use of com.intellij.openapi.editor.colors.impl.AbstractColorsScheme in project intellij-community by JetBrains.
the class EditorColorSchemeTestCase method serialize.
protected Element serialize(@NotNull EditorColorsScheme scheme) {
Element root = new Element("scheme");
((AbstractColorsScheme) scheme).writeExternal(root);
fixPlatformSpecificValues(root);
root.removeChildren("metaInfo");
return root;
}
use of com.intellij.openapi.editor.colors.impl.AbstractColorsScheme in project intellij-community by JetBrains.
the class EditorColorSchemeTestCase method serializeWithFixedMeta.
protected Element serializeWithFixedMeta(@NotNull EditorColorsScheme scheme) {
Element root = new Element("scheme");
((AbstractColorsScheme) scheme).writeExternal(root);
fixPlatformSpecificValues(root);
Element metaInfo = root.getChild("metaInfo");
if (metaInfo != null) {
metaInfo.getChildren().forEach((child) -> {
Attribute name = child.getAttribute("name");
if (!child.getName().equals("property") || name == null || !RainbowHighlighter.isRainbowKey(name.getValue())) {
child.removeContent();
}
});
}
return root;
}
use of com.intellij.openapi.editor.colors.impl.AbstractColorsScheme 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);
}
}
}
}
use of com.intellij.openapi.editor.colors.impl.AbstractColorsScheme in project intellij-community by JetBrains.
the class ColorSchemeActions method exportScheme.
@Override
protected void exportScheme(@NotNull EditorColorsScheme scheme, @NotNull String exporterName) {
EditorColorsScheme schemeToExport = scheme;
if (scheme instanceof AbstractColorsScheme) {
EditorColorsScheme parent = ((AbstractColorsScheme) scheme).getParentScheme();
if (!(parent instanceof DefaultColorsScheme)) {
schemeToExport = parent;
}
}
if (schemeToExport.getName().startsWith(SchemeManager.EDITABLE_COPY_PREFIX)) {
schemeToExport = (EditorColorsScheme) schemeToExport.clone();
schemeToExport.setName(SchemeManager.getDisplayName(schemeToExport));
}
super.exportScheme(schemeToExport, exporterName);
}
use of com.intellij.openapi.editor.colors.impl.AbstractColorsScheme 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);
}
Aggregations