mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
revert CodeStyleSettingsManager
This commit is contained in:
@@ -20,18 +20,19 @@ import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.DefaultJDOMExternalizer;
|
||||
import com.intellij.openapi.util.DifferenceFilter;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CodeStyleSettingsManager implements PersistentStateComponent<CodeStyleSettingsManager> {
|
||||
private static final Logger LOG = Logger.getInstance(CodeStyleSettingsManager.class);
|
||||
public class CodeStyleSettingsManager implements PersistentStateComponent<Element> {
|
||||
private static final Logger LOG = Logger.getInstance("#" + CodeStyleSettingsManager.class.getName());
|
||||
|
||||
public volatile CodeStyleSettings PER_PROJECT_SETTINGS = null;
|
||||
public volatile boolean USE_PER_PROJECT_SETTINGS = false;
|
||||
public volatile String PREFERRED_PROJECT_CODE_STYLE = null;
|
||||
|
||||
private volatile CodeStyleSettings myTemporarySettings;
|
||||
private volatile boolean myIsLoaded = false;
|
||||
|
||||
@@ -43,13 +44,7 @@ public class CodeStyleSettingsManager implements PersistentStateComponent<CodeSt
|
||||
if (!projectSettingsManager.isLoaded()) {
|
||||
LegacyCodeStyleSettingsManager legacySettingsManager = ServiceManager.getService(project, LegacyCodeStyleSettingsManager.class);
|
||||
if (legacySettingsManager != null && legacySettingsManager.getState() != null) {
|
||||
try {
|
||||
//noinspection deprecation
|
||||
DefaultJDOMExternalizer.readExternal(projectSettingsManager, legacySettingsManager.getState());
|
||||
}
|
||||
catch (InvalidDataException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
projectSettingsManager.loadState(legacySettingsManager.getState());
|
||||
LOG.info("Imported old project code style settings.");
|
||||
}
|
||||
}
|
||||
@@ -81,21 +76,42 @@ public class CodeStyleSettingsManager implements PersistentStateComponent<CodeSt
|
||||
return CodeStyleSchemes.getInstance().findPreferredScheme(PREFERRED_PROJECT_CODE_STYLE).getCodeStyleSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeStyleSettingsManager getState() {
|
||||
return this;
|
||||
private void readExternal(Element element) throws InvalidDataException {
|
||||
DefaultJDOMExternalizer.readExternal(this, element);
|
||||
}
|
||||
|
||||
private void writeExternal(Element element) throws WriteExternalException {
|
||||
DefaultJDOMExternalizer.writeExternal(this, element, new DifferenceFilter<CodeStyleSettingsManager>(this, new CodeStyleSettingsManager()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(CodeStyleSettingsManager state) {
|
||||
XmlSerializerUtil.copyBean(state, this);
|
||||
public Element getState() {
|
||||
Element result = new Element("state");
|
||||
try {
|
||||
writeExternal(result);
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(Element state) {
|
||||
try {
|
||||
readExternal(state);
|
||||
myIsLoaded = true;
|
||||
}
|
||||
catch (InvalidDataException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public CodeStyleSettings getTemporarySettings() {
|
||||
return myTemporarySettings;
|
||||
}
|
||||
|
||||
public void setTemporarySettings(CodeStyleSettings settings) {
|
||||
public void setTemporarySettings(@NotNull CodeStyleSettings settings) {
|
||||
myTemporarySettings = settings;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user