本文整理汇总了Java中com.intellij.ui.speedSearch.SpeedSearchUtil.appendColoredFragments方法的典型用法代码示例。如果您正苦于以下问题:Java SpeedSearchUtil.appendColoredFragments方法的具体用法?Java SpeedSearchUtil.appendColoredFragments怎么用?Java SpeedSearchUtil.appendColoredFragments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.ui.speedSearch.SpeedSearchUtil
的用法示例。
在下文中一共展示了SpeedSearchUtil.appendColoredFragments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderItemName
import com.intellij.ui.speedSearch.SpeedSearchUtil; //导入方法依赖的package包/类
private void renderItemName(LookupElement item,
Color foreground,
boolean selected,
@SimpleTextAttributes.StyleAttributeConstant int style,
String name,
final SimpleColoredComponent nameComponent) {
final SimpleTextAttributes base = new SimpleTextAttributes(style, foreground);
final String prefix = item instanceof EmptyLookupItem ? "" : myLookup.itemPattern(item);
if (prefix.length() > 0) {
Iterable<TextRange> ranges = getMatchingFragments(prefix, name);
if (ranges != null) {
SimpleTextAttributes highlighted =
new SimpleTextAttributes(style, selected ? SELECTED_PREFIX_FOREGROUND_COLOR : PREFIX_FOREGROUND_COLOR);
SpeedSearchUtil.appendColoredFragments(nameComponent, name, ranges, base, highlighted);
return;
}
}
nameComponent.append(name, base);
}
示例2: appendWithColoredMatches
import com.intellij.ui.speedSearch.SpeedSearchUtil; //导入方法依赖的package包/类
private static void appendWithColoredMatches(SimpleColoredComponent nameComponent,
String name,
String pattern,
Color fg,
boolean selected) {
SimpleTextAttributes plain = new SimpleTextAttributes(STYLE_PLAIN, fg);
SimpleTextAttributes highlighted = new SimpleTextAttributes(null, fg, null, STYLE_SEARCH_MATCH);
List<TextRange> fragments = ContainerUtil.newArrayList();
if (selected) {
int matchStart = StringUtil.indexOfIgnoreCase(name, pattern, 0);
if (matchStart >= 0) {
fragments.add(TextRange.from(matchStart, pattern.length()));
}
}
SpeedSearchUtil.appendColoredFragments(nameComponent, name, fragments, plain, highlighted);
}
示例3: renderItemName
import com.intellij.ui.speedSearch.SpeedSearchUtil; //导入方法依赖的package包/类
private void renderItemName(LookupElement item,
Color foreground,
boolean selected,
@SimpleTextAttributes.StyleAttributeConstant int style,
String name,
final SimpleColoredComponent nameComponent) {
final SimpleTextAttributes base = new SimpleTextAttributes(style, foreground);
final String prefix = item instanceof EmptyLookupItem ? "" : myLookup.itemPattern(item);
if (prefix.length() > 0) {
Iterable<TextRange> ranges = getMatchingFragments(prefix, name);
if (ranges != null) {
SimpleTextAttributes highlighted =
new SimpleTextAttributes(style, selected ? SELECTED_PREFIX_FOREGROUND_COLOR : PREFIX_FOREGROUND_COLOR);
SpeedSearchUtil.appendColoredFragments(nameComponent, name, ranges, base, highlighted);
return;
}
}
nameComponent.append(name, base);
}
示例4: addText
import com.intellij.ui.speedSearch.SpeedSearchUtil; //导入方法依赖的package包/类
@Override
protected void addText(@NotNull Object value, boolean isSelected, int row)
{
String presentation = ((ReferenceType) value).name();
append(" ");
if(isSelected)
{
FList<TextRange> textRanges = myMatcher.matchingFragments(presentation);
if(textRanges != null)
{
SimpleTextAttributes attributes = new SimpleTextAttributes(getBackground(), getForeground(), null, SimpleTextAttributes.STYLE_SEARCH_MATCH);
SpeedSearchUtil.appendColoredFragments(this, presentation, textRanges, SimpleTextAttributes.REGULAR_ATTRIBUTES, attributes);
}
}
else
{
append(String.format("%s", presentation), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
}