@Override public LightweightHint show(@NotNull Editor editor, @NotNull Point p, boolean alignToRight, @NotNull TooltipGroup group, @NotNull HintHint hintHint) { myTrafficLightRenderer = (TrafficLightRenderer)((EditorMarkupModelImpl)editor.getMarkupModel()).getErrorStripeRenderer(); myPanel = new TrafficProgressPanel(myTrafficLightRenderer, editor, hintHint); repaintTooltipWindow(); LineTooltipRenderer.correctLocation(editor, myPanel, p, alignToRight, true, myPanel.getMinWidth()); LightweightHint hint = new LightweightHint(myPanel); HintManagerImpl hintManager = (HintManagerImpl)HintManager.getInstance(); hintManager.showEditorHint(hint, editor, p, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_OTHER_HINT | HintManager.HIDE_BY_SCROLLING, 0, false, hintHint); hint.addHintListener(new HintListener() { @Override public void hintHidden(EventObject event) { if (myPanel == null) return; //double hide? myPanel = null; onHide.run(); } }); return hint; }
@Override public LightweightHint show(@NotNull Editor editor, @NotNull Point p, boolean alignToRight, @NotNull TooltipGroup group, @NotNull HintHint hintHint) { myTrafficLightRenderer = (TrafficLightRenderer)((EditorMarkupModelImpl)editor.getMarkupModel()).getErrorStripeRenderer(); myPanel = new TrafficProgressPanel(myTrafficLightRenderer, editor, hintHint); LineTooltipRenderer.correctLocation(editor, myPanel, p, alignToRight, false, -1); LightweightHint hint = new LightweightHint(myPanel); HintManagerImpl hintManager = (HintManagerImpl)HintManager.getInstance(); hintManager.showEditorHint(hint, editor, p, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_OTHER_HINT | HintManager.HIDE_BY_SCROLLING, 0, false, hintHint); hint.addHintListener(new HintListener() { @Override public void hintHidden(EventObject event) { if (myPanel == null) return; //double hide? myPanel = null; onHide.run(); } }); repaintTooltipWindow(); return hint; }
@Override public LightweightHint show(@Nonnull Editor editor, @Nonnull Point p, boolean alignToRight, @Nonnull TooltipGroup group, @Nonnull HintHint hintHint) { myTrafficLightRenderer = (TrafficLightRenderer)((EditorMarkupModelImpl)editor.getMarkupModel()).getErrorStripeRenderer(); myPanel = new TrafficProgressPanel(myTrafficLightRenderer, editor, hintHint); repaintTooltipWindow(); LineTooltipRenderer.correctLocation(editor, myPanel, p, alignToRight, true, myPanel.getMinWidth()); LightweightHint hint = new LightweightHint(myPanel); HintManagerImpl hintManager = (HintManagerImpl)HintManager.getInstance(); hintManager.showEditorHint(hint, editor, p, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_OTHER_HINT | HintManager.HIDE_BY_SCROLLING, 0, false, hintHint); hint.addHintListener(new HintListener() { @Override public void hintHidden(EventObject event) { if (myPanel == null) return; //double hide? myPanel = null; onHide.run(); } }); return hint; }
public static void showActiveHint(@NotNull Range range, @NotNull Editor editor, @Nullable Point mousePosition, @NotNull LineStatusTracker tracker) { final Disposable disposable = Disposer.newDisposable(); List<DiffFragment> wordDiff = computeWordDiff(range, tracker); installEditorHighlighters(range, editor, tracker, wordDiff, disposable); Pair<JComponent, Integer> editorComponent = createEditorComponent(range, editor, tracker, wordDiff); ActionToolbar toolbar = buildToolbar(range, editor, tracker, disposable); toolbar.updateActionsImmediately(); // we need valid ActionToolbar.getPreferredSize() to calc size of popup PopupPanel popupPanel = new PopupPanel(editor, toolbar, editorComponent.first, editorComponent.second); LightweightHint hint = new LightweightHint(popupPanel); HintListener closeListener = new HintListener() { public void hintHidden(final EventObject event) { Disposer.dispose(disposable); } }; hint.addHintListener(closeListener); int line = editor.getCaretModel().getLogicalPosition().line; Point point = HintManagerImpl.getHintPosition(hint, editor, new LogicalPosition(line, 0), HintManager.UNDER); if (mousePosition != null) { // show right after the nearest line int lineHeight = editor.getLineHeight(); int delta = (point.y - mousePosition.y) % lineHeight; if (delta < 0) delta += lineHeight; point.y = mousePosition.y + delta; } point.x -= popupPanel.getEditorTextOffset(); // align main editor with the one in popup int flags = HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING; HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, point, flags, -1, false, new HintHint(editor, point)); if (!hint.isVisible()) { closeListener.hintHidden(null); } }
public void showHintAt(@Nullable Point mousePosition) { if (!myTracker.isValid()) return; final Disposable disposable = Disposer.newDisposable(); FileType fileType = getFileType(); List<DiffFragment> wordDiff = computeWordDiff(); installMasterEditorHighlighters(wordDiff, disposable); JComponent editorComponent = createEditorComponent(fileType, wordDiff); ActionToolbar toolbar = buildToolbar(mousePosition, disposable); toolbar.updateActionsImmediately(); // we need valid ActionToolbar.getPreferredSize() to calc size of popup toolbar.setReservePlaceAutoPopupIcon(false); PopupPanel popupPanel = new PopupPanel(myEditor, toolbar, editorComponent); LightweightHint hint = new LightweightHint(popupPanel); HintListener closeListener = new HintListener() { public void hintHidden(final EventObject event) { Disposer.dispose(disposable); } }; hint.addHintListener(closeListener); int line = myEditor.getCaretModel().getLogicalPosition().line; Point point = HintManagerImpl.getHintPosition(hint, myEditor, new LogicalPosition(line, 0), HintManager.UNDER); if (mousePosition != null) { // show right after the nearest line int lineHeight = myEditor.getLineHeight(); int delta = (point.y - mousePosition.y) % lineHeight; if (delta < 0) delta += lineHeight; point.y = mousePosition.y + delta; } point.x -= popupPanel.getEditorTextOffset(); // align main editor with the one in popup int flags = HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING; HintManagerImpl.getInstanceImpl().showEditorHint(hint, myEditor, point, flags, -1, false, new HintHint(myEditor, point)); if (!hint.isVisible()) { closeListener.hintHidden(null); } }