mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DefaultColorSchemesManager — avoid use WriteExternalException to cancel write
This commit is contained in:
+20
-25
@@ -15,34 +15,25 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.colors.ex;
|
||||
|
||||
import com.intellij.openapi.components.NamedComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
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 com.intellij.openapi.util.JDOMExternalizable;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class DefaultColorSchemesManager implements JDOMExternalizable, NamedComponent {
|
||||
@State(
|
||||
name = "DefaultColorSchemesManager",
|
||||
storages = @Storage(file = StoragePathMacros.APP_CONFIG + "/other.xml")
|
||||
)
|
||||
public class DefaultColorSchemesManager implements PersistentStateComponent<Element> {
|
||||
private final List<DefaultColorsScheme> mySchemes;
|
||||
@NonNls private static final String SCHEME_ELEMENT = "scheme";
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "DefaultColorSchemesManager";
|
||||
}
|
||||
|
||||
public DefaultColorSchemesManager() {
|
||||
mySchemes = new ArrayList<DefaultColorsScheme>();
|
||||
}
|
||||
@@ -51,20 +42,24 @@ public class DefaultColorSchemesManager implements JDOMExternalizable, NamedComp
|
||||
return ServiceManager.getService(DefaultColorSchemesManager.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
List schemes = element.getChildren(SCHEME_ELEMENT);
|
||||
for (Object scheme : schemes) {
|
||||
Element schemeElement = (Element)scheme;
|
||||
DefaultColorsScheme newScheme = new DefaultColorsScheme(this);
|
||||
newScheme.readExternal(schemeElement);
|
||||
mySchemes.add(newScheme);
|
||||
}
|
||||
public Element getState() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
throw new WriteExternalException();
|
||||
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);
|
||||
}
|
||||
mySchemes.add(newScheme);
|
||||
}
|
||||
}
|
||||
|
||||
public DefaultColorsScheme[] getAllSchemes() {
|
||||
|
||||
@@ -139,8 +139,7 @@
|
||||
<applicationService serviceInterface="com.intellij.openapi.options.SchemesManagerFactory"
|
||||
serviceImplementation="com.intellij.openapi.options.SchemesManagerFactoryImpl"/>
|
||||
|
||||
<applicationService serviceInterface="com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager"
|
||||
serviceImplementation="com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager"/>
|
||||
<applicationService serviceImplementation="com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager"/>
|
||||
<applicationService serviceInterface="com.intellij.openapi.editor.colors.TextAttributesKey$TextAttributeKeyDefaultsProvider"
|
||||
serviceImplementation="com.intellij.openapi.editor.colors.impl.TextAttributeKeyDefaultsProviderImpl"/>
|
||||
<applicationService serviceInterface="com.intellij.openapi.editor.colors.EditorColorsManager"
|
||||
|
||||
Reference in New Issue
Block a user