@Nullable public RelativePoint getHyperlinkLocation(HyperlinkInfo info) { Editor editor = myLogEditor.getValue(); Project project = editor.getProject(); RangeHighlighter range = myHyperlinkSupport.getValue().findHyperlinkRange(info); Window window = NotificationsManagerImpl.findWindowForBalloon(project); if (range != null && window != null) { Point point = editor.visualPositionToXY(editor.offsetToVisualPosition(range.getStartOffset())); return new RelativePoint( window, SwingUtilities.convertPoint(editor.getContentComponent(), point, window)); } return null; }
private void addToPopup( @NotNull final BalloonImpl balloon, @NotNull BalloonLayoutData layoutData) { layoutData.doLayout = new Runnable() { @Override public void run() { WelcomeBalloonLayoutImpl.this.layoutPopup(); } }; layoutData.configuration = layoutData.configuration.replace( JBUI.scale(myPopupBalloon == null ? 7 : 5), JBUI.scale(12)); if (myPopupBalloon == null) { final JScrollPane pane = NotificationsManagerImpl.createBalloonScrollPane(myBalloonPanel, true); pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); pane.getVerticalScrollBar() .addComponentListener( new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { pane.setBorder( IdeBorderFactory.createEmptyBorder(SystemInfo.isMac ? 2 : 1, 0, 1, 1)); } @Override public void componentHidden(ComponentEvent e) { pane.setBorder(IdeBorderFactory.createEmptyBorder()); } }); myPopupBalloon = new BalloonImpl( pane, BORDER_COLOR, new Insets(0, 0, 0, 0), FILL_COLOR, true, false, false, false, true, 0, false, false, null, false, 0, 0, 0, 0, false, null, null, false, false, false, null, false); myPopupBalloon.setAnimationEnabled(false); myPopupBalloon.setShadowBorderProvider( new NotificationBalloonShadowBorderProvider(FILL_COLOR, BORDER_COLOR)); myPopupBalloon.setHideListener( new Runnable() { @Override public void run() { myPopupBalloon.getComponent().setVisible(false); } }); myPopupBalloon.setActionProvider( new BalloonImpl.ActionProvider() { private BalloonImpl.ActionButton myAction; @NotNull @Override public List<BalloonImpl.ActionButton> createActions() { myAction = myPopupBalloon .new ActionButton( AllIcons.Ide.Notification.Close, null, null, Consumer.EMPTY_CONSUMER); return Collections.singletonList(myAction); } @Override public void layout(@NotNull Rectangle bounds) { myAction.setBounds(0, 0, 0, 0); } }); } myBalloonPanel.add(balloon.getContent()); balloon.getContent().putClientProperty(TYPE_KEY, layoutData.type); Disposer.register( balloon, new Disposable() { @Override public void dispose() { myBalloons.remove(balloon); myBalloonPanel.remove(balloon.getContent()); updatePopup(); } }); myBalloons.add(balloon); updatePopup(); }