Java Code Examples for com.intellij.codeInsight.hint.HintManager#HIDE_BY_ANY_KEY

The following examples show how to use com.intellij.codeInsight.hint.HintManager#HIDE_BY_ANY_KEY . 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: LSPReferencesAction.java    From lsp4intellij with Apache License 2.0 5 votes vote down vote up
private void showReferences(Editor editor, List<PsiElement2UsageTargetAdapter> targets, LogicalPosition position) {
    if (targets.isEmpty()) {
        short constraint = HintManager.ABOVE;
        int flags = HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING;
        JLabel label = new JLabel("No references found");
        label.setBackground(new JBColor(new Color(150, 0, 0), new Color(150, 0, 0)));
        LightweightHint hint = new LightweightHint(label);
        Point p = HintManagerImpl.getHintPosition(hint, editor, position, constraint);
        HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, p, flags, 0, false,
                HintManagerImpl.createHintHint(editor, p, hint, constraint).setContentActive(false));
    } else {
        List<Usage> usages = new ArrayList<>();
        targets.forEach(ut -> {
            PsiElement elem = ut.getElement();
            usages.add(new UsageInfo2UsageAdapter(new UsageInfo(elem, -1, -1, false)));
        });

        if (editor == null) {
            return;
        }
        Project project = editor.getProject();
        if (project == null) {
            return;
        }
        UsageViewPresentation presentation = createPresentation(targets.get(0).getElement(),
                new FindUsagesOptions(editor.getProject()), false);
        UsageViewManager.getInstance(project)
                .showUsages(new UsageTarget[] { targets.get(0) }, usages.toArray(new Usage[usages.size()]),
                        presentation);
    }
}
 
Example 2
Source File: InputPanel.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void showPreviewEditorErrorToolTip(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?
	hintMgr.showErrorHint(editor, msg,
	                      offset, offset+1,
	                      HintManager.ABOVE, flags, timeout);
}
 
Example 3
Source File: InputPanel.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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: LineStatusMarkerPopup.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void showHintAt(@javax.annotation.Nullable Point mousePosition) {
  if (!myTracker.isValid()) return;
  final Disposable disposable = Disposable.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);
  }
}