use of com.intellij.openapi.editor.ex.EditorGutterComponentEx in project intellij-community by JetBrains.
the class DiffLineMarkerRenderer method paint.
@Override
public void paint(Editor editor, Graphics g, Rectangle range) {
Color color = myDiffType.getPolygonColor(editor);
if (color == null) {
return;
}
EditorGutterComponentEx gutter = ((EditorEx) editor).getGutterComponentEx();
Graphics2D g2 = (Graphics2D) g;
int x = 0;
int y = range.y;
int width = gutter.getWidth();
int height = range.height;
if (!myDiffType.isApplied()) {
if (height > 2) {
g.setColor(color);
g.fillRect(x, y, width, height);
DiffUtil.drawDoubleShadowedLine(g2, x, x + width, y - 1, color);
DiffUtil.drawDoubleShadowedLine(g2, x, x + width, y + height - 1, color);
} else {
// insertion or deletion, when a range is null. matching the text highlighter which is a 2 pixel line
DiffUtil.drawDoubleShadowedLine(g2, x, x + width, y - 1, color);
}
} else {
DiffUtil.drawBoldDottedFramingLines(g2, x, x + width, y - 1, y + height - 1, color);
}
}
use of com.intellij.openapi.editor.ex.EditorGutterComponentEx in project intellij-community by JetBrains.
the class CoverageLineMarkerRenderer method moveToLine.
public void moveToLine(final int lineNumber, final Editor editor) {
final int firstOffset = editor.getDocument().getLineStartOffset(lineNumber);
editor.getCaretModel().moveToOffset(firstOffset);
editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
editor.getScrollingModel().runActionOnScrollingFinished(() -> {
Point p = editor.visualPositionToXY(editor.offsetToVisualPosition(firstOffset));
EditorGutterComponentEx editorComponent = (EditorGutterComponentEx) editor.getGutter();
JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane();
p = SwingUtilities.convertPoint(editorComponent, THICKNESS, p.y, layeredPane);
showHint(editor, p, lineNumber);
});
}
use of com.intellij.openapi.editor.ex.EditorGutterComponentEx in project intellij-community by JetBrains.
the class EditBreakpointActionHandler method editBreakpoint.
public void editBreakpoint(@NotNull Project project, @NotNull Editor editor, @NotNull Object breakpoint, @NotNull GutterIconRenderer breakpointGutterRenderer) {
if (BreakpointsDialogFactory.getInstance(project).isBreakpointPopupShowing())
return;
EditorGutterComponentEx gutterComponent = ((EditorEx) editor).getGutterComponentEx();
Point point = gutterComponent.getCenterPoint(breakpointGutterRenderer);
if (point != null) {
doShowPopup(project, gutterComponent, point, breakpoint);
}
}
use of com.intellij.openapi.editor.ex.EditorGutterComponentEx in project intellij-plugins by JetBrains.
the class SplitEditorToolbar method adjustSpacing.
private void adjustSpacing() {
EditorGutterComponentEx leftMostGutter = null;
for (EditorGutterComponentEx gutter : myGutters) {
if (!gutter.isShowing()) {
continue;
}
if (leftMostGutter == null || leftMostGutter.getX() > gutter.getX()) {
leftMostGutter = gutter;
}
}
final int spacing;
if (leftMostGutter == null) {
spacing = 0;
} else {
spacing = leftMostGutter.getWhitespaceSeparatorOffset();
}
mySpacingPanel.setSpacing(spacing);
revalidate();
repaint();
}
use of com.intellij.openapi.editor.ex.EditorGutterComponentEx in project intellij-community by JetBrains.
the class OpenInEditorWithMouseAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
InputEvent inputEvent = e.getInputEvent();
if (!(inputEvent instanceof MouseEvent)) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
if (e.getProject() == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
if (e.getData(OpenInEditorAction.KEY) == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
Component component = inputEvent.getComponent();
if (component == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
Point point = ((MouseEvent) inputEvent).getPoint();
Component componentAt = SwingUtilities.getDeepestComponentAt(component, point.x, point.y);
if (!(componentAt instanceof EditorGutterComponentEx)) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
Editor editor = getEditor(componentAt);
if (editor == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
MouseEvent convertedEvent = SwingUtilities.convertMouseEvent(inputEvent.getComponent(), (MouseEvent) inputEvent, componentAt);
EditorMouseEventArea area = editor.getMouseEventArea(convertedEvent);
if (area != EditorMouseEventArea.LINE_NUMBERS_AREA) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
e.getPresentation().setEnabledAndVisible(true);
}
Aggregations