ability to load colors as well as text attributes

This commit is contained in:
Gregory.Shrago
2019-02-20 15:11:38 +03:00
parent 93dcb8b5e3
commit b4e6ecac2e
2 changed files with 11 additions and 2 deletions
@@ -412,7 +412,7 @@ public abstract class AbstractColorsScheme extends EditorFontCacheImpl implement
}
}
private void readColors(Element childNode) {
public void readColors(@NotNull Element childNode) {
for (Element colorElement : childNode.getChildren(OPTION_ELEMENT)) {
String keyName = colorElement.getAttributeValue(NAME_ATTR);
Color valueColor = myValueReader.read(Color.class, colorElement);
@@ -38,9 +38,11 @@ import com.intellij.psi.PsiManager;
import com.intellij.psi.impl.PsiModificationTrackerImpl;
import com.intellij.util.ComponentTreeEventDispatcher;
import com.intellij.util.JdomKt;
import com.intellij.util.ObjectUtils;
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.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -314,7 +316,14 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Pers
continue;
}
try {
((AbstractColorsScheme)editorColorsScheme).readAttributes(JdomKt.loadElement(URLUtil.openStream(resource)));
Element root = JdomKt.loadElement(URLUtil.openStream(resource));
Element attrs = ObjectUtils.notNull(root.getChild("attributes"), root);
Element colors = root.getChild("colors");
AbstractColorsScheme scheme = (AbstractColorsScheme)editorColorsScheme;
scheme.readAttributes(attrs);
if (colors != null) {
scheme.readColors(colors);
}
}
catch (Exception e) {
LOG.error(e);