本文整理汇总了Java中com.intellij.openapi.editor.markup.RangeHighlighter.putUserData方法的典型用法代码示例。如果您正苦于以下问题:Java RangeHighlighter.putUserData方法的具体用法?Java RangeHighlighter.putUserData怎么用?Java RangeHighlighter.putUserData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.editor.markup.RangeHighlighter
的用法示例。
在下文中一共展示了RangeHighlighter.putUserData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: linkFollowed
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
private static void linkFollowed(Editor editor, Collection<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, HYPERLINK_LAYER, getHyperlinkAttributes(), HighlighterTargetArea.EXACT_RANGE).dispose();
}
示例2: associateHyperlink
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
private static void associateHyperlink(@NotNull RangeHighlighter highlighter,
@NotNull HyperlinkInfo hyperlinkInfo,
@Nullable TextAttributes followedHyperlinkAttributes) {
highlighter.putUserData(HYPERLINK, new HyperlinkInfoTextAttributes(hyperlinkInfo, followedHyperlinkAttributes));
}
示例3: updateInSelectionHighlighters
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
private void updateInSelectionHighlighters() {
if (mySearchResults.getEditor() == null) return;
final SelectionModel selectionModel = mySearchResults.getEditor().getSelectionModel();
int[] starts = selectionModel.getBlockSelectionStarts();
int[] ends = selectionModel.getBlockSelectionEnds();
final HashSet<RangeHighlighter> toRemove = new HashSet<RangeHighlighter>();
Set<RangeHighlighter> toAdd = new HashSet<RangeHighlighter>();
for (RangeHighlighter highlighter : myHighlighters) {
if (!highlighter.isValid()) continue;
boolean intersectsWithSelection = false;
for (int i = 0; i < starts.length; ++i) {
TextRange selectionRange = new TextRange(starts[i], ends[i]);
intersectsWithSelection = selectionRange.intersects(highlighter.getStartOffset(), highlighter.getEndOffset()) &&
selectionRange.getEndOffset() != highlighter.getStartOffset() &&
highlighter.getEndOffset() != selectionRange.getStartOffset();
if (intersectsWithSelection) break;
}
final Object userData = highlighter.getUserData(IN_SELECTION_KEY);
if (userData != null) {
if (!intersectsWithSelection) {
if (userData == IN_SELECTION2) {
HighlightManager.getInstance(mySearchResults.getProject()).removeSegmentHighlighter(mySearchResults.getEditor(), highlighter);
toRemove.add(highlighter);
} else {
highlighter.putUserData(IN_SELECTION_KEY, null);
}
}
} else if (intersectsWithSelection) {
TextRange cursor = mySearchResults.getCursor();
if (cursor != null && highlighter.getStartOffset() == cursor.getStartOffset() &&
highlighter.getEndOffset() == cursor.getEndOffset()) continue;
final RangeHighlighter toAnnotate = highlightRange(new TextRange(highlighter.getStartOffset(), highlighter.getEndOffset()),
new TextAttributes(null, null, Color.WHITE, EffectType.ROUNDED_BOX, 0), toAdd);
highlighter.putUserData(IN_SELECTION_KEY, IN_SELECTION1);
toAnnotate.putUserData(IN_SELECTION_KEY, IN_SELECTION2);
}
}
myHighlighters.removeAll(toRemove);
myHighlighters.addAll(toAdd);
}
示例4: doHightlightRange
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
private RangeHighlighter doHightlightRange(final TextRange textRange, final TextAttributes attributes, Set<RangeHighlighter> highlighters) {
HighlightManager highlightManager = HighlightManager.getInstance(mySearchResults.getProject());
MarkupModelEx markupModel = (MarkupModelEx)mySearchResults.getEditor().getMarkupModel();
final RangeHighlighter[] candidate = new RangeHighlighter[1];
boolean notFound = markupModel.processRangeHighlightersOverlappingWith(
textRange.getStartOffset(), textRange.getEndOffset(),
new Processor<RangeHighlighterEx>() {
@Override
public boolean process(RangeHighlighterEx highlighter) {
if (!highlighter.getEditorFilter().avaliableIn(mySearchResults.getEditor())) return true;
TextAttributes textAttributes =
highlighter.getTextAttributes();
if (highlighter.getUserData(SEARCH_MARKER) != null &&
textAttributes != null &&
textAttributes.equals(attributes) &&
highlighter.getStartOffset() == textRange.getStartOffset() &&
highlighter.getEndOffset() == textRange.getEndOffset()) {
candidate[0] = highlighter;
return false;
}
return true;
}
});
if (!notFound && highlighters.contains(candidate[0])) {
return candidate[0];
}
final ArrayList<RangeHighlighter> dummy = new ArrayList<RangeHighlighter>();
highlightManager.addRangeHighlight(mySearchResults.getEditor(),
textRange.getStartOffset(),
textRange.getEndOffset(),
attributes,
false,
dummy);
final RangeHighlighter h = dummy.get(0);
highlighters.add(h);
h.putUserData(SEARCH_MARKER, YES);
return h;
}