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);
}
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);
}
}
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);
}
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);
}
}
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;
}
Aggregations