use of com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl in project intellij-community by JetBrains.
the class DocumentMarkupModelTest method testInfoTestAttributes.
public void testInfoTestAttributes() throws Exception {
LanguageExtensionPoint<Annotator> extension = new LanguageExtensionPoint<>();
extension.language = "TEXT";
extension.implementationClass = TestAnnotator.class.getName();
PlatformTestUtil.registerExtension(ExtensionPointName.create(LanguageAnnotators.EP_NAME), extension, myFixture.getTestRootDisposable());
myFixture.configureByText(PlainTextFileType.INSTANCE, "foo");
EditorColorsScheme scheme = new EditorColorsSchemeImpl(new DefaultColorsScheme()) {
{
initFonts();
}
};
scheme.setAttributes(HighlighterColors.TEXT, new TextAttributes(Color.black, Color.white, null, null, Font.PLAIN));
((EditorEx) myFixture.getEditor()).setColorsScheme(scheme);
myFixture.doHighlighting();
MarkupModel model = DocumentMarkupModel.forDocument(myFixture.getEditor().getDocument(), getProject(), false);
RangeHighlighter[] highlighters = model.getAllHighlighters();
assertThat(highlighters).hasSize(1);
TextAttributes attributes = highlighters[0].getTextAttributes();
assertThat(attributes).isNotNull();
assertThat(attributes.getBackgroundColor()).isNull();
assertThat(attributes.getForegroundColor()).isNull();
}
use of com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl in project intellij-community by JetBrains.
the class EditorColorSchemeTestCase method doTestWriteRead.
@NotNull
protected Pair<EditorColorsScheme, TextAttributes> doTestWriteRead(@NotNull TextAttributesKey key, @NotNull TextAttributes attributes) {
EditorColorsScheme defaultScheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME);
EditorColorsScheme sourceScheme = (EditorColorsScheme) defaultScheme.clone();
sourceScheme.setName("test");
sourceScheme.setAttributes(key, attributes);
Element root = new Element("scheme");
((AbstractColorsScheme) sourceScheme).writeExternal(root);
EditorColorsScheme targetScheme = new EditorColorsSchemeImpl(defaultScheme);
targetScheme.readExternal(root);
assertEquals("test", targetScheme.getName());
TextAttributes targetAttrs = targetScheme.getAttributes(key);
return Pair.create(targetScheme, targetAttrs);
}
use of com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl in project intellij-community by JetBrains.
the class EditorColorSchemeTestCase method loadScheme.
protected static EditorColorsScheme loadScheme(@NotNull String docText) throws ParserConfigurationException, IOException, SAXException {
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource inputSource = new InputSource(new StringReader(docText));
Document doc = docBuilder.parse(inputSource);
Element root = new DOMBuilder().build(doc.getDocumentElement());
EditorColorsScheme defaultScheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME);
EditorColorsScheme targetScheme = new EditorColorsSchemeImpl(defaultScheme);
targetScheme.readExternal(root);
return targetScheme;
}
use of com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl in project intellij-community by JetBrains.
the class ColorSchemeActions method importScheme.
@Override
protected void importScheme(@NotNull String importerName) {
if (tryImportWithImportHandler(importerName)) {
return;
}
final SchemeImporter<EditorColorsScheme> importer = SchemeImporterEP.getImporter(importerName, EditorColorsScheme.class);
if (importer != null) {
VirtualFile importSource = SchemeImportUtil.selectImportSource(importer.getSourceExtensions(), getSchemesPanel(), null, "Choose " + importerName);
if (importSource != null) {
try {
EditorColorsScheme imported = importer.importScheme(DefaultProjectFactory.getInstance().getDefaultProject(), importSource, getOptions().getSelectedScheme(), name -> {
String newName = SchemeNameGenerator.getUniqueName(name != null ? name : "Unnamed", candidate -> getSchemesPanel().getModel().containsScheme(candidate, false));
AbstractColorsScheme newScheme = new EditorColorsSchemeImpl(EmptyColorScheme.INSTANCE);
newScheme.setName(newName);
newScheme.setDefaultMetaInfo(EmptyColorScheme.INSTANCE);
return newScheme;
});
if (imported != null) {
getOptions().addImportedScheme(imported);
}
} catch (SchemeImportException e) {
getSchemesPanel().showStatus("Import failed: " + e.getMessage(), MessageType.ERROR);
}
}
}
}
Aggregations