IDEA-136776 As of 14.1 IDEA Color & Font theme resets after every restart to default

This commit is contained in:
Vladimir Krivosheev
2015-02-20 17:08:18 +01:00
parent 5a9487b15f
commit 9965d8e51e
20 changed files with 318 additions and 412 deletions
@@ -17,8 +17,6 @@ package com.intellij.openapi.editor.markup;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizable;
import com.intellij.openapi.util.WriteExternalException;
import org.intellij.lang.annotations.JdkConstants;
import org.jdom.Element;
import org.jetbrains.annotations.Contract;
@@ -30,7 +28,7 @@ import java.awt.*;
/**
* Defines the visual representation (colors and effects) of text.
*/
public class TextAttributes implements JDOMExternalizable, Cloneable {
public class TextAttributes implements Cloneable {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.markup.TextAttributes");
public static final TextAttributes ERASE_MARKER = new TextAttributes();
@@ -77,7 +75,7 @@ public class TextAttributes implements JDOMExternalizable, Cloneable {
myEnforcedDefaults = enforced;
}
public TextAttributes(@NotNull Element element) throws InvalidDataException {
public TextAttributes(@NotNull Element element) {
readExternal(element);
}
@@ -191,14 +189,20 @@ public class TextAttributes implements JDOMExternalizable, Cloneable {
return myAttrs.hashCode();
}
@Override
public void readExternal(Element element) throws InvalidDataException {
myAttrs = AttributesFlyweight.create(element);
if (isEmpty()) myEnforcedDefaults = true;
public void readExternal(Element element) {
try {
myAttrs = AttributesFlyweight.create(element);
}
catch (InvalidDataException e) {
throw new RuntimeException(e);
}
if (isEmpty()) {
myEnforcedDefaults = true;
}
}
@Override
public void writeExternal(Element element) throws WriteExternalException {
public void writeExternal(Element element) {
myAttrs.writeExternal(element);
}
@@ -15,94 +15,43 @@
*/
package com.intellij.openapi.options;
import com.intellij.util.ThrowableConvertor;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public interface SchemesManager <T extends Scheme, E extends ExternalizableScheme>{
SchemesManager EMPTY = new SchemesManager(){
@Override
@NotNull
public Collection loadSchemes() {
return Collections.emptySet();
}
public abstract class SchemesManager<T extends Scheme, E extends ExternalizableScheme> {
@NotNull
public abstract Collection<E> loadSchemes();
@Override
public void addNewScheme(@NotNull final Scheme scheme, final boolean replaceExisting) {
}
public abstract void addNewScheme(@NotNull T scheme, final boolean replaceExisting);
@Override
public void clearAllSchemes() {
}
@Override
@NotNull
public List getAllSchemes() {
return Collections.emptyList();
}
@Override
public Scheme findSchemeByName(@NotNull String schemeName) {
return null;
}
@Override
public void save() {
}
@Override
public void setCurrentSchemeName(String schemeName) {
}
@Override
public Scheme getCurrentScheme() {
return null;
}
@Override
public void removeScheme(@NotNull Scheme scheme) {
}
@Override
@NotNull
public Collection getAllSchemeNames() {
return Collections.emptySet();
}
@Override
public File getRootDirectory() {
return null;
}
};
public abstract void clearAllSchemes();
@NotNull
Collection<E> loadSchemes();
void addNewScheme(@NotNull T scheme, final boolean replaceExisting);
void clearAllSchemes();
@NotNull
List<T> getAllSchemes();
public abstract List<T> getAllSchemes();
@Nullable
T findSchemeByName(@NotNull String schemeName);
public abstract T findSchemeByName(@NotNull String schemeName);
void save();
public abstract void save();
void setCurrentSchemeName(@Nullable String schemeName);
public abstract void setCurrentSchemeName(@Nullable String schemeName);
@Nullable
T getCurrentScheme();
public abstract T getCurrentScheme();
void removeScheme(@NotNull T scheme);
public abstract void removeScheme(@NotNull T scheme);
@NotNull
Collection<String> getAllSchemeNames();
public abstract Collection<String> getAllSchemeNames();
File getRootDirectory();
public abstract File getRootDirectory();
public void loadBundledScheme(@NotNull String resourceName, @NotNull Object requestor, @NotNull ThrowableConvertor<Element, T, Throwable> convertor) {
}
}
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.*;
public abstract class AbstractSchemesManager<T extends Scheme, E extends ExternalizableScheme> implements SchemesManager<T, E> {
public abstract class AbstractSchemesManager<T extends Scheme, E extends ExternalizableScheme> extends SchemesManager<T, E> {
private static final Logger LOG = Logger.getInstance(AbstractSchemesManager.class);
protected final List<T> mySchemes = new ArrayList<T>();
@@ -0,0 +1,78 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.options;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class EmptySchemesManager extends SchemesManager {
@Override
@NotNull
public Collection loadSchemes() {
return Collections.emptySet();
}
@Override
public void addNewScheme(@NotNull final Scheme scheme, final boolean replaceExisting) {
}
@Override
public void clearAllSchemes() {
}
@Override
@NotNull
public List getAllSchemes() {
return Collections.emptyList();
}
@Override
public Scheme findSchemeByName(@NotNull String schemeName) {
return null;
}
@Override
public void save() {
}
@Override
public void setCurrentSchemeName(String schemeName) {
}
@Override
public Scheme getCurrentScheme() {
return null;
}
@Override
public void removeScheme(@NotNull Scheme scheme) {
}
@Override
@NotNull
public Collection getAllSchemeNames() {
return Collections.emptySet();
}
@Override
public File getRootDirectory() {
return null;
}
}
@@ -18,14 +18,14 @@ package com.intellij.openapi.editor.colors;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.options.FontSize;
import com.intellij.openapi.options.Scheme;
import com.intellij.openapi.util.JDOMExternalizable;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, TextAttributesScheme, Scheme {
public interface EditorColorsScheme extends Cloneable, TextAttributesScheme, Scheme {
@NonNls String DEFAULT_SCHEME_NAME = "Default";
void setName(String name);
@@ -90,4 +90,6 @@ public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, TextA
float getConsoleLineSpacing();
void setConsoleLineSpacing(float lineSpacing);
void readExternal(Element parentNode);
}
@@ -18,7 +18,6 @@ package com.intellij.openapi.editor.colors.ex;
import com.intellij.openapi.components.*;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.impl.DefaultColorsScheme;
import com.intellij.openapi.util.InvalidDataException;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
@@ -52,13 +51,8 @@ public class DefaultColorSchemesManager implements PersistentStateComponent<Elem
@Override
public void loadState(Element state) {
for (Element schemeElement : state.getChildren(SCHEME_ELEMENT)) {
DefaultColorsScheme newScheme = new DefaultColorsScheme(this);
try {
newScheme.readExternal(schemeElement);
}
catch (InvalidDataException e) {
throw new RuntimeException(e);
}
DefaultColorsScheme newScheme = new DefaultColorsScheme();
newScheme.readExternal(schemeElement);
mySchemes.add(newScheme);
}
}
@@ -27,12 +27,10 @@ import com.intellij.openapi.editor.markup.EffectType;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.options.FontSize;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.containers.HashMap;
import com.intellij.util.ui.JBFont;
import com.intellij.util.ui.JBUI;
import gnu.trove.THashMap;
import org.jdom.Element;
@@ -73,7 +71,6 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
@NonNls private static final String CONSOLE_FONT = "console-font";
@NonNls private static final String EDITOR_FONT_NAME = "EDITOR_FONT_NAME";
@NonNls private static final String CONSOLE_FONT_NAME = "CONSOLE_FONT_NAME";
protected DefaultColorSchemesManager myDefaultColorSchemesManager;
private Color myDeprecatedBackgroundColor = null;
@NonNls private static final String SCHEME_ELEMENT = "scheme";
@NonNls public static final String NAME_ATTR = "name";
@@ -91,9 +88,8 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
@NonNls private static final String CONSOLE_FONT_SIZE = "CONSOLE_FONT_SIZE";
@NonNls private static final String EDITOR_QUICK_JAVADOC_FONT_SIZE = "EDITOR_QUICK_DOC_FONT_SIZE";
protected AbstractColorsScheme(EditorColorsScheme parentScheme, DefaultColorSchemesManager defaultColorSchemesManager) {
protected AbstractColorsScheme(EditorColorsScheme parentScheme) {
myParentScheme = parentScheme;
myDefaultColorSchemesManager = defaultColorSchemesManager;
myFontPreferences.setChangeListener(new Runnable() {
@Override
public void run() {
@@ -102,8 +98,7 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
});
}
public AbstractColorsScheme(DefaultColorSchemesManager defaultColorSchemesManager) {
myDefaultColorSchemesManager = defaultColorSchemesManager;
public AbstractColorsScheme() {
}
@NotNull
@@ -263,13 +258,12 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
return getName();
}
@Override
public void readExternal(Element parentNode) throws InvalidDataException {
public void readExternal(Element parentNode) {
if (SCHEME_ELEMENT.equals(parentNode.getName())) {
readScheme(parentNode);
} else {
for (final Object o : parentNode.getChildren(SCHEME_ELEMENT)) {
Element element = (Element)o;
}
else {
for (Element element : parentNode.getChildren(SCHEME_ELEMENT)) {
readScheme(element);
}
}
@@ -277,66 +271,66 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
myVersion = CURR_VERSION;
}
private void readScheme(Element node) throws InvalidDataException {
private void readScheme(Element node) {
myDeprecatedBackgroundColor = null;
if (SCHEME_ELEMENT.equals(node.getName())) {
setName(node.getAttributeValue(NAME_ATTR));
int readVersion = Integer.parseInt(node.getAttributeValue(VERSION_ATTR, "0"));
if (readVersion > CURR_VERSION) throw new InvalidDataException("Unsupported color scheme version: " + readVersion);
myVersion = readVersion;
String isDefaultScheme = node.getAttributeValue(DEFAULT_SCHEME_ATTR);
if (isDefaultScheme == null || !Boolean.parseBoolean(isDefaultScheme)) {
String parentSchemeName = node.getAttributeValue(PARENT_SCHEME_ATTR);
if (parentSchemeName == null) parentSchemeName = DEFAULT_SCHEME_NAME;
myParentScheme = myDefaultColorSchemesManager.getScheme(parentSchemeName);
}
for (final Object o : node.getChildren()) {
Element childNode = (Element)o;
String childName = childNode.getName();
if (OPTION_ELEMENT.equals(childName)) {
readSettings(childNode);
}
else if (EDITOR_FONT.equals(childName)) {
readFontSettings(childNode, myFontPreferences);
}
else if (CONSOLE_FONT.equals(childName)) {
readFontSettings(childNode, myConsoleFontPreferences);
}
else if (COLORS_ELEMENT.equals(childName)) {
readColors(childNode);
}
else if (ATTRIBUTES_ELEMENT.equals(childName)) {
readAttributes(childNode);
}
}
if (myDeprecatedBackgroundColor != null) {
TextAttributes textAttributes = myAttributesMap.get(HighlighterColors.TEXT);
if (textAttributes == null) {
textAttributes = new TextAttributes(Color.black, myDeprecatedBackgroundColor, null, EffectType.BOXED, Font.PLAIN);
myAttributesMap.put(HighlighterColors.TEXT, textAttributes);
}
else {
textAttributes.setBackgroundColor(myDeprecatedBackgroundColor);
}
}
if (myConsoleFontPreferences.getEffectiveFontFamilies().isEmpty()) {
myFontPreferences.copyTo(myConsoleFontPreferences);
}
initFonts();
if (!SCHEME_ELEMENT.equals(node.getName())) {
return;
}
setName(node.getAttributeValue(NAME_ATTR));
int readVersion = Integer.parseInt(node.getAttributeValue(VERSION_ATTR, "0"));
if (readVersion > CURR_VERSION) {
throw new IllegalStateException("Unsupported color scheme version: " + readVersion);
}
myVersion = readVersion;
String isDefaultScheme = node.getAttributeValue(DEFAULT_SCHEME_ATTR);
if (isDefaultScheme == null || !Boolean.parseBoolean(isDefaultScheme)) {
myParentScheme = DefaultColorSchemesManager.getInstance().getScheme(node.getAttributeValue(PARENT_SCHEME_ATTR, DEFAULT_SCHEME_NAME));
}
for (final Object o : node.getChildren()) {
Element childNode = (Element)o;
String childName = childNode.getName();
if (OPTION_ELEMENT.equals(childName)) {
readSettings(childNode);
}
else if (EDITOR_FONT.equals(childName)) {
readFontSettings(childNode, myFontPreferences);
}
else if (CONSOLE_FONT.equals(childName)) {
readFontSettings(childNode, myConsoleFontPreferences);
}
else if (COLORS_ELEMENT.equals(childName)) {
readColors(childNode);
}
else if (ATTRIBUTES_ELEMENT.equals(childName)) {
readAttributes(childNode);
}
}
if (myDeprecatedBackgroundColor != null) {
TextAttributes textAttributes = myAttributesMap.get(HighlighterColors.TEXT);
if (textAttributes == null) {
textAttributes = new TextAttributes(Color.black, myDeprecatedBackgroundColor, null, EffectType.BOXED, Font.PLAIN);
myAttributesMap.put(HighlighterColors.TEXT, textAttributes);
}
else {
textAttributes.setBackgroundColor(myDeprecatedBackgroundColor);
}
}
if (myConsoleFontPreferences.getEffectiveFontFamilies().isEmpty()) {
myFontPreferences.copyTo(myConsoleFontPreferences);
}
initFonts();
}
protected void readAttributes(Element childNode) throws InvalidDataException {
for (final Object o : childNode.getChildren(OPTION_ELEMENT)) {
Element e = (Element)o;
String key = e.getAttributeValue(NAME_ATTR);
TextAttributesKey name = TextAttributesKey.find(key);
Element value = e.getChild(VALUE_ELEMENT);
TextAttributes attr = new TextAttributes(value);
protected void readAttributes(@NotNull Element childNode) {
for (Element e : childNode.getChildren(OPTION_ELEMENT)) {
TextAttributesKey name = TextAttributesKey.find(e.getAttributeValue(NAME_ATTR));
TextAttributes attr = new TextAttributes(e.getChild(VALUE_ELEMENT));
myAttributesMap.put(name, attr);
migrateErrorStripeColorFrom45(name, attr);
}
@@ -446,7 +440,6 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
return value == null ? e.getAttributeValue(VALUE_ELEMENT) : value;
}
@Override
public void writeExternal(Element parentNode) throws WriteExternalException {
parentNode.setAttribute(NAME_ATTR, getName());
parentNode.setAttribute(VERSION_ATTR, Integer.toString(myVersion));
@@ -545,9 +538,8 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
}
}
private boolean haveToWrite(final TextAttributesKey key, final TextAttributes value, final TextAttributes defaultAttribute) {
if (key.getFallbackAttributeKey() != null && value.isFallbackEnabled()) return false;
return !value.equals(defaultAttribute);
private static boolean haveToWrite(final TextAttributesKey key, final TextAttributes value, final TextAttributes defaultAttribute) {
return !(key.getFallbackAttributeKey() != null && value.isFallbackEnabled()) && !value.equals(defaultAttribute);
}
private void writeAttributes(Element attrElements) throws WriteExternalException {
@@ -22,9 +22,7 @@ package com.intellij.openapi.editor.colors.impl;
import com.intellij.openapi.editor.colors.ColorKey;
import com.intellij.openapi.editor.colors.EditorFontType;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.util.InvalidDataException;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -34,8 +32,8 @@ import java.awt.*;
public class DefaultColorsScheme extends AbstractColorsScheme implements ReadOnlyColorsScheme {
private String myName;
public DefaultColorsScheme(DefaultColorSchemesManager defaultColorSchemesManager) {
super(null, defaultColorSchemesManager);
public DefaultColorsScheme() {
super(null);
}
@Override
@@ -62,7 +60,7 @@ public class DefaultColorsScheme extends AbstractColorsScheme implements ReadOnl
}
@Override
public void readExternal(Element parentNode) throws InvalidDataException {
public void readExternal(Element parentNode) {
super.readExternal(parentNode);
myName = parentNode.getAttributeValue(NAME_ATTR);
}
@@ -87,10 +85,9 @@ public class DefaultColorsScheme extends AbstractColorsScheme implements ReadOnl
@Override
public Object clone() {
EditorColorsSchemeImpl newScheme = new EditorColorsSchemeImpl(this, myDefaultColorSchemesManager);
EditorColorsSchemeImpl newScheme = new EditorColorsSchemeImpl(this);
copyTo(newScheme);
newScheme.setName(DEFAULT_SCHEME_NAME);
return newScheme;
}
}
@@ -18,7 +18,6 @@ package com.intellij.openapi.editor.colors.impl;
import com.intellij.openapi.editor.colors.ColorKey;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.options.ExternalInfo;
import com.intellij.openapi.options.ExternalizableScheme;
@@ -34,8 +33,8 @@ import java.awt.*;
public class EditorColorsSchemeImpl extends AbstractColorsScheme implements ExternalizableScheme {
private final ExternalInfo myExternalInfo = new ExternalInfo();
public EditorColorsSchemeImpl(EditorColorsScheme parentScheme, DefaultColorSchemesManager defaultColorSchemesManager) {
super(parentScheme, defaultColorSchemesManager);
public EditorColorsSchemeImpl(EditorColorsScheme parentScheme) {
super(parentScheme);
}
@Override
@@ -69,7 +68,6 @@ public class EditorColorsSchemeImpl extends AbstractColorsScheme implements Exte
return myParentScheme.getAttributes(key);
}
public boolean containsKey(TextAttributesKey key) {
return myAttributesMap.containsKey(key);
}
@@ -87,7 +85,7 @@ public class EditorColorsSchemeImpl extends AbstractColorsScheme implements Exte
@Override
public Object clone() {
EditorColorsSchemeImpl newScheme = new EditorColorsSchemeImpl(myParentScheme, DefaultColorSchemesManager.getInstance());
EditorColorsSchemeImpl newScheme = new EditorColorsSchemeImpl(myParentScheme);
copyTo(newScheme);
newScheme.setName(getName());
return newScheme;
@@ -20,7 +20,6 @@ import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.EditorColorsUtil;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizable;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.util.ui.UIUtil;
@@ -51,10 +50,9 @@ public class UsageTreeColorsScheme implements NamedComponent, JDOMExternalizable
}
@Override
public void readExternal(Element element) throws InvalidDataException {
public void readExternal(Element element) {
if (myColorsScheme == null) {
EditorColorsScheme scheme = EditorColorsUtil.getColorSchemeForBackground(UIUtil.getTreeTextBackground());
myColorsScheme = (EditorColorsScheme)scheme.clone();
myColorsScheme = (EditorColorsScheme)EditorColorsUtil.getColorSchemeForBackground(UIUtil.getTreeTextBackground()).clone();
}
myColorsScheme.readExternal(element);
}
@@ -32,7 +32,6 @@ import com.intellij.openapi.editor.colors.ColorKey;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager;
import com.intellij.openapi.editor.colors.impl.DefaultColorsScheme;
import com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl;
import com.intellij.openapi.editor.colors.impl.ReadOnlyColorsScheme;
@@ -990,7 +989,8 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
private boolean myIsNew = false;
private MyColorScheme(@NotNull EditorColorsScheme parentScheme) {
super(parentScheme, DefaultColorSchemesManager.getInstance());
super(parentScheme);
parentScheme.getFontPreferences().copyTo(getFontPreferences());
setLineSpacing(parentScheme.getLineSpacing());
@@ -20,7 +20,6 @@ import com.intellij.ide.actions.QuickSwitchSchemeAction;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.impl.BundledQuickListsProvider;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ex.DecodeDefaultsUtil;
import com.intellij.openapi.components.ExportableApplicationComponent;
import com.intellij.openapi.components.RoamingType;
import com.intellij.openapi.components.StoragePathMacros;
@@ -31,12 +30,12 @@ import com.intellij.openapi.options.SchemesManagerFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.util.PathUtilRt;
import com.intellij.util.ThrowableConvertor;
import gnu.trove.THashSet;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.InputStream;
import java.util.Collection;
import java.util.Set;
@@ -101,25 +100,17 @@ public class QuickListsManager implements ExportableApplicationComponent {
@Override
public void initComponent() {
for (BundledQuickListsProvider provider : BundledQuickListsProvider.EP_NAME.getExtensions()) {
for (String path : provider.getBundledListsRelativePaths()) {
try {
InputStream inputStream = DecodeDefaultsUtil.getDefaultsInputStream(provider, path);
if (inputStream == null) {
// Error shouldn't occur during this operation thus we report error instead of info
LOG.error("Cannot read quick list from " + path);
}
else {
Element element = JDOMUtil.load(inputStream);
for (final String path : provider.getBundledListsRelativePaths()) {
mySchemesManager.loadBundledScheme(path, provider, new ThrowableConvertor<Element, QuickList, Throwable>() {
@Override
public QuickList convert(Element element) throws Throwable {
QuickList item = createItem(element);
item.getExternalInfo().setHash(JDOMUtil.getTreeHash(element, true));
item.getExternalInfo().setPreviouslySavedName(item.getName());
item.getExternalInfo().setCurrentFileName(PathUtilRt.getFileName(path));
mySchemesManager.addNewScheme(item, false);
return item;
}
}
catch (Exception e) {
LOG.error("Cannot read quick list from " + path + ": " + e.getMessage(), e);
}
});
}
}
mySchemesManager.loadSchemes();
@@ -18,8 +18,6 @@ package com.intellij.openapi.editor.colors.impl;
import com.intellij.openapi.editor.colors.*;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.options.FontSize;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -145,11 +143,7 @@ public abstract class DelegateColorScheme implements EditorColorsScheme {
}
@Override
public void readExternal(Element element) throws InvalidDataException {
}
@Override
public void writeExternal(Element element) throws WriteExternalException {
public void readExternal(Element element) {
}
@NotNull
@@ -203,5 +197,4 @@ public abstract class DelegateColorScheme implements EditorColorsScheme {
public void setConsoleLineSpacing(float lineSpacing) {
myDelegate.setConsoleLineSpacing(lineSpacing);
}
}
@@ -13,21 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author Yura Cangea
*/
package com.intellij.openapi.editor.colors.impl;
import com.intellij.ide.WelcomeWizardUtil;
import com.intellij.ide.ui.LafManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.components.ExportableComponent;
import com.intellij.openapi.components.NamedComponent;
import com.intellij.openapi.components.RoamingType;
import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.components.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.colors.EditorColorsListener;
@@ -36,42 +28,47 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.options.*;
import com.intellij.openapi.util.*;
import com.intellij.openapi.options.BaseSchemeProcessor;
import com.intellij.openapi.options.Scheme;
import com.intellij.openapi.options.SchemesManager;
import com.intellij.openapi.options.SchemesManagerFactory;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.EventDispatcher;
import com.intellij.util.ThrowableConvertor;
import com.intellij.util.io.URLUtil;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.xmlb.annotations.OptionTag;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
public class EditorColorsManagerImpl extends EditorColorsManager implements NamedJDOMExternalizable, ExportableComponent, NamedComponent {
@State(
name = "EditorColorsManagerImpl",
storages = @Storage(file = StoragePathMacros.APP_CONFIG + "/colors.scheme.xml"),
additionalExportFile = EditorColorsManagerImpl.FILE_SPEC
)
public class EditorColorsManagerImpl extends EditorColorsManager implements PersistentStateComponent<EditorColorsManagerImpl.State> {
private static final Logger LOG = Logger.getInstance(EditorColorsManagerImpl.class);
private final EventDispatcher<EditorColorsListener> myListeners = EventDispatcher.create(EditorColorsListener.class);
@NonNls private static final String NODE_NAME = "global_color_scheme";
@NonNls private static final String SCHEME_NODE_NAME = "scheme";
private static final String DEFAULT_NAME = "Default";
private String myGlobalSchemeName;
public boolean USE_ONLY_MONOSPACED_FONTS = true;
private final EventDispatcher<EditorColorsListener> myListeners = EventDispatcher.create(EditorColorsListener.class);
private final DefaultColorSchemesManager myDefaultColorSchemesManager;
private final SchemesManager<EditorColorsScheme, EditorColorsSchemeImpl> mySchemesManager;
@NonNls private static final String NAME_ATTR = "name";
private static final String FILE_SPEC = StoragePathMacros.ROOT_CONFIG + "/colors";
@NonNls
private static final String FILE_EXT = ".icls";
static final String FILE_SPEC = StoragePathMacros.ROOT_CONFIG + "/colors";
private State myState = new State();
public EditorColorsManagerImpl(DefaultColorSchemesManager defaultColorSchemesManager, SchemesManagerFactory schemesManagerFactory) {
myDefaultColorSchemesManager = defaultColorSchemesManager;
@@ -79,8 +76,10 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name
mySchemesManager = schemesManagerFactory.createSchemesManager(FILE_SPEC, new BaseSchemeProcessor<EditorColorsSchemeImpl>() {
@NotNull
@Override
public EditorColorsSchemeImpl readScheme(@NotNull Element element) throws InvalidDataException {
return loadSchemeFromDocument(element, true);
public EditorColorsSchemeImpl readScheme(@NotNull Element element) {
EditorColorsSchemeImpl scheme = new EditorColorsSchemeImpl(null);
scheme.readExternal(element);
return scheme;
}
@Override
@@ -93,7 +92,6 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name
LOG.error(e);
return null;
}
return root;
}
@@ -109,9 +107,10 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name
}
@NotNull
@NonNls
@Override
public String getSchemeExtension() {
return FILE_EXT;
return ".icls";
}
@Override
@@ -124,7 +123,14 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name
// Load default schemes from providers
if (!isUnitTestOrHeadlessMode()) {
loadSchemesFromBeans();
for (BundledColorSchemeEP ep : BundledColorSchemeEP.EP_NAME.getExtensions()) {
mySchemesManager.loadBundledScheme(ep.path + ".xml", ep, new ThrowableConvertor<Element, EditorColorsScheme, Throwable>() {
@Override
public EditorColorsScheme convert(Element element) throws Throwable {
return new ReadOnlyColorsSchemeImpl(element);
}
});
}
}
mySchemesManager.loadSchemes();
@@ -137,8 +143,22 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name
scheme = getScheme(wizardEditorScheme);
LOG.assertTrue(scheme != null, "Wizard scheme " + wizardEditorScheme + " not found");
}
if (scheme == null) scheme = myDefaultColorSchemesManager.getAllSchemes()[0];
setGlobalSchemeInner(scheme);
setGlobalSchemeInner(scheme == null ? getDefaultScheme() : scheme);
}
static class ReadOnlyColorsSchemeImpl extends EditorColorsSchemeImpl implements ReadOnlyColorsScheme {
public ReadOnlyColorsSchemeImpl(@NotNull Element element) {
super(null);
readExternal(element);
}
}
static class State {
public boolean USE_ONLY_MONOSPACED_FONTS = true;
@OptionTag(tag = "global_color_scheme", nameAttribute = "", valueAttribute = "name")
public String colorScheme;
}
private static boolean isUnitTestOrHeadlessMode() {
@@ -150,29 +170,12 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name
// It is reasonable to fetch attributes from Default color scheme. Otherwise if we launch IDE and then
// try switch from custom colors scheme (e.g. with dark background) to default one. Editor will show
// incorrect highlighting with "traces" of color scheme which was active during IDE startup.
final EditorColorsScheme defaultColorScheme = getScheme(dark ? "Darcula" : EditorColorsScheme.DEFAULT_SCHEME_NAME);
return defaultColorScheme.getAttributes(key);
}
private void loadSchemesFromBeans() {
for (BundledColorSchemeEP schemeEP : Extensions.getExtensions(BundledColorSchemeEP.EP_NAME)) {
String fileName = schemeEP.path + ".xml";
InputStream stream = schemeEP.getLoaderForClass().getResourceAsStream(fileName);
try {
EditorColorsSchemeImpl scheme = loadSchemeFromStream(fileName, stream);
if (scheme != null) {
mySchemesManager.addNewScheme(scheme, false);
}
}
catch (final Exception e) {
LOG.error("Cannot read scheme from " + fileName + ": " + e.getLocalizedMessage(), e);
}
}
return getScheme(dark ? "Darcula" : EditorColorsScheme.DEFAULT_SCHEME_NAME).getAttributes(key);
}
private void loadAdditionalTextAttributes() {
for (AdditionalTextAttributesEP attributesEP : AdditionalTextAttributesEP.EP_NAME.getExtensions()) {
final EditorColorsScheme editorColorsScheme = mySchemesManager.findSchemeByName(attributesEP.scheme);
EditorColorsScheme editorColorsScheme = mySchemesManager.findSchemeByName(attributesEP.scheme);
if (editorColorsScheme == null) {
if (!isUnitTestOrHeadlessMode()) {
LOG.warn("Cannot find scheme: " + attributesEP.scheme + " from plugin: " + attributesEP.getPluginDescriptor().getPluginId());
@@ -180,53 +183,19 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name
continue;
}
try {
InputStream inputStream = attributesEP.getLoaderForClass().getResourceAsStream(attributesEP.file);
((AbstractColorsScheme)editorColorsScheme).readAttributes(JDOMUtil.load(inputStream));
URL resource = attributesEP.getLoaderForClass().getResource(attributesEP.file);
assert resource != null;
((AbstractColorsScheme)editorColorsScheme).readAttributes(JDOMUtil.load(URLUtil.openStream(resource)));
}
catch (Exception e1) {
LOG.error(e1);
catch (Exception e) {
LOG.error(e);
}
}
}
private static EditorColorsSchemeImpl loadSchemeFromStream(String schemePath, InputStream inputStream)
throws IOException, JDOMException, InvalidDataException {
if (inputStream == null) {
// Error shouldn't occur during this operation
// thus we report error instead of info
LOG.error("Cannot read scheme from " + schemePath);
return null;
}
Element element;
try {
element = JDOMUtil.load(inputStream);
}
catch (JDOMException e) {
LOG.info("Error reading scheme from " + schemePath + ": " + e.getLocalizedMessage());
throw e;
}
return loadSchemeFromDocument(element, false);
}
@NotNull
private static EditorColorsSchemeImpl loadSchemeFromDocument(@NotNull Element element, boolean isEditable) throws InvalidDataException {
if (!SCHEME_NODE_NAME.equals(element.getName())) {
throw new InvalidDataException();
}
final EditorColorsSchemeImpl scheme = isEditable
// editable scheme
? new EditorColorsSchemeImpl(null, DefaultColorSchemesManager.getInstance())
//not editable scheme
: new ReadOnlyColorsSchemeImpl(null, DefaultColorSchemesManager.getInstance());
scheme.readExternal(element);
return scheme;
}
@Override
public void addColorsScheme(@NotNull EditorColorsScheme scheme) {
if (!isDefaultScheme(scheme) && scheme.getName().trim().length() > 0) {
if (!isDefaultScheme(scheme) && !StringUtil.isEmpty(scheme.getName())) {
mySchemesManager.addNewScheme(scheme, true);
}
}
@@ -238,8 +207,7 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name
}
private void addDefaultSchemes() {
DefaultColorsScheme[] allDefaultSchemes = myDefaultColorSchemesManager.getAllSchemes();
for (DefaultColorsScheme defaultScheme : allDefaultSchemes) {
for (DefaultColorsScheme defaultScheme : myDefaultColorSchemesManager.getAllSchemes()) {
mySchemesManager.addNewScheme(defaultScheme, true);
}
}
@@ -277,18 +245,15 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name
}
@NotNull
private static DefaultColorsScheme getDefaultScheme() {
return DefaultColorSchemesManager.getInstance().getAllSchemes()[0];
private DefaultColorsScheme getDefaultScheme() {
return myDefaultColorSchemesManager.getAllSchemes()[0];
}
@NotNull
@Override
public EditorColorsScheme getGlobalScheme() {
final EditorColorsScheme scheme = mySchemesManager.getCurrentScheme();
if (scheme == null) {
return getDefaultScheme();
}
return scheme;
EditorColorsScheme scheme = mySchemesManager.getCurrentScheme();
return scheme == null ? getDefaultScheme() : scheme;
}
@Override
@@ -300,20 +265,6 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name
myListeners.getMulticaster().globalSchemeChange(scheme);
}
private static File getColorsDir(boolean create) {
@NonNls String directoryPath = PathManager.getConfigPath() + File.separator + "colors";
File directory = new File(directoryPath);
if (!directory.exists()) {
if (!create) return null;
if (!directory.mkdir()) {
LOG.error("Cannot create directory: " + directory.getAbsolutePath());
return null;
}
}
return directory;
}
@Override
public void addEditorColorsListener(@NotNull EditorColorsListener listener) {
myListeners.addListener(listener);
@@ -330,56 +281,29 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name
}
@Override
public void setUseOnlyMonospacedFonts(boolean b) {
USE_ONLY_MONOSPACED_FONTS = b;
public void setUseOnlyMonospacedFonts(boolean value) {
myState.USE_ONLY_MONOSPACED_FONTS = value;
}
@Override
public boolean isUseOnlyMonospacedFonts() {
return USE_ONLY_MONOSPACED_FONTS;
return myState.USE_ONLY_MONOSPACED_FONTS;
}
@Nullable
@Override
public String getExternalFileName() {
return "colors.scheme";
}
@Override
@NotNull
public File[] getExportFiles() {
return new File[]{getColorsDir(true), PathManager.getOptionsFile(this)};
}
@Override
@NotNull
public String getPresentableName() {
return OptionsBundle.message("options.color.schemes.presentable.name");
}
@Override
public void readExternal(Element parentNode) throws InvalidDataException {
DefaultJDOMExternalizer.readExternal(this, parentNode);
Element element = parentNode.getChild(NODE_NAME);
if (element != null) {
String name = element.getAttributeValue(NAME_ATTR);
if (StringUtil.isNotEmpty(name)) {
myGlobalSchemeName = name;
}
}
EditorColorsScheme globalScheme =
myGlobalSchemeName != null ? mySchemesManager.findSchemeByName(myGlobalSchemeName) : myDefaultColorSchemesManager.getAllSchemes()[0];
setGlobalSchemeInner(globalScheme);
}
@Override
public void writeExternal(Element parentNode) throws WriteExternalException {
DefaultJDOMExternalizer.writeExternal(this, parentNode);
public State getState() {
if (mySchemesManager.getCurrentScheme() != null) {
Element element = new Element(NODE_NAME);
element.setAttribute(NAME_ATTR, mySchemesManager.getCurrentScheme().getName());
parentNode.addContent(element);
String name = mySchemesManager.getCurrentScheme().getName();
myState.colorScheme = "Default".equals(name) ? null : name;
}
return myState;
}
@Override
public void loadState(State state) {
myState = state;
setGlobalSchemeInner(myState.colorScheme == null ? getDefaultScheme() : mySchemesManager.findSchemeByName(myState.colorScheme));
}
@Override
@@ -387,13 +311,8 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Name
return scheme instanceof DefaultColorsScheme;
}
@TestOnly
public SchemesManager<EditorColorsScheme, EditorColorsSchemeImpl> getSchemesManager() {
return mySchemesManager;
}
@Override
@NotNull
public String getComponentName() {
return "EditorColorsManagerImpl";
}
}
@@ -1,29 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.editor.colors.impl;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager;
/**
* @author Roman Chernyatchik
*/
public class ReadOnlyColorsSchemeImpl extends EditorColorsSchemeImpl implements ReadOnlyColorsScheme {
public ReadOnlyColorsSchemeImpl(final EditorColorsScheme parenScheme,
final DefaultColorSchemesManager defaultColorSchemesManager) {
super(parenScheme, defaultColorSchemesManager);
}
}
@@ -18,6 +18,7 @@ package com.intellij.openapi.options;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ex.DecodeDefaultsUtil;
import com.intellij.openapi.components.RoamingType;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.StateStorageException;
@@ -27,6 +28,7 @@ import com.intellij.openapi.components.impl.stores.StorageUtil;
import com.intellij.openapi.components.impl.stores.StreamProvider;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.DocumentRunnable;
import com.intellij.openapi.extensions.AbstractExtensionPointBean;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.InvalidDataException;
@@ -41,7 +43,9 @@ import com.intellij.openapi.vfs.VirtualFileAdapter;
import com.intellij.openapi.vfs.VirtualFileEvent;
import com.intellij.openapi.vfs.tracker.VirtualFileTracker;
import com.intellij.util.SmartList;
import com.intellij.util.ThrowableConvertor;
import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.io.URLUtil;
import com.intellij.util.text.UniqueNameGenerator;
import gnu.trove.THashSet;
import org.jdom.Document;
@@ -55,6 +59,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.*;
public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme> extends AbstractSchemesManager<T, E> {
@@ -164,6 +169,23 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
}
}
public void loadBundledScheme(@NotNull String resourceName, @NotNull Object requestor, @NotNull ThrowableConvertor<Element, T, Throwable> convertor) {
try {
URL url = requestor instanceof AbstractExtensionPointBean
? (((AbstractExtensionPointBean)requestor).getLoaderForClass().getResource(resourceName))
: DecodeDefaultsUtil.getDefaults(requestor, resourceName);
if (url == null) {
// Error shouldn't occur during this operation thus we report error instead of info
LOG.error("Cannot read scheme from " + resourceName);
return;
}
addNewScheme(convertor.convert(JDOMUtil.load(URLUtil.openStream(url))), false);
}
catch (Throwable e) {
LOG.error("Cannot read scheme from " + resourceName, e);
}
}
private boolean isMy(@NotNull VirtualFileEvent event) {
return StringUtilRt.endsWithIgnoreCase(event.getFile().getNameSequence(), mySchemeExtension);
}
@@ -252,7 +252,6 @@ project.file.read.only.error.message=The project file is read-only.\nThe setting
template.project.settings.display.name=Template Project Settings
#0 - project name
project.settings.display.name=Project Settings [{0}]
options.color.schemes.presentable.name=Color schemes
options.java.attribute.descriptor.weak.warning=Weak Warning
options.java.attribute.descriptor.server.problems=Problem from server
options.java.attribute.descriptor.server.duplicate=Duplicate from server
@@ -315,4 +314,5 @@ exportable.CodeStyleSchemeSettings.presentable.name=Code Style
exportable.InspectionProfileManager.presentable.name=Inspection profiles
exportable.TodoConfiguration.presentable.name=Todo
exportable.UISettings.presentable.name=UI Settings
exportable.FileTypeManager.presentable.name=File types
exportable.FileTypeManager.presentable.name=File types
exportable.EditorColorsManager.presentable.name=Color schemes
@@ -19,6 +19,7 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.FontPreferences;
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
import com.intellij.testFramework.PlatformTestCase;
import org.jdom.Element;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
@@ -28,12 +29,14 @@ import java.io.StringWriter;
import java.util.Arrays;
import java.util.Collections;
import static com.intellij.openapi.editor.colors.FontPreferencesTest.checkState;
import static com.intellij.openapi.editor.colors.FontPreferencesTest.getAnotherExistingNonDefaultFontName;
import static com.intellij.openapi.editor.colors.FontPreferencesTest.getExistingNonDefaultFontName;
import static com.intellij.openapi.editor.colors.FontPreferencesTest.*;
public class EditorColorsSchemeImplTest extends LightPlatformCodeInsightTestCase {
EditorColorsSchemeImpl myScheme = new EditorColorsSchemeImpl(null, null);
EditorColorsSchemeImpl myScheme = new EditorColorsSchemeImpl(null);
static {
PlatformTestCase.initPlatformLangPrefix();
}
public void testDefaults() {
checkState(myScheme.getFontPreferences(),
@@ -173,7 +176,7 @@ public class EditorColorsSchemeImplTest extends LightPlatformCodeInsightTestCase
EditorColorsScheme editorColorsScheme = (EditorColorsScheme)defaultScheme.clone();
editorColorsScheme.setName("test");
Element root = new Element("scheme");
editorColorsScheme.writeExternal(root);
((AbstractColorsScheme)editorColorsScheme).writeExternal(root);
root.removeChildren("option"); // Remove font options
assertXmlOutputEquals("<scheme name=\"test\" version=\"124\" parent_scheme=\"Default\" />", root);
}
@@ -183,7 +186,7 @@ public class EditorColorsSchemeImplTest extends LightPlatformCodeInsightTestCase
EditorColorsScheme editorColorsScheme = (EditorColorsScheme)darculaScheme.clone();
editorColorsScheme.setName("test");
Element root = new Element("scheme");
editorColorsScheme.writeExternal(root);
((AbstractColorsScheme)editorColorsScheme).writeExternal(root);
root.removeChildren("option"); // Remove font options
assertXmlOutputEquals("<scheme name=\"test\" version=\"124\" parent_scheme=\"Darcula\" />", root);
}
@@ -5,17 +5,18 @@ import com.intellij.openapi.options.*;
import org.jetbrains.annotations.NotNull;
public class MockSchemesManagerFactory extends SchemesManagerFactory {
private static final SchemesManager EMPTY = new EmptySchemesManager();
@NotNull
@Override
public <T extends Scheme, E extends ExternalizableScheme> SchemesManager<T, E> createSchemesManager(@NotNull String fileSpec,
@NotNull SchemeProcessor<E> processor,
@NotNull RoamingType roamingType) {
//noinspection unchecked
return SchemesManager.EMPTY;
return EMPTY;
}
@Override
public void updateConfigFilesFromStreamProviders() {
}
}
@@ -27,8 +27,6 @@ import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.options.FontSize;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.util.containers.HashMap;
import com.jediterm.pty.PtyProcessTtyConnector;
import com.jediterm.terminal.TerminalColor;
@@ -401,11 +399,7 @@ public class JBTerminalSystemSettingsProvider extends DefaultTabbedSettingsProvi
}
@Override
public void readExternal(Element element) throws InvalidDataException {
}
@Override
public void writeExternal(Element element) throws WriteExternalException {
public void readExternal(Element element) {
}
public void updateGlobalScheme(EditorColorsScheme scheme) {