From 9965d8e51e2407e025f9c8e4cc8b2d2b06009975 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 20 Feb 2015 17:06:44 +0100 Subject: [PATCH] IDEA-136776 As of 14.1 IDEA Color & Font theme resets after every restart to default --- .../openapi/editor/markup/TextAttributes.java | 24 +- .../openapi/options/SchemesManager.java | 87 ++----- .../options/AbstractSchemesManager.java | 2 +- .../openapi/options/EmptySchemesManager.java | 78 ++++++ .../editor/colors/EditorColorsScheme.java | 6 +- .../colors/ex/DefaultColorSchemesManager.java | 10 +- .../colors/impl/AbstractColorsScheme.java | 136 +++++----- .../colors/impl/DefaultColorsScheme.java | 11 +- .../colors/impl/EditorColorsSchemeImpl.java | 8 +- .../usageView/UsageTreeColorsScheme.java | 6 +- .../options/colors/ColorAndFontOptions.java | 4 +- .../actionSystem/ex/QuickListsManager.java | 23 +- .../colors/impl/DelegateColorScheme.java | 9 +- .../colors/impl/EditorColorsManagerImpl.java | 243 ++++++------------ .../colors/impl/ReadOnlyColorsSchemeImpl.java | 29 --- .../openapi/options/SchemesManagerImpl.java | 22 ++ .../src/messages/OptionsBundle.properties | 4 +- .../impl/EditorColorsSchemeImplTest.java | 15 +- .../MockSchemesManagerFactory.java | 5 +- .../JBTerminalSystemSettingsProvider.java | 8 +- 20 files changed, 318 insertions(+), 412 deletions(-) create mode 100644 platform/core-impl/src/com/intellij/openapi/options/EmptySchemesManager.java delete mode 100644 platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/ReadOnlyColorsSchemeImpl.java diff --git a/platform/core-api/src/com/intellij/openapi/editor/markup/TextAttributes.java b/platform/core-api/src/com/intellij/openapi/editor/markup/TextAttributes.java index c9d4bd59ec59..bd98d77dd987 100644 --- a/platform/core-api/src/com/intellij/openapi/editor/markup/TextAttributes.java +++ b/platform/core-api/src/com/intellij/openapi/editor/markup/TextAttributes.java @@ -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); } diff --git a/platform/core-api/src/com/intellij/openapi/options/SchemesManager.java b/platform/core-api/src/com/intellij/openapi/options/SchemesManager.java index cef94aefcc06..c085400d9465 100644 --- a/platform/core-api/src/com/intellij/openapi/options/SchemesManager.java +++ b/platform/core-api/src/com/intellij/openapi/options/SchemesManager.java @@ -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 { - SchemesManager EMPTY = new SchemesManager(){ - @Override - @NotNull - public Collection loadSchemes() { - return Collections.emptySet(); - } +public abstract class SchemesManager { + @NotNull + public abstract Collection 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 loadSchemes(); - - void addNewScheme(@NotNull T scheme, final boolean replaceExisting); - - void clearAllSchemes(); - - @NotNull - List getAllSchemes(); + public abstract List 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 getAllSchemeNames(); + public abstract Collection getAllSchemeNames(); - File getRootDirectory(); + public abstract File getRootDirectory(); + + public void loadBundledScheme(@NotNull String resourceName, @NotNull Object requestor, @NotNull ThrowableConvertor convertor) { + } } diff --git a/platform/core-impl/src/com/intellij/openapi/options/AbstractSchemesManager.java b/platform/core-impl/src/com/intellij/openapi/options/AbstractSchemesManager.java index d4f3f707d4e6..14f3b057a5fc 100644 --- a/platform/core-impl/src/com/intellij/openapi/options/AbstractSchemesManager.java +++ b/platform/core-impl/src/com/intellij/openapi/options/AbstractSchemesManager.java @@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; -public abstract class AbstractSchemesManager implements SchemesManager { +public abstract class AbstractSchemesManager extends SchemesManager { private static final Logger LOG = Logger.getInstance(AbstractSchemesManager.class); protected final List mySchemes = new ArrayList(); diff --git a/platform/core-impl/src/com/intellij/openapi/options/EmptySchemesManager.java b/platform/core-impl/src/com/intellij/openapi/options/EmptySchemesManager.java new file mode 100644 index 000000000000..55a74d08ebd1 --- /dev/null +++ b/platform/core-impl/src/com/intellij/openapi/options/EmptySchemesManager.java @@ -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; + } +} diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java index d19658d588fb..085fecc6fae2 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java @@ -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); } diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/ex/DefaultColorSchemesManager.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/ex/DefaultColorSchemesManager.java index bd90843372ea..4940473bc740 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/ex/DefaultColorSchemesManager.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/ex/DefaultColorSchemesManager.java @@ -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 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 { diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java index 7c907d1c607b..31ab7469b217 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java @@ -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; } - } diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java index 1fc6e1fa4f06..16c3592092a2 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java @@ -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; diff --git a/platform/lang-api/src/com/intellij/usageView/UsageTreeColorsScheme.java b/platform/lang-api/src/com/intellij/usageView/UsageTreeColorsScheme.java index e9e72103f612..5eb526877ba6 100644 --- a/platform/lang-api/src/com/intellij/usageView/UsageTreeColorsScheme.java +++ b/platform/lang-api/src/com/intellij/usageView/UsageTreeColorsScheme.java @@ -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); } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java index dff0a5c4eac8..bda2aab689ba 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java @@ -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()); diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickListsManager.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickListsManager.java index 4547726a4834..9dda8602f086 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickListsManager.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickListsManager.java @@ -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() { + @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(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java index 1089d5e54e3e..01fe0814f2c3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java @@ -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); } - } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java index 1421aef3e99c..e4a8a78c5698 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java @@ -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 { private static final Logger LOG = Logger.getInstance(EditorColorsManagerImpl.class); - private final EventDispatcher 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 myListeners = EventDispatcher.create(EditorColorsListener.class); + private final DefaultColorSchemesManager myDefaultColorSchemesManager; private final SchemesManager 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() { @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() { + @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 getSchemesManager() { return mySchemesManager; } - - @Override - @NotNull - public String getComponentName() { - return "EditorColorsManagerImpl"; - } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/ReadOnlyColorsSchemeImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/ReadOnlyColorsSchemeImpl.java deleted file mode 100644 index f7a777edb96f..000000000000 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/ReadOnlyColorsSchemeImpl.java +++ /dev/null @@ -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); - } -} diff --git a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java index 58bf8e6ecb64..03714165fa24 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java @@ -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 extends AbstractSchemesManager { @@ -164,6 +169,23 @@ public class SchemesManagerImpl 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); } diff --git a/platform/platform-resources-en/src/messages/OptionsBundle.properties b/platform/platform-resources-en/src/messages/OptionsBundle.properties index 761cb2400667..4972ee89de88 100644 --- a/platform/platform-resources-en/src/messages/OptionsBundle.properties +++ b/platform/platform-resources-en/src/messages/OptionsBundle.properties @@ -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 \ No newline at end of file +exportable.FileTypeManager.presentable.name=File types +exportable.EditorColorsManager.presentable.name=Color schemes \ No newline at end of file diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImplTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImplTest.java index 675f6715f201..348dc0d94bfc 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImplTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImplTest.java @@ -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("", 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("", root); } diff --git a/platform/testFramework/src/com/intellij/testFramework/MockSchemesManagerFactory.java b/platform/testFramework/src/com/intellij/testFramework/MockSchemesManagerFactory.java index 370465f3f994..967beebc2078 100644 --- a/platform/testFramework/src/com/intellij/testFramework/MockSchemesManagerFactory.java +++ b/platform/testFramework/src/com/intellij/testFramework/MockSchemesManagerFactory.java @@ -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 SchemesManager createSchemesManager(@NotNull String fileSpec, @NotNull SchemeProcessor processor, @NotNull RoamingType roamingType) { //noinspection unchecked - return SchemesManager.EMPTY; + return EMPTY; } @Override public void updateConfigFilesFromStreamProviders() { - } } diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java index f388d9d931f6..0f19c66153e5 100644 --- a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java +++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java @@ -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) {