Search in sources :

Example 6 with EditorGutterComponentEx

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);
    }
}
Also used : EditorGutterComponentEx(com.intellij.openapi.editor.ex.EditorGutterComponentEx) EditorEx(com.intellij.openapi.editor.ex.EditorEx)

Example 7 with EditorGutterComponentEx

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);
    });
}
Also used : EditorGutterComponentEx(com.intellij.openapi.editor.ex.EditorGutterComponentEx) LightweightHint(com.intellij.ui.LightweightHint) HintHint(com.intellij.ui.HintHint)

Example 8 with EditorGutterComponentEx

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);
    }
}
Also used : EditorGutterComponentEx(com.intellij.openapi.editor.ex.EditorGutterComponentEx) EditorEx(com.intellij.openapi.editor.ex.EditorEx)

Example 9 with EditorGutterComponentEx

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();
}
Also used : EditorGutterComponentEx(com.intellij.openapi.editor.ex.EditorGutterComponentEx)

Example 10 with EditorGutterComponentEx

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);
}
Also used : EditorGutterComponentEx(com.intellij.openapi.editor.ex.EditorGutterComponentEx) MouseEvent(java.awt.event.MouseEvent) InputEvent(java.awt.event.InputEvent) EditorMouseEventArea(com.intellij.openapi.editor.event.EditorMouseEventArea) Editor(com.intellij.openapi.editor.Editor)

Aggregations

EditorGutterComponentEx (com.intellij.openapi.editor.ex.EditorGutterComponentEx)13 EditorEx (com.intellij.openapi.editor.ex.EditorEx)6 NotNull (org.jetbrains.annotations.NotNull)4 Editor (com.intellij.openapi.editor.Editor)3 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)2 FileHyperlinkInfo (com.intellij.execution.filters.FileHyperlinkInfo)1 HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)1 EditorHyperlinkSupport (com.intellij.execution.impl.EditorHyperlinkSupport)1 AllIcons (com.intellij.icons.AllIcons)1 Disposable (com.intellij.openapi.Disposable)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 Logger (com.intellij.openapi.diagnostic.Logger)1 ColorKey (com.intellij.openapi.editor.colors.ColorKey)1 EditorFontType (com.intellij.openapi.editor.colors.EditorFontType)1 EditorMouseEventArea (com.intellij.openapi.editor.event.EditorMouseEventArea)1 RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1