Java 类com.intellij.openapi.editor.ex.EditorGutterComponentEx 实例源码

项目:intellij-ce-playground    文件:DiffLineMarkerRenderer.java   
@Override
public void paint(Editor editor, Graphics g, Rectangle range) {
  EditorGutterComponentEx gutter = ((EditorEx)editor).getGutterComponentEx();
  Graphics2D g2 = (Graphics2D)g;
  int x1 = 0;
  int x2 = x1 + gutter.getWidth();
  int y = range.y;
  int height = range.height;

  int annotationsOffset = gutter.getAnnotationsAreaOffset();
  int annotationsWidth = gutter.getAnnotationsAreaWidth();
  if (annotationsWidth != 0) {
    drawMarker(editor, g2, x1, annotationsOffset, y, height, false);
    x1 = annotationsOffset + annotationsWidth;
  }

  if (myIgnoredFoldingOutline) {
    int xOutline = gutter.getWhitespaceSeparatorOffset();
    drawMarker(editor, g2, xOutline, x2, y, height, true);
    drawMarker(editor, g2, x1, xOutline, y, height, false);
  } else {
    drawMarker(editor, g2, x1, x2, y, height, false);
  }
}
项目:intellij-ce-playground    文件:DiffLineSeparatorRenderer.java   
@Override
public void paint(Editor editor, Graphics g, Rectangle r) {
  if (!myCondition.get()) return;

  int y = r.y;
  int lineHeight = myEditor.getLineHeight();

  EditorGutterComponentEx gutter = ((EditorEx)editor).getGutterComponentEx();
  int annotationsOffset = gutter.getAnnotationsAreaOffset();
  int annotationsWidth = gutter.getAnnotationsAreaWidth();
  if (annotationsWidth != 0) {
    g.setColor(editor.getColorsScheme().getColor(EditorColors.GUTTER_BACKGROUND));
    g.fillRect(annotationsOffset, y, annotationsWidth, lineHeight);
  }

  draw(g, 0, y, lineHeight, myEditor.getColorsScheme());
}
项目:intellij-ce-playground    文件:CaretImpl.java   
private void requestRepaint(VerticalInfo oldCaretInfo) {
  int lineHeight = myEditor.getLineHeight();
  Rectangle visibleArea = myEditor.getScrollingModel().getVisibleArea();
  final EditorGutterComponentEx gutter = myEditor.getGutterComponentEx();
  final EditorComponentImpl content = myEditor.getContentComponent();

  int updateWidth = myEditor.getScrollPane().getHorizontalScrollBar().getValue() + visibleArea.width;
  if (Math.abs(myCaretInfo.y - oldCaretInfo.y) <= 2 * lineHeight) {
    int minY = Math.min(oldCaretInfo.y, myCaretInfo.y);
    int maxY = Math.max(oldCaretInfo.y + oldCaretInfo.height, myCaretInfo.y + myCaretInfo.height);
    content.repaintEditorComponent(0, minY, updateWidth, maxY - minY);
    gutter.repaint(0, minY, gutter.getWidth(), maxY - minY);
  }
  else {
    content.repaintEditorComponent(0, oldCaretInfo.y, updateWidth, oldCaretInfo.height + lineHeight);
    gutter.repaint(0, oldCaretInfo.y, updateWidth, oldCaretInfo.height + lineHeight);
    content.repaintEditorComponent(0, myCaretInfo.y, updateWidth, myCaretInfo.height + lineHeight);
    gutter.repaint(0, myCaretInfo.y, updateWidth, myCaretInfo.height + lineHeight);
  }
}
项目:intellij-ce-playground    文件:CoverageLineMarkerRenderer.java   
public void paint(Editor editor, Graphics g, Rectangle r) {
  final TextAttributes color = editor.getColorsScheme().getAttributes(myKey);
  Color bgColor = color.getBackgroundColor();
  if (bgColor == null) {
    bgColor = color.getForegroundColor();
  }
  if (editor.getSettings().isLineNumbersShown() || ((EditorGutterComponentEx)editor.getGutter()).isAnnotationsShown()) {
    if (bgColor != null) {
      bgColor = ColorUtil.toAlpha(bgColor, 150);
    }
  }
  if (bgColor != null) {
    g.setColor(bgColor);
  }
  g.fillRect(r.x, r.y, r.width, r.height);
  final LineData lineData = getLineData(editor.xyToLogicalPosition(new Point(0, r.y)).line);
  if (lineData != null && lineData.isCoveredByOneTest()) {
    g.drawImage( ImageLoader.loadFromResource("/gutter/unique.png"), r.x, r.y, 8, 8, editor.getComponent());
  }
}
项目:tools-idea    文件:CaretModelImpl.java   
private void requestRepaint(VerticalInfo oldCaretInfo) {
  int lineHeight = myEditor.getLineHeight();
  Rectangle visibleArea = myEditor.getScrollingModel().getVisibleArea();
  final EditorGutterComponentEx gutter = myEditor.getGutterComponentEx();
  final EditorComponentImpl content = myEditor.getContentComponent();

  int updateWidth = myEditor.getScrollPane().getHorizontalScrollBar().getValue() + visibleArea.width;
  if (Math.abs(myCaretInfo.y - oldCaretInfo.y) <= 2 * lineHeight) {
    int minY = Math.min(oldCaretInfo.y, myCaretInfo.y);
    int maxY = Math.max(oldCaretInfo.y + oldCaretInfo.height, myCaretInfo.y + myCaretInfo.height);
    content.repaintEditorComponent(0, minY, updateWidth, maxY - minY);
    gutter.repaint(0, minY, gutter.getWidth(), maxY - minY);
  }
  else {
    content.repaintEditorComponent(0, oldCaretInfo.y, updateWidth, oldCaretInfo.height + lineHeight);
    gutter.repaint(0, oldCaretInfo.y, updateWidth, oldCaretInfo.height + lineHeight);
    content.repaintEditorComponent(0, myCaretInfo.y, updateWidth, myCaretInfo.height + lineHeight);
    gutter.repaint(0, myCaretInfo.y, updateWidth, myCaretInfo.height + lineHeight);
  }
}
项目:tools-idea    文件:AnnotationPresentation.java   
AnnotationPresentation(@NotNull final HighlightAnnotationsActions highlighting, @Nullable final AnnotationSourceSwitcher switcher,
                              final EditorGutterComponentEx gutter,
                              final List<AnnotationFieldGutter> gutters,
                              final AnAction... actions) {
  myHighlighting = highlighting;
  mySwitcher = switcher;

  myActions = new ArrayList<AnAction>();
  myActions.add(Separator.getInstance());
  if (actions != null) {
    final List<AnAction> actionsList = Arrays.asList(actions);
    if (!actionsList.isEmpty()) {
      myActions.addAll(actionsList);
      myActions.add(new Separator());
    }
  }
  myActions.addAll(myHighlighting.getList());
  if (mySwitcher != null) {
    mySwitchAction = new SwitchAnnotationSourceAction(mySwitcher, gutter);
    myActions.add(mySwitchAction);
  }
}
项目:consulo    文件:DiffLineSeparatorRenderer.java   
@Override
public void paint(Editor editor, Graphics g, Rectangle r) {
  if (!myCondition.get()) return;

  int y = r.y;
  int lineHeight = myEditor.getLineHeight();

  EditorGutterComponentEx gutter = ((EditorEx)editor).getGutterComponentEx();
  int annotationsOffset = gutter.getAnnotationsAreaOffset();
  int annotationsWidth = gutter.getAnnotationsAreaWidth();
  if (annotationsWidth != 0) {
    g.setColor(editor.getColorsScheme().getColor(EditorColors.GUTTER_BACKGROUND));
    g.fillRect(annotationsOffset, y, annotationsWidth, lineHeight);
  }

  draw(g, 0, y, lineHeight, myEditor.getColorsScheme());
}
项目:consulo    文件:CoverageLineMarkerRenderer.java   
public void paint(Editor editor, Graphics g, Rectangle r) {
  final TextAttributes color = editor.getColorsScheme().getAttributes(myKey);
  Color bgColor = color.getBackgroundColor();
  if (bgColor == null) {
    bgColor = color.getForegroundColor();
  }
  if (editor.getSettings().isLineNumbersShown() || ((EditorGutterComponentEx)editor.getGutter()).isAnnotationsShown()) {
    if (bgColor != null) {
      bgColor = ColorUtil.toAlpha(bgColor, 150);
    }
  }
  if (bgColor != null) {
    g.setColor(bgColor);
  }
  g.fillRect(r.x, r.y, r.width, r.height);
  final LineData lineData = getLineData(editor.xyToLogicalPosition(new Point(0, r.y)).line);
  if (lineData != null && lineData.isCoveredByOneTest()) {
    g.drawImage( ImageLoader.loadFromResource("/gutter/unique.png"), r.x, r.y, 8, 8, editor.getComponent());
  }
}
项目:consulo    文件:CaretImpl.java   
private void requestRepaint(VerticalInfo oldCaretInfo) {
  int lineHeight = myEditor.getLineHeight();
  Rectangle visibleArea = myEditor.getScrollingModel().getVisibleArea();
  final EditorGutterComponentEx gutter = myEditor.getGutterComponentEx();
  final EditorComponentImpl content = myEditor.getContentComponent();

  int updateWidth = myEditor.getScrollPane().getHorizontalScrollBar().getValue() + visibleArea.width;
  if (Math.abs(myCaretInfo.y - oldCaretInfo.y) <= 2 * lineHeight) {
    int minY = Math.min(oldCaretInfo.y, myCaretInfo.y);
    int maxY = Math.max(oldCaretInfo.y + oldCaretInfo.height, myCaretInfo.y + myCaretInfo.height);
    content.repaintEditorComponent(0, minY, updateWidth, maxY - minY);
    gutter.repaint(0, minY, gutter.getWidth(), maxY - minY);
  }
  else {
    content.repaintEditorComponent(0, oldCaretInfo.y, updateWidth, oldCaretInfo.height + lineHeight);
    gutter.repaint(0, oldCaretInfo.y, updateWidth, oldCaretInfo.height + lineHeight);
    content.repaintEditorComponent(0, myCaretInfo.y, updateWidth, myCaretInfo.height + lineHeight);
    gutter.repaint(0, myCaretInfo.y, updateWidth, myCaretInfo.height + lineHeight);
  }
}
项目:consulo    文件:AnnotateActionGroup.java   
public AnnotateActionGroup(@Nonnull List<AnnotationFieldGutter> gutters,
                           @Nonnull EditorGutterComponentEx gutterComponent,
                           @Nullable Couple<Map<VcsRevisionNumber, Color>> bgColorMap) {
  super("View", true);
  final List<AnAction> actions = new ArrayList<>();
  for (AnnotationFieldGutter g : gutters) {
    if (g.getID() != null) {
      actions.add(new ShowHideAspectAction(g, gutterComponent));
    }
  }
  actions.add(AnSeparator.getInstance());
  if (bgColorMap != null) {
    actions.add(new ShowAnnotationColorsAction(gutterComponent));
  }
  actions.add(new ShowShortenNames(gutterComponent));
  myActions = actions.toArray(new AnAction[actions.size()]);
}
项目:intellij-ce-playground    文件:OpenInEditorWithMouseAction.java   
public void register(@NotNull List<? extends Editor> editors) {
  myEditors = editors;
  for (Editor editor : editors) {
    if (editor == null) continue;
    registerCustomShortcutSet(getShortcutSet(), (EditorGutterComponentEx)editor.getGutter());
  }
}
项目:intellij-ce-playground    文件:DiffPanelImpl.java   
public void setLineNumberConvertors(@NotNull TIntFunction old, @NotNull TIntFunction newConvertor) {
  if (getEditor1() != null) {
    ((EditorGutterComponentEx) getEditor1().getGutter()).setLineNumberConvertor(old);
  }
  if (getEditor2() != null) {
    ((EditorGutterComponentEx) getEditor2().getGutter()).setLineNumberConvertor(newConvertor);
  }
}
项目:intellij-ce-playground    文件:DiffLineMarkerRenderer.java   
@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);
  }
}
项目:intellij-ce-playground    文件:EditBreakpointActionHandler.java   
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.getPoint(breakpointGutterRenderer);
  if (point == null) return;
  final Icon icon = breakpointGutterRenderer.getIcon();
  Point whereToShow = new Point(point.x + icon.getIconWidth() / 2, point.y + icon.getIconHeight() / 2);
  doShowPopup(project, gutterComponent, whereToShow, breakpoint);
}
项目:intellij-ce-playground    文件:ShowAnnotationColorsAction.java   
public ShowAnnotationColorsAction(EditorGutterComponentEx gutter) {
  super("Colors", true);

  final ArrayList<AnAction> kids = new ArrayList<AnAction>(ShortNameType.values().length);
  for (ColorMode type : ColorMode.values()) {
    kids.add(new SetColorModeAction(type, gutter));
  }
  myChildren = kids.toArray(new AnAction[kids.size()]);
}
项目:intellij-ce-playground    文件:ShowShortenNames.java   
public ShowShortenNames(final EditorGutterComponentEx gutter) {
  super("Names", true);
  final ArrayList<AnAction> kids = new ArrayList<AnAction>(ShortNameType.values().length);
  for (ShortNameType type : ShortNameType.values()) {
    kids.add(new SetShortNameTypeAction(type, gutter));
  }
  myChildren = kids.toArray(new AnAction[kids.size()]);
}
项目:intellij-ce-playground    文件:AnnotateActionGroup.java   
public AnnotateActionGroup(List<AnnotationFieldGutter> gutters, EditorGutterComponentEx gutterComponent) {
  super("View", true);
  final List<AnAction> actions = new ArrayList<AnAction>();
  for (AnnotationFieldGutter g : gutters) {
    if (g.getID() != null) {
      actions.add(new ShowHideAspectAction(g, gutterComponent));
    }
  }
  actions.add(Separator.getInstance());
  actions.add(new ShowAnnotationColorsAction(gutterComponent));
  actions.add(new ShowShortenNames(gutterComponent));
  myActions = actions.toArray(new AnAction[actions.size()]);
}
项目:intellij-ce-playground    文件:CoverageLineMarkerRenderer.java   
public boolean canDoAction(final MouseEvent e) {
  Component component = e.getComponent();
  if (component instanceof EditorGutterComponentEx) {
    EditorGutterComponentEx gutter = (EditorGutterComponentEx)component;
    return e.getX() > gutter.getLineMarkerAreaOffset() && e.getX() < gutter.getIconAreaOffset();
  }
  return false;
}
项目:intellij-ce-playground    文件:CoverageLineMarkerRenderer.java   
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(new Runnable() {
    public void run() {
      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);
    }
  });
}
项目:tools-idea    文件:DiffPanelImpl.java   
public void setLineNumberConvertors(final Convertor<Integer, Integer> old, final Convertor<Integer, Integer> newConvertor) {
  if (getEditor1() != null) {
    ((EditorGutterComponentEx) getEditor1().getGutter()).setLineNumberConvertor(old);
  }
  if (getEditor2() != null) {
    ((EditorGutterComponentEx) getEditor2().getGutter()).setLineNumberConvertor(newConvertor);
  }
}
项目:tools-idea    文件:DiffLineMarkerRenderer.java   
@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);
  }
}
项目:tools-idea    文件:EditBreakpointActionHandler.java   
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.getPoint(breakpointGutterRenderer);
  if (point == null) return;
  final Icon icon = breakpointGutterRenderer.getIcon();
  Point whereToShow = new Point(point.x + icon.getIconWidth() / 2 + gutterComponent.getIconsAreaWidth(), point.y + icon.getIconHeight() / 2);
  doShowPopup(project, gutterComponent, whereToShow, breakpoint);
}
项目:tools-idea    文件:HighlightAnnotationsActions.java   
public HighlightAnnotationsActions(final Project project, final VirtualFile virtualFile, final FileAnnotation fileAnnotation,
                                   final EditorGutterComponentEx gutter) {
  myGutter = gutter;
  myBefore = new HightlightAction(true, project, virtualFile, fileAnnotation, myGutter, null);
  final List<VcsFileRevision> fileRevisionList = fileAnnotation.getRevisions();
  final VcsFileRevision afterSelected = ((fileRevisionList != null) && (fileRevisionList.size() > 1)) ? fileRevisionList.get(0) : null;
  myAfter = new HightlightAction(false, project, virtualFile, fileAnnotation, myGutter, afterSelected);
  myRemove = new RemoveHighlightingAction();
}
项目:tools-idea    文件:HighlightAnnotationsActions.java   
private HightlightAction(final boolean before, final Project project, final VirtualFile virtualFile, final FileAnnotation fileAnnotation,
                         final EditorGutterComponentEx gutter, @Nullable final VcsFileRevision selectedRevision) {
  myBefore = before;
  myProject = project;
  myVirtualFile = virtualFile;
  myFileAnnotation = fileAnnotation;
  myGutter = gutter;
  myShowComments = null;
  mySelectedRevision = selectedRevision;
}
项目:tools-idea    文件:ShowShortenNames.java   
public ShowShortenNames(final EditorGutterComponentEx gutter) {
  super("Names", true);
  final ArrayList<AnAction> kids = new ArrayList<AnAction>(ShortNameType.values().length);
  for (ShortNameType type : ShortNameType.values()) {
    kids.add(new SetShortNameTypeAction(type, gutter));
  }
  myChildren = kids.toArray(new AnAction[kids.size()]);
}
项目:tools-idea    文件:AnnotateActionGroup.java   
public AnnotateActionGroup(List<AnnotationFieldGutter> gutters, EditorGutterComponentEx gutterComponent) {
  super("View", true);
  final List<AnAction> actions = new ArrayList<AnAction>();
  for (AnnotationFieldGutter g : gutters) {
    if (g.getID() != null) {
      actions.add(new ShowHideAspectAction(g, gutterComponent));
    }
  }
  actions.add(Separator.getInstance());
  actions.add(new ShowAnnotationColorsAction(gutters, gutterComponent));
  actions.add(new ShowShortenNames(gutterComponent));
  myActions = actions.toArray(new AnAction[actions.size()]);
}
项目:tools-idea    文件:GotoDeclarationAction.java   
@Override
public void update(final AnActionEvent event) {
  final InputEvent inputEvent = event.getInputEvent();
  if (inputEvent instanceof MouseEvent) {
    final MouseEvent mouseEvent = (MouseEvent)inputEvent;
    final Point point = mouseEvent.getPoint();
    final Component componentAt = SwingUtilities.getDeepestComponentAt(inputEvent.getComponent(), point.x, point.y);
    if (componentAt instanceof EditorGutterComponentEx) {
      event.getPresentation().setEnabled(false);
      return;
    }
  }

  for (GotoDeclarationHandler handler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) {
    try {
      final String text = handler.getActionText(event.getDataContext());

      if (text != null) {
        Presentation presentation = event.getPresentation();
        presentation.setText(text);
        break;
      }
    }
    catch (AbstractMethodError e) {
      LOG.error(handler.toString(), e);
    }
  }

  super.update(event);
}
项目:ali-idea-plugin    文件:DevMotiveAnnotationGutter.java   
public DevMotiveAnnotationGutter(Project project, FileAnnotation annotation, List<VcsFileRevision> revisions, EditorGutter editorGutter) {
    this.annotation = annotation;

    devMotivePanel = AliContentFactory.addDevMotiveContent(project, annotation.getFile(), revisions, annotation.getVcsKey().getName(), this, true);
    devMotivePanel.addChangeListener(this);

    if (editorGutter instanceof EditorGutterComponentEx) {
        editorGutterComponentEx = (EditorGutterComponentEx) editorGutter;
        unknownLine = "???";
    } else {
        // unable to resize, make sure to reserve enough room
        unknownLine = "??????????";
    }
}
项目:consulo    文件:DiffDrawUtil.java   
@Nonnull
private static LineMarkerRenderer createFoldingGutterLineRenderer(@Nonnull final TextDiffType type,
                                                                  @Nonnull final SeparatorPlacement placement,
                                                                  final boolean doubleLine,
                                                                  final boolean resolved) {
  return new LineMarkerRendererEx() {
    @Override
    public void paint(Editor editor, Graphics g, Rectangle r) {
      EditorGutterComponentEx gutter = ((EditorEx)editor).getGutterComponentEx();
      Graphics2D g2 = (Graphics2D)g;

      int x1 = gutter.getWhitespaceSeparatorOffset();
      int x2 = gutter.getWidth();

      int y = r.y;
      if (placement == SeparatorPlacement.BOTTOM) y += editor.getLineHeight();

      drawChunkBorderLine(g2, x1, x2, y - 1, type.getColor(editor), doubleLine, resolved);
    }

    @Nonnull
    @Override
    public Position getPosition() {
      return Position.CUSTOM;
    }
  };
}
项目:consulo    文件:DiffLineMarkerRenderer.java   
@Override
public void paint(Editor editor, Graphics g, Rectangle range) {
  EditorGutterComponentEx gutter = ((EditorEx)editor).getGutterComponentEx();
  Graphics2D g2 = (Graphics2D)g;
  int x1 = 0;
  int x2 = x1 + gutter.getWidth();

  int y1, y2;
  if (myEmptyRange && myLastLine) {
    y1 = DiffDrawUtil.lineToY(editor, DiffUtil.getLineCount(editor.getDocument()));
    y2 = y1;
  }
  else {
    int startLine = editor.getDocument().getLineNumber(myHighlighter.getStartOffset());
    int endLine = editor.getDocument().getLineNumber(myHighlighter.getEndOffset()) + 1;
    y1 = DiffDrawUtil.lineToY(editor, startLine);
    y2 = myEmptyRange ? y1 : DiffDrawUtil.lineToY(editor, endLine);
  }

  if (myHideWithoutLineNumbers && !editor.getSettings().isLineNumbersShown()) {
    x1 = gutter.getWhitespaceSeparatorOffset();
  }
  else {
    int annotationsOffset = gutter.getAnnotationsAreaOffset();
    int annotationsWidth = gutter.getAnnotationsAreaWidth();
    if (annotationsWidth != 0) {
      drawMarker(editor, g2, x1, annotationsOffset, y1, y2, false);
      x1 = annotationsOffset + annotationsWidth;
    }
  }

  if (myIgnoredFoldingOutline) {
    int xOutline = gutter.getWhitespaceSeparatorOffset();
    drawMarker(editor, g2, xOutline, x2, y1, y2, true);
    drawMarker(editor, g2, x1, xOutline, y1, y2, false);
  }
  else {
    drawMarker(editor, g2, x1, x2, y1, y2, false);
  }
}
项目:consulo    文件:CoverageLineMarkerRenderer.java   
public boolean canDoAction(final MouseEvent e) {
  Component component = e.getComponent();
  if (component instanceof EditorGutterComponentEx) {
    EditorGutterComponentEx gutter = (EditorGutterComponentEx)component;
    return e.getX() > gutter.getLineMarkerAreaOffset() && e.getX() < gutter.getIconAreaOffset();
  }
  return false;
}
项目:consulo    文件:CoverageLineMarkerRenderer.java   
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(new Runnable() {
    public void run() {
      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);
    }
  });
}
项目:consulo    文件:IdeBackgroundUtil.java   
private static String getComponentType(JComponent component) {
  return component instanceof JTree ? "tree" :
         component instanceof JList ? "list" :
         component instanceof JTable ? "table" :
         component instanceof JViewport ? "viewport" :
         component instanceof ActionToolbar ? "toolbar" :
         component instanceof EditorComponentImpl ? "editor" :
         component instanceof EditorGutterComponentEx ? "editor" :
         component instanceof JBLoadingPanel ? "loading" :
         component instanceof JBTabs ? "tabs" :
         component instanceof JBPanelWithEmptyText ? "panel" :
         component instanceof JPanel && ourKnownNames.contains(component.getName()) ? component.getName() :
         null;
}
项目:consulo    文件:DiffPanelImpl.java   
public void setLineNumberConvertors(@Nonnull TIntFunction old, @Nonnull TIntFunction newConvertor) {
  if (getEditor1() != null) {
    ((EditorGutterComponentEx)getEditor1().getGutter()).setLineNumberConvertor(old);
  }
  if (getEditor2() != null) {
    ((EditorGutterComponentEx)getEditor2().getGutter()).setLineNumberConvertor(newConvertor);
  }
}
项目:consulo    文件:DiffLineMarkerRenderer.java   
@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);
  }
}
项目:consulo    文件:EditBreakpointActionHandler.java   
public void editBreakpoint(@Nonnull Project project, @Nonnull Editor editor, @Nonnull Object breakpoint, @Nonnull 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);
  }
}
项目:consulo    文件:HighlightAnnotationsActions.java   
public HighlightAnnotationsActions(final Project project, final VirtualFile virtualFile, final FileAnnotation fileAnnotation,
                                   final EditorGutterComponentEx gutter) {
  myGutter = gutter;
  myBefore = new HightlightAction(true, project, virtualFile, fileAnnotation, myGutter, null);
  final List<VcsFileRevision> fileRevisionList = fileAnnotation.getRevisions();
  final VcsFileRevision afterSelected = ((fileRevisionList != null) && (fileRevisionList.size() > 1)) ? fileRevisionList.get(0) : null;
  myAfter = new HightlightAction(false, project, virtualFile, fileAnnotation, myGutter, afterSelected);
  myRemove = new RemoveHighlightingAction();
}
项目:consulo    文件:HighlightAnnotationsActions.java   
private HightlightAction(final boolean before, final Project project, final VirtualFile virtualFile, final FileAnnotation fileAnnotation,
                         final EditorGutterComponentEx gutter, @Nullable final VcsFileRevision selectedRevision) {
  myBefore = before;
  myProject = project;
  myVirtualFile = virtualFile;
  myFileAnnotation = fileAnnotation;
  myGutter = gutter;
  myShowComments = null;
  mySelectedRevision = selectedRevision;
}
项目:consulo    文件:LineStatusMarkerRenderer.java   
@Nonnull
public static Rectangle getMarkerArea(@Nonnull Editor editor, @Nonnull Rectangle r, int line1, int line2) {
  EditorGutterComponentEx gutter = ((EditorEx)editor).getGutterComponentEx();
  int x = r.x + JBUI.scale(1); // leave 1px for brace highlighters
  int endX = gutter.getWhitespaceSeparatorOffset();
  int y = lineToY(editor, line1);
  int endY = lineToY(editor, line2);
  return new Rectangle(x, y, endX - x, endY - y);
}
项目:consulo    文件:ShowAnnotationColorsAction.java   
public ShowAnnotationColorsAction(EditorGutterComponentEx gutter) {
  super("Colors", true);

  final ArrayList<AnAction> kids = new ArrayList<AnAction>(ShortNameType.values().length);
  for (ColorMode type : ColorMode.values()) {
    kids.add(new SetColorModeAction(type, gutter));
  }
  myChildren = kids.toArray(new AnAction[kids.size()]);
}