Skip to content

Commit

Permalink
Use separate class to store xml folding settings state
Browse files Browse the repository at this point in the history
this is required for proper merging Css and Xml folding settings
  • Loading branch information
zolotov committed Jul 8, 2016
1 parent 1c8b706 commit ebbe04b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2016 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.
Expand All @@ -23,9 +23,9 @@
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.options.BeanConfigurable;

public class XmlCodeFoldingOptionsProvider extends BeanConfigurable<XmlFoldingSettings> implements CodeFoldingOptionsProvider {
public class XmlCodeFoldingOptionsProvider extends BeanConfigurable<XmlFoldingSettings.State> implements CodeFoldingOptionsProvider {
public XmlCodeFoldingOptionsProvider() {
super(XmlFoldingSettings.getInstance());
super(XmlFoldingSettings.getInstance().getState());
checkBox("COLLAPSE_XML_TAGS", ApplicationBundle.message("checkbox.collapse.xml.tags"));
checkBox("COLLAPSE_HTML_STYLE_ATTRIBUTE", ApplicationBundle.message("checkbox.collapse.html.style.attribute"));
checkBox("COLLAPSE_ENTITIES", ApplicationBundle.message("checkbox.collapse.entities"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,54 +20,42 @@
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil;

@State(
name = "XmlFoldingSettings",
storages = @Storage("editor.codeinsight.xml")
)
public class XmlFoldingSettings implements XmlCodeFoldingSettings, PersistentStateComponent<XmlFoldingSettings> {
@State(name = "XmlFoldingSettings", storages = @Storage("editor.codeinsight.xml"))
public class XmlFoldingSettings implements XmlCodeFoldingSettings, PersistentStateComponent<XmlFoldingSettings.State> {
private XmlFoldingSettings.State myState;

public static XmlFoldingSettings getInstance() {
return ServiceManager.getService(XmlFoldingSettings.class);
}

@Override
public boolean isCollapseXmlTags() {
return COLLAPSE_XML_TAGS;
}

public void setCollapseXmlTags(boolean value) {
COLLAPSE_XML_TAGS = value;
return myState.COLLAPSE_XML_TAGS;
}

@Override
public boolean isCollapseHtmlStyleAttribute() {
return COLLAPSE_HTML_STYLE_ATTRIBUTE;
return myState.COLLAPSE_HTML_STYLE_ATTRIBUTE;
}

public boolean isCollapseEntities() {
return COLLAPSE_ENTITIES;
}

public void setCollapseEntities(boolean COLLAPSE_ENTITIES) {
this.COLLAPSE_ENTITIES = COLLAPSE_ENTITIES;
return myState.COLLAPSE_ENTITIES;
}

public void setCollapseHtmlStyleAttribute(boolean value) {
this.COLLAPSE_HTML_STYLE_ATTRIBUTE = value;
@Override
public State getState() {
return myState;
}

@SuppressWarnings({"WeakerAccess"}) public boolean COLLAPSE_XML_TAGS = false;
@SuppressWarnings({"WeakerAccess"}) public boolean COLLAPSE_HTML_STYLE_ATTRIBUTE = true;
@SuppressWarnings({"WeakerAccess"}) public boolean COLLAPSE_ENTITIES = true;

@Override
public XmlFoldingSettings getState() {
return this;
public void loadState(State state) {
myState = state;
}

@Override
public void loadState(final XmlFoldingSettings state) {
XmlSerializerUtil.copyBean(state, this);
public static final class State {
public boolean COLLAPSE_XML_TAGS = false;
public boolean COLLAPSE_HTML_STYLE_ATTRIBUTE = true;
public boolean COLLAPSE_ENTITIES = true;
}
}

0 comments on commit ebbe04b

Please sign in to comment.