Search in sources :

Example 11 with HintHint

use of com.intellij.ui.HintHint in project intellij-community by JetBrains.

the class GraphTableController method showToolTip.

private void showToolTip(@NotNull String text, @NotNull MouseEvent e) {
    // standard tooltip does not allow to customize its location, and locating tooltip above can obscure some important info
    Point point = new Point(e.getX() + 5, e.getY());
    JEditorPane tipComponent = IdeTooltipManager.initPane(text, new HintHint(myTable, point).setAwtTooltip(true), null);
    IdeTooltip tooltip = new IdeTooltip(myTable, point, new Wrapper(tipComponent)).setPreferredPosition(Balloon.Position.atRight);
    IdeTooltipManager.getInstance().show(tooltip, false);
}
Also used : Wrapper(com.intellij.ui.components.panels.Wrapper) HintHint(com.intellij.ui.HintHint) IdeTooltip(com.intellij.ide.IdeTooltip)

Example 12 with HintHint

use of com.intellij.ui.HintHint in project intellij-community by JetBrains.

the class DiffRequestProcessor method notifyMessage.

private void notifyMessage(@NotNull AnActionEvent e, boolean next) {
    Editor editor = e.getData(DiffDataKeys.CURRENT_EDITOR);
    // TODO: provide "change" word in chain UserData - for tests/etc
    String message = DiffUtil.createNotificationText(next ? "Press again to go to the next file" : "Press again to go to the previous file", "You can disable this feature in " + DiffUtil.getSettingsConfigurablePath());
    final LightweightHint hint = new LightweightHint(HintUtil.createInformationLabel(message));
    Point point = new Point(myContentPanel.getWidth() / 2, next ? myContentPanel.getHeight() - JBUI.scale(40) : JBUI.scale(40));
    if (editor == null) {
        final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        final HintHint hintHint = createNotifyHint(myContentPanel, point, next);
        hint.show(myContentPanel, point.x, point.y, owner instanceof JComponent ? (JComponent) owner : null, hintHint);
    } else {
        int x = SwingUtilities.convertPoint(myContentPanel, point, editor.getComponent()).x;
        JComponent header = editor.getHeaderComponent();
        int shift = editor.getScrollingModel().getVerticalScrollOffset() - (header != null ? header.getHeight() : 0);
        LogicalPosition position;
        LineRange changeRange = e.getData(DiffDataKeys.CURRENT_CHANGE_RANGE);
        if (changeRange == null) {
            position = new LogicalPosition(editor.getCaretModel().getLogicalPosition().line + (next ? 1 : 0), 0);
        } else {
            position = new LogicalPosition(next ? changeRange.end : changeRange.start, 0);
        }
        int y = editor.logicalPositionToXY(position).y - shift;
        Point editorPoint = new Point(x, y);
        final HintHint hintHint = createNotifyHint(editor.getComponent(), editorPoint, !next);
        HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, editorPoint, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0, false, hintHint);
    }
}
Also used : LogicalPosition(com.intellij.openapi.editor.LogicalPosition) HintHint(com.intellij.ui.HintHint) LightweightHint(com.intellij.ui.LightweightHint) Editor(com.intellij.openapi.editor.Editor) LineRange(com.intellij.diff.util.LineRange) LightweightHint(com.intellij.ui.LightweightHint) HintHint(com.intellij.ui.HintHint)

Example 13 with HintHint

use of com.intellij.ui.HintHint in project intellij-community by JetBrains.

the class DaemonTooltipUtil method showInfoTooltip.

public static void showInfoTooltip(@NotNull final HighlightInfo info, @NotNull Editor editor, final int defaultOffset, final int currentWidth, final boolean requestFocus) {
    if (info.getToolTip() == null)
        return;
    Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
    Point bestPoint = editor.logicalPositionToXY(editor.offsetToLogicalPosition(defaultOffset));
    bestPoint.y += editor.getLineHeight() / 2;
    if (!visibleArea.contains(bestPoint)) {
        bestPoint = editor.logicalPositionToXY(editor.offsetToLogicalPosition(defaultOffset));
    }
    Point p = SwingUtilities.convertPoint(editor.getContentComponent(), bestPoint, editor.getComponent().getRootPane().getLayeredPane());
    HintHint hintHint = new HintHint(editor, bestPoint).setAwtTooltip(true).setHighlighterType(true).setRequestFocus(requestFocus).setCalloutShift(editor.getLineHeight() / 2 - 1);
    TooltipController.getInstance().showTooltip(editor, p, info.getToolTip(), currentWidth, false, DAEMON_INFO_GROUP, hintHint);
}
Also used : HintHint(com.intellij.ui.HintHint)

Example 14 with HintHint

use of com.intellij.ui.HintHint in project intellij-community by JetBrains.

the class LineStatusMarkerPopup method showHintAt.

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);
    // we need valid ActionToolbar.getPreferredSize() to calc size of popup
    toolbar.updateActionsImmediately();
    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;
    }
    // align main editor with the one in popup
    point.x -= popupPanel.getEditorTextOffset();
    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);
    }
}
Also used : Disposable(com.intellij.openapi.Disposable) LightweightHint(com.intellij.ui.LightweightHint) EventObject(java.util.EventObject) HintHint(com.intellij.ui.HintHint) LightweightHint(com.intellij.ui.LightweightHint) HintListener(com.intellij.ui.HintListener) HintHint(com.intellij.ui.HintHint) DiffFragment(com.intellij.diff.fragments.DiffFragment) PlainTextFileType(com.intellij.openapi.fileTypes.PlainTextFileType) FileType(com.intellij.openapi.fileTypes.FileType)

Example 15 with HintHint

use of com.intellij.ui.HintHint in project intellij-community by JetBrains.

the class DocumentFragmentTooltipRenderer method show.

@Override
public LightweightHint show(@NotNull final Editor editor, @NotNull Point p, boolean alignToRight, @NotNull TooltipGroup group, @NotNull HintHint intInfo) {
    LightweightHint hint;
    final JComponent editorComponent = editor.getComponent();
    TextRange range = myDocumentFragment.getTextRange();
    int startOffset = range.getStartOffset();
    int endOffset = range.getEndOffset();
    Document doc = myDocumentFragment.getDocument();
    int endLine = doc.getLineNumber(endOffset);
    int startLine = doc.getLineNumber(startOffset);
    JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane();
    // There is a possible case that collapsed folding region is soft wrapped, hence, we need to anchor
    // not logical but visual line start.
    VisualPosition visual = editor.offsetToVisualPosition(startOffset);
    p = editor.visualPositionToXY(visual);
    p = SwingUtilities.convertPoint(((EditorEx) editor).getGutterComponentEx(), p, layeredPane);
    p.x -= 3;
    p.y += editor.getLineHeight();
    Point screenPoint = new Point(p);
    SwingUtilities.convertPointToScreen(screenPoint, layeredPane);
    int maxLineCount = (ScreenUtil.getScreenRectangle(screenPoint).height - screenPoint.y) / editor.getLineHeight();
    if (endLine - startLine > maxLineCount) {
        endOffset = doc.getLineEndOffset(Math.max(0, Math.min(startLine + maxLineCount, doc.getLineCount() - 1)));
    }
    if (endOffset < startOffset)
        return null;
    FoldingModelEx foldingModel = (FoldingModelEx) editor.getFoldingModel();
    foldingModel.setFoldingEnabled(false);
    TextRange textRange = new TextRange(startOffset, endOffset);
    hint = EditorFragmentComponent.showEditorFragmentHintAt(editor, textRange, p.y, false, false, true, true, true);
    foldingModel.setFoldingEnabled(true);
    return hint;
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) LightweightHint(com.intellij.ui.LightweightHint) TextRange(com.intellij.openapi.util.TextRange) FoldingModelEx(com.intellij.openapi.editor.ex.FoldingModelEx) HintHint(com.intellij.ui.HintHint) LightweightHint(com.intellij.ui.LightweightHint)

Aggregations

HintHint (com.intellij.ui.HintHint)18 LightweightHint (com.intellij.ui.LightweightHint)10 Document (com.intellij.openapi.editor.Document)4 TooltipController (com.intellij.codeInsight.hint.TooltipController)2 Editor (com.intellij.openapi.editor.Editor)2 RelativePoint (com.intellij.ui.awt.RelativePoint)2 NonOpaquePanel (com.intellij.ui.components.panels.NonOpaquePanel)2 GutterMark (com.intellij.codeInsight.daemon.GutterMark)1 NonHideableIconGutterMark (com.intellij.codeInsight.daemon.NonHideableIconGutterMark)1 ErrorInfo (com.intellij.designer.model.ErrorInfo)1 DiffFragment (com.intellij.diff.fragments.DiffFragment)1 LineRange (com.intellij.diff.util.LineRange)1 IdeTooltip (com.intellij.ide.IdeTooltip)1 EditorWindow (com.intellij.injected.editor.EditorWindow)1 Disposable (com.intellij.openapi.Disposable)1 EditorFactory (com.intellij.openapi.editor.EditorFactory)1 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)1 EditorActionManager (com.intellij.openapi.editor.actionSystem.EditorActionManager)1 TypedAction (com.intellij.openapi.editor.actionSystem.TypedAction)1 EditorEx (com.intellij.openapi.editor.ex.EditorEx)1