use of com.intellij.ui.LightweightHint in project intellij-plugins by JetBrains.
the class AbstractDartFileProcessingAction method showHintLater.
public static void showHintLater(@NotNull final Editor editor, @NotNull final String text, final boolean error) {
ApplicationManager.getApplication().invokeLater(() -> {
final JComponent component = error ? HintUtil.createErrorLabel(text) : HintUtil.createInformationLabel(text);
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);
}, ModalityState.NON_MODAL, o -> editor.isDisposed() || !editor.getComponent().isShowing());
}
use of com.intellij.ui.LightweightHint in project intellij-community by JetBrains.
the class TooltipController method showTooltipByMouseMove.
public void showTooltipByMouseMove(@NotNull final Editor editor, @NotNull final RelativePoint point, final TooltipRenderer tooltipObject, final boolean alignToRight, @NotNull final TooltipGroup group, @NotNull HintHint hintHint) {
LightweightHint currentTooltip = myCurrentTooltip;
if (currentTooltip == null || !currentTooltip.isVisible()) {
if (currentTooltip != null) {
if (!IdeTooltipManager.getInstance().isQueuedToShow(currentTooltip.getCurrentIdeTooltip())) {
myCurrentTooltipObject = null;
}
} else {
myCurrentTooltipObject = null;
}
}
if (Comparing.equal(tooltipObject, myCurrentTooltipObject)) {
IdeTooltipManager.getInstance().cancelAutoHide();
return;
}
hideCurrentTooltip();
if (tooltipObject != null) {
final Point p = point.getPointOn(editor.getComponent().getRootPane().getLayeredPane()).getPoint();
if (!hintHint.isAwtTooltip()) {
p.x += alignToRight ? -10 : 10;
}
Project project = editor.getProject();
if (project != null && !project.isOpen())
return;
if (editor.getContentComponent().isShowing()) {
showTooltip(editor, p, tooltipObject, alignToRight, group, hintHint);
}
}
}
use of com.intellij.ui.LightweightHint in project intellij-community by JetBrains.
the class TooltipController method hideCurrentTooltip.
private void hideCurrentTooltip() {
if (myCurrentTooltip != null) {
LightweightHint currentTooltip = myCurrentTooltip;
myCurrentTooltip = null;
currentTooltip.hide();
myCurrentTooltipGroup = null;
IdeTooltipManager.getInstance().hide(null);
}
}
use of com.intellij.ui.LightweightHint 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;
}
use of com.intellij.ui.LightweightHint 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);
}
}
Aggregations