Java Code Examples for com.intellij.openapi.editor.markup.RangeHighlighter#setLineMarkerRenderer()

The following examples show how to use com.intellij.openapi.editor.markup.RangeHighlighter#setLineMarkerRenderer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnifiedEditorRangeHighlighter.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void apply(@javax.annotation.Nullable Project project, @Nonnull Document document) {
  MarkupModel model = DocumentMarkupModel.forDocument(document, project, true);

  for (Element piece : myPieces) {
    RangeHighlighterEx delegate = piece.getDelegate();
    if (!delegate.isValid()) continue;

    RangeHighlighter highlighter = model
            .addRangeHighlighter(piece.getStart(), piece.getEnd(), delegate.getLayer(), delegate.getTextAttributes(), delegate.getTargetArea());
    highlighter.setEditorFilter(delegate.getEditorFilter());
    highlighter.setCustomRenderer(delegate.getCustomRenderer());
    highlighter.setErrorStripeMarkColor(delegate.getErrorStripeMarkColor());
    highlighter.setErrorStripeTooltip(delegate.getErrorStripeTooltip());
    highlighter.setGutterIconRenderer(delegate.getGutterIconRenderer());
    highlighter.setLineMarkerRenderer(delegate.getLineMarkerRenderer());
    highlighter.setLineSeparatorColor(delegate.getLineSeparatorColor());
    highlighter.setThinErrorStripeMark(delegate.isThinErrorStripeMark());
    highlighter.setLineSeparatorPlacement(delegate.getLineSeparatorPlacement());
    highlighter.setLineSeparatorRenderer(delegate.getLineSeparatorRenderer());
  }
}
 
Example 2
Source File: ApplyPatchChange.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void createStatusHighlighter() {
  int line1 = myPatchDeletionRange.start;
  int line2 = myPatchInsertionRange.end;

  Color color = getStatusColor();
  if (isResolved()) {
    color = ColorUtil.mix(color, myViewer.getPatchEditor().getGutterComponentEx().getBackground(), 0.6f);
  }

  String tooltip = getStatusText();

  EditorEx patchEditor = myViewer.getPatchEditor();
  Document document = patchEditor.getDocument();
  MarkupModelEx markupModel = patchEditor.getMarkupModel();
  TextRange textRange = DiffUtil.getLinesRange(document, line1, line2);

  RangeHighlighter highlighter = markupModel.addRangeHighlighter(textRange.getStartOffset(), textRange.getEndOffset(),
                                                                 HighlighterLayer.LAST, null, HighlighterTargetArea.LINES_IN_RANGE);

  PairConsumer<Editor, MouseEvent> clickHandler = getResultRange() != null ?
                                                  (e, event) -> myViewer.scrollToChange(this, Side.RIGHT, false) :
                                                  null;
  highlighter.setLineMarkerRenderer(LineStatusMarkerRenderer.createRenderer(line1, line2, color, tooltip, clickHandler));

  myHighlighters.add(highlighter);
}
 
Example 3
Source File: LineStatusTracker.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@RequiredUIAccess
protected void createHighlighter(@Nonnull Range range) {
  myApplication.assertIsDispatchThread();

  if (range.getHighlighter() != null) {
    LOG.error("Multiple highlighters registered for the same Range");
    return;
  }

  if (myMode == Mode.SILENT) return;

  int first =
          range.getLine1() >= getLineCount(myDocument) ? myDocument.getTextLength() : myDocument.getLineStartOffset(range.getLine1());
  int second =
          range.getLine2() >= getLineCount(myDocument) ? myDocument.getTextLength() : myDocument.getLineStartOffset(range.getLine2());

  MarkupModel markupModel = DocumentMarkupModel.forDocument(myDocument, myProject, true);

  RangeHighlighter highlighter = LineStatusMarkerRenderer.createRangeHighlighter(range, new TextRange(first, second), markupModel);
  highlighter.setLineMarkerRenderer(LineStatusMarkerRenderer.createRenderer(range, (editor) -> {
    return new LineStatusTrackerDrawing.MyLineStatusMarkerPopup(this, editor, range);
  }));

  highlighter.setEditorFilter(MarkupEditorFilterFactory.createIsNotDiffFilter());

  range.setHighlighter(highlighter);
}