Java Code Examples for com.intellij.codeInsight.hint.HintUtil#createInformationLabel()
The following examples show how to use
com.intellij.codeInsight.hint.HintUtil#createInformationLabel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommentByBlockCommentHandler.java From consulo with Apache License 2.0 | 6 votes |
private void showMessageIfNeeded() { if (myWarning != null) { myEditor.getScrollingModel().disableAnimation(); myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); myEditor.getScrollingModel().enableAnimation(); LogicalPosition hintPosition = myCaret.getLogicalPosition(); if (myWarningLocation != null) { LogicalPosition targetPosition = myEditor.offsetToLogicalPosition(myWarningLocation.getStartOffset()); Point targetPoint = myEditor.logicalPositionToXY(targetPosition); if (myEditor.getScrollingModel().getVisibleArea().contains(targetPoint)) { hintPosition = targetPosition; } } LightweightHint hint = new LightweightHint(HintUtil.createInformationLabel(myWarning)); Point p = HintManagerImpl.getHintPosition(hint, myEditor, hintPosition, HintManager.ABOVE); HintManagerImpl.getInstanceImpl().showEditorHint(hint, myEditor, p, 0, 0, false); } }
Example 2
Source File: JSGraphQLQueryContextHighlightVisitor.java From js-graphql-intellij-plugin with MIT License | 5 votes |
/** * Shows a query context hint under the current caret position. * The hint hides after a few seconds or when the user interacts with the editor */ private static void showQueryContextHint(Editor editor, String hintText) { final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl(); final JComponent label = HintUtil.createInformationLabel(hintText); final LightweightHint lightweightHint = new LightweightHint(label); final Point hintPosition = hintManager.getHintPosition(lightweightHint, editor, HintManager.UNDER); hintManager.showEditorHint(lightweightHint, editor, hintPosition, 0, 2000, false, HintManager.UNDER); }
Example 3
Source File: InputPanel.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void showDecisionEventToolTip(Editor editor, int offset, HintManagerImpl hintMgr, String msg) { int flags = HintManager.HIDE_BY_ANY_KEY| HintManager.HIDE_BY_TEXT_CHANGE| HintManager.HIDE_BY_SCROLLING; int timeout = 0; // default? JComponent infoLabel = HintUtil.createInformationLabel(msg); LightweightHint hint = new LightweightHint(infoLabel); final LogicalPosition pos = editor.offsetToLogicalPosition(offset); final Point p = HintManagerImpl.getHintPosition(hint, editor, pos, HintManager.ABOVE); hintMgr.showEditorHint(hint, editor, p, flags, timeout, false); }
Example 4
Source File: ShowUsagesAction.java From dagger-intellij-plugin with Apache License 2.0 | 5 votes |
@NotNull private JComponent createHintComponent(@NotNull String text, @NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition, final Editor editor, @NotNull final Runnable cancelAction, final int maxUsages, @NotNull final FindUsagesOptions options) { JComponent label = HintUtil.createInformationLabel(suggestSecondInvocation(options, handler, text + " ")); InplaceButton button = createSettingsButton(handler, popupPosition, editor, maxUsages, cancelAction); JPanel panel = new JPanel(new BorderLayout()) { @Override public void addNotify() { mySearchEverywhereRunnable = new Runnable() { @Override public void run() { searchEverywhere(options, handler, editor, popupPosition, maxUsages); } }; super.addNotify(); } @Override public void removeNotify() { mySearchEverywhereRunnable = null; super.removeNotify(); } }; button.setBackground(label.getBackground()); panel.setBackground(label.getBackground()); label.setOpaque(false); label.setBorder(null); panel.setBorder(HintUtil.createHintBorder()); panel.add(label, BorderLayout.CENTER); panel.add(button, BorderLayout.EAST); return panel; }
Example 5
Source File: AbstractValueHint.java From consulo with Apache License 2.0 | 5 votes |
protected JComponent createExpandableHintComponent(final SimpleColoredText text, final Runnable expand) { final JComponent component = HintUtil.createInformationLabel(text, IconUtil.getAddIcon()); addClickListenerToHierarchy(component, new ClickListener() { @Override public boolean onClick(@Nonnull MouseEvent event, int clickCount) { if (myCurrentHint != null) { myCurrentHint.hide(); } expand.run(); return true; } }); return component; }
Example 6
Source File: FileInEditorProcessor.java From consulo with Apache License 2.0 | 5 votes |
public static void showHint(@Nonnull Editor editor, @Nonnull String info, @Nullable HyperlinkListener hyperlinkListener) { JComponent component = HintUtil.createInformationLabel(info, hyperlinkListener, null, null); LightweightHint hint = new LightweightHint(component); HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, HintManager.UNDER, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0, false); }
Example 7
Source File: CodeInsightUtilBase.java From consulo with Apache License 2.0 | 5 votes |
public static void showReadOnlyViewWarning(Editor editor) { if (ApplicationManager.getApplication().isHeadlessEnvironment()) return; JComponent component = HintUtil.createInformationLabel("This view is read-only"); final LightweightHint hint = new LightweightHint(component); HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, HintManager.UNDER, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0, false); }
Example 8
Source File: SelectOccurrencesActionHandler.java From consulo with Apache License 2.0 | 5 votes |
protected static void showHint(final Editor editor) { String message = FindBundle.message("select.next.occurence.not.found.message"); final LightweightHint hint = new LightweightHint(HintUtil.createInformationLabel(message)); HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, HintManager.UNDER, HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0, false); }
Example 9
Source File: ShowUsagesAction.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private JComponent createHintComponent(@Nonnull String text, @Nonnull final FindUsagesHandler handler, @Nonnull final RelativePoint popupPosition, final Editor editor, @Nonnull final Runnable cancelAction, final int maxUsages, @Nonnull final FindUsagesOptions options, boolean isWarning) { JComponent label = HintUtil.createInformationLabel(suggestSecondInvocation(options, handler, text + " ")); if (isWarning) { label.setBackground(MessageType.WARNING.getPopupBackground()); } InplaceButton button = createSettingsButton(handler, popupPosition, editor, maxUsages, cancelAction); JPanel panel = new JPanel(new BorderLayout()) { @Override public void addNotify() { mySearchEverywhereRunnable = () -> searchEverywhere(options, handler, editor, popupPosition, maxUsages); super.addNotify(); } @Override public void removeNotify() { mySearchEverywhereRunnable = null; super.removeNotify(); } }; button.setBackground(label.getBackground()); panel.setBackground(label.getBackground()); label.setOpaque(false); label.setBorder(null); panel.setBorder(HintUtil.createHintBorder()); panel.add(label, BorderLayout.CENTER); panel.add(button, BorderLayout.EAST); return panel; }
Example 10
Source File: FindUsagesManager.java From consulo with Apache License 2.0 | 5 votes |
private static void showEditorHint(String message, final Editor editor) { JComponent component = HintUtil.createInformationLabel(message); final LightweightHint hint = new LightweightHint(component); HintManagerImpl.getInstanceImpl() .showEditorHint(hint, editor, HintManager.UNDER, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0, false); }
Example 11
Source File: ShowUsagesAction.java From otto-intellij-plugin with Apache License 2.0 | 5 votes |
@NotNull private JComponent createHintComponent(@NotNull String text, @NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition, final Editor editor, @NotNull final Runnable cancelAction, final int maxUsages, @NotNull final FindUsagesOptions options) { JComponent label = HintUtil.createInformationLabel(suggestSecondInvocation(options, handler, text + " ")); InplaceButton button = createSettingsButton(handler, popupPosition, editor, maxUsages, cancelAction); JPanel panel = new JPanel(new BorderLayout()) { @Override public void addNotify() { mySearchEverywhereRunnable = new Runnable() { @Override public void run() { searchEverywhere(options, handler, editor, popupPosition, maxUsages); } }; super.addNotify(); } @Override public void removeNotify() { mySearchEverywhereRunnable = null; super.removeNotify(); } }; button.setBackground(label.getBackground()); panel.setBackground(label.getBackground()); label.setOpaque(false); label.setBorder(null); panel.setBorder(HintUtil.createHintBorder()); panel.add(label, BorderLayout.CENTER); panel.add(button, BorderLayout.EAST); return panel; }
Example 12
Source File: CtrlMouseHandler.java From consulo with Apache License 2.0 | 4 votes |
private void addHighlighterAndShowHint(@Nonnull Info info, @Nonnull DocInfo docInfo, @Nonnull EditorEx editor) { if (myDisposed || editor.isDisposed()) return; if (myHighlighter != null) { if (!info.isSimilarTo(myHighlighter.getStoredInfo())) { disposeHighlighter(); } else { // highlighter already set if (info.isNavigatable()) { editor.setCustomCursor(CtrlMouseHandler.class, Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } return; } } if (!info.isValid(editor.getDocument()) || !info.isNavigatable() && docInfo.text == null) { return; } boolean highlighterOnly = EditorSettingsExternalizable.getInstance().isShowQuickDocOnMouseOverElement() && DocumentationManager.getInstance(myProject).getDocInfoHint() != null; myHighlighter = installHighlighterSet(info, editor, highlighterOnly); if (highlighterOnly || docInfo.text == null) return; HyperlinkListener hyperlinkListener = docInfo.docProvider == null ? null : new QuickDocHyperlinkListener(docInfo.docProvider, info.myElementAtPointer); Ref<Consumer<? super String>> newTextConsumerRef = new Ref<>(); JComponent component = HintUtil.createInformationLabel(docInfo.text, hyperlinkListener, null, newTextConsumerRef); component.setBorder(JBUI.Borders.empty(6, 6, 5, 6)); final LightweightHint hint = new LightweightHint(wrapInScrollPaneIfNeeded(component, editor)); myHint = hint; hint.addHintListener(__ -> myHint = null); showHint(hint, editor); Consumer<? super String> newTextConsumer = newTextConsumerRef.get(); if (newTextConsumer != null) { updateOnPsiChanges(hint, info, newTextConsumer, docInfo.text, editor); } }