use of com.intellij.openapi.editor.colors.EditorColorsManager in project intellij-community by JetBrains.
the class AdvHighlightingTest method testSharedScopeBased.
public void testSharedScopeBased() throws Exception {
NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_ANY, null));
NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
NamedScopesHolder scopeManager = DependencyValidationManager.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, null, 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);
NamedScope projectScope = PackagesScopesProvider.getInstance(myProject).getProjectProductionScope();
TextAttributesKey projectKey = ScopeAttributesUtil.getScopeTextAttributeKey(projectScope.getName());
TextAttributes projectAttributes = new TextAttributes(null, null, Color.blue, EffectType.BOXED, Font.ITALIC);
scheme.setAttributes(projectKey, projectAttributes);
try {
testFile(BASE_PATH + "/scopeBased/x/Shared.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test();
} finally {
scopeManager.removeAllSets();
}
}
use of com.intellij.openapi.editor.colors.EditorColorsManager in project intellij-community by JetBrains.
the class AdvHighlightingTest method testScopeBased.
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();
}
}
use of com.intellij.openapi.editor.colors.EditorColorsManager in project intellij-community by JetBrains.
the class ThreadDumpPanel method highlightOccurrences.
private static void highlightOccurrences(String filter, Project project, Editor editor) {
final HighlightManager highlightManager = HighlightManager.getInstance(project);
EditorColorsManager colorManager = EditorColorsManager.getInstance();
final TextAttributes attributes = colorManager.getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);
String documentText = editor.getDocument().getText();
int i = -1;
while (true) {
int nextOccurrence = StringUtil.indexOfIgnoreCase(documentText, filter, i + 1);
if (nextOccurrence < 0) {
break;
}
i = nextOccurrence;
highlightManager.addOccurrenceHighlight(editor, i, i + filter.length(), attributes, HighlightManager.HIDE_BY_TEXT_CHANGE, null, null);
}
}
use of com.intellij.openapi.editor.colors.EditorColorsManager in project android by JetBrains.
the class HtmlBuilderHelper method fixFontStyles.
/**
* Adjust the font styles of the given text component, provided it's
* an HTML styled document, to use fonts from the current IDE scheme.
* <p>
* Note: Calling setText() on a component will reset the document styles
* so you will need to call this method repeatedly after each document
* replace.
*
* @param component the component
*/
public static void fixFontStyles(@NotNull JTextComponent component) {
Document document = component.getDocument();
if (!(document instanceof StyledDocument)) {
return;
}
StyledDocument styledDocument = (StyledDocument) document;
EditorColorsManager colorsManager = EditorColorsManager.getInstance();
EditorColorsScheme scheme = colorsManager.getGlobalScheme();
Style style = styledDocument.addStyle("active", null);
StyleConstants.setFontFamily(style, scheme.getEditorFontName());
StyleConstants.setFontSize(style, scheme.getEditorFontSize());
styledDocument.setCharacterAttributes(0, document.getLength(), style, false);
}
use of com.intellij.openapi.editor.colors.EditorColorsManager in project android by JetBrains.
the class MergedManifestFixture method getDefaultBackgroundColor.
public Color getDefaultBackgroundColor() {
EditorColorsManager colorsManager = EditorColorsManager.getInstance();
EditorColorsScheme scheme = colorsManager.getGlobalScheme();
return scheme.getDefaultBackground();
}
Aggregations