use of com.intellij.codeInsight.hint.TooltipController in project intellij-community by JetBrains.
the class EditorGutterComponentImpl method mouseMoved.
@Override
public void mouseMoved(final MouseEvent e) {
String toolTip = null;
final GutterIconRenderer renderer = getGutterRenderer(e);
TooltipController controller = TooltipController.getInstance();
if (renderer != null) {
toolTip = renderer.getTooltipText();
} else {
TextAnnotationGutterProvider provider = getProviderAtPoint(e.getPoint());
if (provider != null) {
final int line = getLineNumAtPoint(e.getPoint());
toolTip = provider.getToolTip(line, myEditor);
if (!Comparing.equal(toolTip, myLastGutterToolTip)) {
controller.cancelTooltip(GUTTER_TOOLTIP_GROUP, e, true);
myLastGutterToolTip = toolTip;
}
} else {
ActiveGutterRenderer lineRenderer = getActiveRendererByMouseEvent(e);
if (lineRenderer != null) {
toolTip = lineRenderer.getTooltipText();
}
}
}
if (toolTip != null && !toolTip.isEmpty()) {
final Ref<Point> t = new Ref<>(e.getPoint());
int line = EditorUtil.yPositionToLogicalLine(myEditor, e);
List<GutterMark> row = getGutterRenderers(line);
Balloon.Position ballPosition = Balloon.Position.atRight;
if (row != null) {
final TreeMap<Integer, GutterMark> xPos = new TreeMap<>();
final int[] currentPos = { 0 };
processIconsRow(line, row, (x, y, r) -> {
xPos.put(x, r);
if (renderer == r) {
currentPos[0] = x;
Icon icon = scaleIcon(r.getIcon());
t.set(new Point(x + icon.getIconWidth() / 2, y + icon.getIconHeight() / 2));
}
});
List<Integer> xx = new ArrayList<>(xPos.keySet());
int posIndex = xx.indexOf(currentPos[0]);
if (xPos.size() > 1 && posIndex == 0) {
ballPosition = Balloon.Position.below;
}
}
RelativePoint showPoint = new RelativePoint(this, t.get());
controller.showTooltipByMouseMove(myEditor, showPoint, ((EditorMarkupModel) myEditor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(toolTip), false, GUTTER_TOOLTIP_GROUP, new HintHint(this, t.get()).setAwtTooltip(true).setPreferredPosition(ballPosition));
} else {
controller.cancelTooltip(GUTTER_TOOLTIP_GROUP, e, false);
}
}
use of com.intellij.codeInsight.hint.TooltipController in project intellij-community by JetBrains.
the class ConsoleGutterComponent method mouseMoved.
@Override
public void mouseMoved(MouseEvent e) {
int line = EditorUtil.yPositionToLogicalLine(editor, e.getPoint());
if (line == lastGutterToolTipLine) {
return;
}
TooltipController controller = TooltipController.getInstance();
if (lastGutterToolTipLine != -1) {
controller.cancelTooltip(TOOLTIP_GROUP, e, true);
}
String toolTip = gutterContentProvider.getToolTip(line, editor);
setCursor(toolTip == null ? Cursor.getDefaultCursor() : Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
if (toolTip == null) {
lastGutterToolTipLine = -1;
controller.cancelTooltip(TOOLTIP_GROUP, e, false);
} else {
lastGutterToolTipLine = line;
RelativePoint showPoint = new RelativePoint(this, e.getPoint());
controller.showTooltipByMouseMove(editor, showPoint, ((EditorMarkupModel) editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(toolTip), false, TOOLTIP_GROUP, new HintHint(this, e.getPoint()).setAwtTooltip(true));
}
}
Aggregations