本文整理汇总了Java中com.intellij.openapi.editor.markup.EffectType类的典型用法代码示例。如果您正苦于以下问题:Java EffectType类的具体用法?Java EffectType怎么用?Java EffectType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EffectType类属于com.intellij.openapi.editor.markup包,在下文中一共展示了EffectType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testScopeBased
import com.intellij.openapi.editor.markup.EffectType; //导入依赖的package包/类
public void testScopeBased() throws Exception {
NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_SOURCE, null));
NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
NamedScopeManager scopeManager = NamedScopeManager.getInstance(getProject());
scopeManager.addScope(xScope);
scopeManager.addScope(utilScope);
EditorColorsManager manager = EditorColorsManager.getInstance();
EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
manager.addColorsScheme(scheme);
EditorColorsManager.getInstance().setGlobalScheme(scheme);
TextAttributesKey xKey = ScopeAttributesUtil.getScopeTextAttributeKey(xScope.getName());
TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, EffectType.BOXED, Font.ITALIC);
scheme.setAttributes(xKey, xAttributes);
TextAttributesKey utilKey = ScopeAttributesUtil.getScopeTextAttributeKey(utilScope.getName());
TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD);
scheme.setAttributes(utilKey, utilAttributes);
try {
testFile(BASE_PATH + "/scopeBased/x/X.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test();
}
finally {
scopeManager.removeAllSets();
}
}
示例2: customizeCellRenderer
import com.intellij.openapi.editor.markup.EffectType; //导入依赖的package包/类
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof FileInfo) {
Project project = mySwitcherPanel.project;
VirtualFile virtualFile = ((FileInfo)value).getFirst();
String renderedName = ((FileInfo)value).getNameForRendering();
setIcon(IconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, project));
FileStatus fileStatus = FileStatusManager.getInstance(project).getStatus(virtualFile);
open = FileEditorManager.getInstance(project).isFileOpen(virtualFile);
TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null, null, EffectType.LINE_UNDERSCORE, Font.PLAIN);
append(renderedName, SimpleTextAttributes.fromTextAttributes(attributes));
// calc color the same way editor tabs do this, i.e. including EPs
Color color = EditorTabbedContainer.calcTabColor(project, virtualFile);
if (!selected && color != null) {
setBackground(color);
}
SpeedSearchUtil.applySpeedSearchHighlighting(mySwitcherPanel, this, false, selected);
}
}
示例3: testEffectType
import com.intellij.openapi.editor.markup.EffectType; //导入依赖的package包/类
public void testEffectType() throws Exception {
assertEquals(EffectType.BOXED, readEffectType(null));
assertEquals(EffectType.BOXED, readEffectType(""));
assertEquals(EffectType.BOXED, readEffectType("WRONG"));
assertEquals(EffectType.BOXED, readEffectType("0"));
assertEquals(EffectType.BOXED, readEffectType("BORDER"));
assertEquals(EffectType.LINE_UNDERSCORE, readEffectType("1"));
assertEquals(EffectType.LINE_UNDERSCORE, readEffectType("LINE"));
assertEquals(EffectType.WAVE_UNDERSCORE, readEffectType("2"));
assertEquals(EffectType.WAVE_UNDERSCORE, readEffectType("WAVE"));
assertEquals(EffectType.STRIKEOUT, readEffectType("3"));
assertEquals(EffectType.STRIKEOUT, readEffectType("STRIKEOUT"));
assertEquals(EffectType.BOLD_LINE_UNDERSCORE, readEffectType("4"));
assertEquals(EffectType.BOLD_LINE_UNDERSCORE, readEffectType("BOLD_LINE"));
assertEquals(EffectType.BOLD_DOTTED_LINE, readEffectType("5"));
assertEquals(EffectType.BOLD_DOTTED_LINE, readEffectType("BOLD_DOTTED_LINE"));
assertEquals(EffectType.BOXED, readEffectType("6"));
}
示例4: updateCursorHighlighting
import com.intellij.openapi.editor.markup.EffectType; //导入依赖的package包/类
private void updateCursorHighlighting() {
hideBalloon();
if (myCursorHighlighter != null) {
HighlightManager.getInstance(mySearchResults.getProject()).removeSegmentHighlighter(mySearchResults.getEditor(), myCursorHighlighter);
myCursorHighlighter = null;
}
final FindResult cursor = mySearchResults.getCursor();
Editor editor = mySearchResults.getEditor();
if (cursor != null && cursor.getEndOffset() <= editor.getDocument().getTextLength()) {
Set<RangeHighlighter> dummy = new HashSet<RangeHighlighter>();
Color color = editor.getColorsScheme().getColor(EditorColors.CARET_COLOR);
highlightRange(cursor, new TextAttributes(null, null, color, EffectType.ROUNDED_BOX, 0), dummy);
if (!dummy.isEmpty()) {
myCursorHighlighter = dummy.iterator().next();
}
editor.getScrollingModel().runActionOnScrollingFinished(new Runnable() {
@Override
public void run() {
showReplacementPreview();
}
});
}
}
示例5: highlightUsages
import com.intellij.openapi.editor.markup.EffectType; //导入依赖的package包/类
private void highlightUsages() {
if (mySearchResults.getEditor() == null) return;
if (mySearchResults.getMatchesCount() >= mySearchResults.getMatchesLimit())
return;
for (FindResult range : mySearchResults.getOccurrences()) {
if (range.getEndOffset() > mySearchResults.getEditor().getDocument().getTextLength()) continue;
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);
if (range.getLength() == 0) {
attributes = attributes.clone();
attributes.setEffectType(EffectType.BOXED);
attributes.setEffectColor(attributes.getBackgroundColor());
}
if (mySearchResults.isExcluded(range)) {
highlightRange(range, strikeout(), myHighlighters);
} else {
highlightRange(range, attributes, myHighlighters);
}
}
updateInSelectionHighlighters();
if (!myListeningSelection) {
mySearchResults.getEditor().getSelectionModel().addSelectionListener(this);
myListeningSelection = true;
}
}
示例6: getTextAttributesKeyForStyle
import com.intellij.openapi.editor.markup.EffectType; //导入依赖的package包/类
/**
* Gets the text attributes for the specified style.
*
* @param style The style.
* @return The text attributes.
*/
private TextAttributesKey[] getTextAttributesKeyForStyle(final IStyle style) {
@Nullable TextAttributesKey[] attributes = this.styleMap.getOrDefault(style, null);
if (attributes == null) {
final String name = "STYLE_" + style.hashCode();
@SuppressWarnings("deprecation") final TextAttributesKey attribute = createTextAttributesKey(
name,
new TextAttributes(
style.color(),
style.backgroundColor(),
null,
(style.underscore() ? EffectType.LINE_UNDERSCORE : null),
(style.bold() ? Font.BOLD : Font.PLAIN)
+ (style.italic() ? Font.ITALIC : Font.PLAIN)
)
);
attributes = new TextAttributesKey[]{attribute};
this.styleMap.put(style, attributes);
}
return attributes;
}
示例7: syntaxError
import com.intellij.openapi.editor.markup.EffectType; //导入依赖的package包/类
protected void syntaxError(String annotation, Token offendingToken) {
// Annotation annot = new Annotation(20, 30, HighlightSeverity.ERROR, "Test!", "Test Message!");
// HighlightInfo info = HighlightInfo.fromAnnotation(annot);
// List<HighlightInfo> al = new ArrayList<HighlightInfo>();
// al.add(info);
// UpdateHighlightersUtil.setHighlightersToEditor(project, doc, 20, 30, al, null, 0)
final TextAttributes attr = new TextAttributes();
attr.setForegroundColor(JBColor.RED);
attr.setEffectColor(JBColor.RED);
attr.setEffectType(EffectType.WAVE_UNDERSCORE);
MarkupModel markupModel = editor.getMarkupModel();
RangeHighlighter h =
markupModel.addRangeHighlighter(startIndex+offendingToken.getStartIndex(),
startIndex+offendingToken.getStopIndex()+1,
HighlighterLayer.ERROR, // layer
attr,
HighlighterTargetArea.EXACT_RANGE);
h.putUserData(SYNTAX_HIGHLIGHTING_TAG, offendingToken); // store any non-null value to tag it
}
示例8: testScopeBased
import com.intellij.openapi.editor.markup.EffectType; //导入依赖的package包/类
public void testScopeBased() throws Exception {
NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_SOURCE, null));
NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
NamedScopeManager scopeManager = NamedScopeManager.getInstance(getProject());
scopeManager.addScope(xScope);
scopeManager.addScope(utilScope);
EditorColorsManager manager = EditorColorsManager.getInstance();
EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
manager.addColorsScheme(scheme);
EditorColorsManager.getInstance().setGlobalScheme(scheme);
TextAttributesKey xKey = ColorAndFontOptions.getScopeTextAttributeKey(xScope.getName());
TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, EffectType.BOXED, Font.ITALIC);
scheme.setAttributes(xKey, xAttributes);
TextAttributesKey utilKey = ColorAndFontOptions.getScopeTextAttributeKey(utilScope.getName());
TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD);
scheme.setAttributes(utilKey, utilAttributes);
try {
testFile(BASE_PATH + "/scopeBased/x/X.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test();
}
finally {
scopeManager.removeAllSets();
}
}
示例9: paintBorder
import com.intellij.openapi.editor.markup.EffectType; //导入依赖的package包/类
private static void paintBorder(Graphics g, EditorImpl editor, int startOffset, int endOffset, EffectType effectType) {
Point startPoint = offsetToXY(editor, startOffset);
Point endPoint = offsetToXY(editor, endOffset);
int height = endPoint.y - startPoint.y;
int startX = startPoint.x;
int startY = startPoint.y;
int endX = endPoint.x;
if (height == 0) {
int width = endX == startX ? 1 : endX - startX - 1;
if (effectType == EffectType.ROUNDED_BOX) {
UIUtil.drawRectPickedOut((Graphics2D)g, startX, startY, width, editor.getLineHeight() - 1);
} else {
g.drawRect(startX, startY, width, editor.getLineHeight() - 1);
}
return;
}
BorderGraphics border = new BorderGraphics(g, startX, startY, effectType);
border.horizontalTo(editor.getMaxWidthInRange(startOffset, endOffset) - 1);
border.verticalRel(height - 1);
border.horizontalTo(endX);
border.verticalRel(editor.getLineHeight());
border.horizontalTo(0);
border.verticalRel(-height + 1);
border.horizontalTo(startX);
border.verticalTo(startY);
}
示例10: customizeCellRenderer
import com.intellij.openapi.editor.markup.EffectType; //导入依赖的package包/类
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof VirtualFile) {
VirtualFile virtualFile = (VirtualFile)value;
String name = virtualFile.getPresentableName();
setIcon(IconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, myProject));
FileStatus fileStatus = FileStatusManager.getInstance(myProject).getStatus(virtualFile);
TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null , null, EffectType.LINE_UNDERSCORE,
Font.PLAIN);
append(name, SimpleTextAttributes.fromTextAttributes(attributes));
if (!selected && FileEditorManager.getInstance(myProject).isFileOpen(virtualFile)) {
setBackground(LightColors.SLIGHTLY_GREEN);
}
}
}
示例11: customizeCellRenderer
import com.intellij.openapi.editor.markup.EffectType; //导入依赖的package包/类
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof FileInfo) {
VirtualFile virtualFile = ((FileInfo)value).getFirst();
String name = virtualFile instanceof VirtualFilePathWrapper
? ((VirtualFilePathWrapper)virtualFile).getPresentablePath()
: UISettings.getInstance().SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES
? UniqueVFilePathBuilder.getInstance().getUniqueVirtualFilePath(myProject, virtualFile)
: virtualFile.getName();
setIcon(IconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, myProject));
FileStatus fileStatus = FileStatusManager.getInstance(myProject).getStatus(virtualFile);
open = FileEditorManager.getInstance(myProject).isFileOpen(virtualFile);
TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null , null, EffectType.LINE_UNDERSCORE, Font.PLAIN);
append(name, SimpleTextAttributes.fromTextAttributes(attributes));
// calc color the same way editor tabs do this, i.e. including extensions
Color color = EditorTabbedContainer.calcTabColor(myProject, virtualFile);
if (!selected && color != null) {
setBackground(color);
}
}
}
示例12: highlightUsages
import com.intellij.openapi.editor.markup.EffectType; //导入依赖的package包/类
private void highlightUsages() {
if (mySearchResults.getEditor() == null) return;
if (mySearchResults.getMatchesCount() >= mySearchResults.getMatchesLimit())
return;
for (FindResult range : mySearchResults.getOccurrences()) {
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);
if (range.getLength() == 0) {
attributes = attributes.clone();
attributes.setEffectType(EffectType.BOXED);
attributes.setEffectColor(attributes.getBackgroundColor());
}
if (mySearchResults.isExcluded(range)) {
highlightRange(range, strikout(attributes), myHighlighters);
} else {
highlightRange(range, attributes, myHighlighters);
}
}
updateInSelectionHighlighters();
if (!myListeningSelection) {
mySearchResults.getEditor().getSelectionModel().addSelectionListener(this);
myListeningSelection = true;
}
}
示例13: addDecisionEventHighlighter
import com.intellij.openapi.editor.markup.EffectType; //导入依赖的package包/类
public Token addDecisionEventHighlighter(PreviewState previewState, MarkupModel markupModel,
DecisionEventInfo info, Color errorStripeColor,
EffectType effectType) {
TokenStream tokens = previewState.parsingResult.parser.getInputStream();
Token startToken = tokens.get(info.startIndex);
Token stopToken = tokens.get(info.stopIndex);
TextAttributes textAttributes =
new TextAttributes(JBColor.BLACK, JBColor.WHITE, errorStripeColor,
effectType, Font.PLAIN);
textAttributes.setErrorStripeColor(errorStripeColor);
final RangeHighlighter rangeHighlighter =
markupModel.addRangeHighlighter(
startToken.getStartIndex(), stopToken.getStopIndex()+1,
HighlighterLayer.ADDITIONAL_SYNTAX, textAttributes,
HighlighterTargetArea.EXACT_RANGE);
rangeHighlighter.putUserData(DECISION_EVENT_INFO_KEY, info);
rangeHighlighter.setErrorStripeMarkColor(errorStripeColor);
return startToken;
}
示例14: highlightAndOfferHint
import com.intellij.openapi.editor.markup.EffectType; //导入依赖的package包/类
public void highlightAndOfferHint(Editor editor, int offset,
Interval sourceInterval,
JBColor color,
EffectType effectType, String hintText) {
CaretModel caretModel = editor.getCaretModel();
final TextAttributes attr = new TextAttributes();
attr.setForegroundColor(color);
attr.setEffectColor(color);
attr.setEffectType(effectType);
MarkupModel markupModel = editor.getMarkupModel();
markupModel.addRangeHighlighter(
sourceInterval.a,
sourceInterval.b,
InputPanel.TOKEN_INFO_LAYER, // layer
attr,
HighlighterTargetArea.EXACT_RANGE
);
if ( hintText.contains("<") ) {
hintText = hintText.replaceAll("<", "<");
}
// HINT
caretModel.moveToOffset(offset); // info tooltip only shows at cursor :(
HintManager.getInstance().showInformationHint(editor, hintText);
}
示例15: createTextAttributes
import com.intellij.openapi.editor.markup.EffectType; //导入依赖的package包/类
@Nonnull
public static GwtTextAttributes createTextAttributes(TextAttributes textAttributes) {
GwtColor foreground = null;
GwtColor background = null;
Color foregroundColor = textAttributes.getForegroundColor();
if (foregroundColor != null) {
foreground = createColor(foregroundColor);
}
Color backgroundColor = textAttributes.getBackgroundColor();
if (backgroundColor != null) {
background = createColor(backgroundColor);
}
int flags = 0;
flags = BitUtil.set(flags, GwtTextAttributes.BOLD, (textAttributes.getFontType() & Font.BOLD) != 0);
flags = BitUtil.set(flags, GwtTextAttributes.ITALIC, (textAttributes.getFontType() & Font.ITALIC) != 0);
flags = BitUtil.set(flags, GwtTextAttributes.UNDERLINE, textAttributes.getEffectType() == EffectType.LINE_UNDERSCORE);
flags = BitUtil.set(flags, GwtTextAttributes.LINE_THROUGH, textAttributes.getEffectType() == EffectType.STRIKEOUT);
return new GwtTextAttributes(foreground, background, flags);
}