Java Code Examples for com.intellij.openapi.editor.markup.RangeHighlighter#getUserData()
The following examples show how to use
com.intellij.openapi.editor.markup.RangeHighlighter#getUserData() .
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: EditorHyperlinkSupport.java From consulo with Apache License 2.0 | 6 votes |
private static void linkFollowed(Editor editor, Collection<? extends RangeHighlighter> ranges, final RangeHighlighter link) { MarkupModelEx markupModel = (MarkupModelEx)editor.getMarkupModel(); for (RangeHighlighter range : ranges) { TextAttributes oldAttr = range.getUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES); if (oldAttr != null) { markupModel.setRangeHighlighterAttributes(range, oldAttr); range.putUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES, null); } if (range == link) { range.putUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES, range.getTextAttributes()); markupModel.setRangeHighlighterAttributes(range, getFollowedHyperlinkAttributes(range)); } } //refresh highlighter text attributes markupModel.addRangeHighlighter(0, 0, link.getLayer(), getHyperlinkAttributes(), HighlighterTargetArea.EXACT_RANGE).dispose(); }
Example 2
Source File: MyActionUtils.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static DecisionEventInfo getHighlighterWithDecisionEventType(List<RangeHighlighter> highlighters, Class decisionEventType) { for (RangeHighlighter r : highlighters) { DecisionEventInfo eventInfo = r.getUserData(ProfilerPanel.DECISION_EVENT_INFO_KEY); if (eventInfo != null) { if (eventInfo.getClass() == decisionEventType) { return eventInfo; } } } return null; }
Example 3
Source File: BreakpointItem.java From consulo with Apache License 2.0 | 5 votes |
protected static void showInEditor(DetailView panel, VirtualFile virtualFile, int line) { TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES); DetailView.PreviewEditorState state = DetailView.PreviewEditorState.create(virtualFile, line, attributes); if (state.equals(panel.getEditorState())) { return; } panel.navigateInPreviewEditor(state); TextAttributes softerAttributes = attributes.clone(); Color backgroundColor = softerAttributes.getBackgroundColor(); if (backgroundColor != null) { softerAttributes.setBackgroundColor(ColorUtil.softer(backgroundColor)); } final Editor editor = panel.getEditor(); final MarkupModel editorModel = editor.getMarkupModel(); final MarkupModel documentModel = DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false); for (RangeHighlighter highlighter : documentModel.getAllHighlighters()) { if (highlighter.getUserData(DebuggerColors.BREAKPOINT_HIGHLIGHTER_KEY) == Boolean.TRUE) { final int line1 = editor.offsetToLogicalPosition(highlighter.getStartOffset()).line; if (line1 != line) { editorModel.addLineHighlighter(line1, DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER + 1, softerAttributes); } } } }
Example 4
Source File: LivePreview.java From consulo with Apache License 2.0 | 5 votes |
private void removeHighlighterWithDependent(@Nonnull RangeHighlighter highlighter) { removeHighlighter(highlighter); RangeHighlighter additionalHighlighter = highlighter.getUserData(IN_SELECTION_KEY); if (additionalHighlighter != null) { removeHighlighter(additionalHighlighter); } }
Example 5
Source File: LivePreview.java From consulo with Apache License 2.0 | 5 votes |
private void updateInSelectionHighlighters() { final SelectionModel selectionModel = mySearchResults.getEditor().getSelectionModel(); int[] starts = selectionModel.getBlockSelectionStarts(); int[] ends = selectionModel.getBlockSelectionEnds(); for (RangeHighlighter highlighter : myHighlighters) { if (!highlighter.isValid()) continue; boolean needsAdditionalHighlighting = false; TextRange cursor = mySearchResults.getCursor(); if (cursor == null || highlighter.getStartOffset() != cursor.getStartOffset() || highlighter.getEndOffset() != cursor.getEndOffset()) { for (int i = 0; i < starts.length; ++i) { TextRange selectionRange = new TextRange(starts[i], ends[i]); needsAdditionalHighlighting = selectionRange.intersects(highlighter.getStartOffset(), highlighter.getEndOffset()) && selectionRange.getEndOffset() != highlighter.getStartOffset() && highlighter.getEndOffset() != selectionRange.getStartOffset(); if (needsAdditionalHighlighting) break; } } RangeHighlighter inSelectionHighlighter = highlighter.getUserData(IN_SELECTION_KEY); if (inSelectionHighlighter != null) { if (!needsAdditionalHighlighting) { removeHighlighter(inSelectionHighlighter); } } else if (needsAdditionalHighlighting) { RangeHighlighter additionalHighlighter = addHighlighter(highlighter.getStartOffset(), highlighter.getEndOffset(), new TextAttributes(null, null, Color.WHITE, EffectType.ROUNDED_BOX, Font.PLAIN)); highlighter.putUserData(IN_SELECTION_KEY, additionalHighlighter); } } }
Example 6
Source File: EditorHyperlinkSupport.java From consulo with Apache License 2.0 | 4 votes |
@Nullable public static HyperlinkInfo getHyperlinkInfo(@Nonnull RangeHighlighter range) { final HyperlinkInfoTextAttributes attributes = range.getUserData(HYPERLINK); return attributes != null ? attributes.getHyperlinkInfo() : null; }
Example 7
Source File: LineMarkersUtil.java From consulo with Apache License 2.0 | 4 votes |
private static LineMarkerInfo<?> getLineMarkerInfo(@Nonnull RangeHighlighter highlighter) { return highlighter.getUserData(LINE_MARKER_INFO); }