From 944eef001b31c84f4d87c6bdfb72c4e7c91ea515 Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Wed, 26 Dec 2012 18:27:01 +0400 Subject: [PATCH] Uncheck color selection boxes if colors are equal to base (fallback) attributes, reset the attributes to restore color inheritance. --- .../openapi/editor/markup/TextAttributes.java | 7 ++++ .../options/colors/ColorAndFontOptions.java | 36 ++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) 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 f5701b208f06..12c65bdf1626 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 @@ -162,6 +162,13 @@ public class TextAttributes implements JDOMExternalizable, Cloneable { return getForegroundColor() == null && getBackgroundColor() == null && getEffectColor() == null && getFontType() == Font.PLAIN; } + public void reset() { + setForegroundColor(null); + setBackgroundColor(null); + setEffectColor(null); + setFontType(Font.PLAIN); + } + @NotNull public AttributesFlyweight getFlyweight() { return myAttrs; 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 2298d142773a..edf09caa8b19 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 @@ -790,10 +790,44 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract return attributes; } + private boolean equalToFallbackAttributes() { + if (myFallbackAttributes != null) { + return myFallbackAttributes.equals(getTextAttributes()); + } + return false; + } + + @Override + public boolean isBackgroundChecked() { + if (equalToFallbackAttributes()) return false; + return super.isBackgroundChecked(); + } + + @Override + public boolean isForegroundChecked() { + if (equalToFallbackAttributes()) return false; + return super.isForegroundChecked(); + } + + @Override + public boolean isErrorStripeChecked() { + if (equalToFallbackAttributes()) return false; + return super.isErrorStripeChecked(); + } + + @Override + public boolean isEffectsColorChecked() { + if (equalToFallbackAttributes()) return false; + return super.isEffectsColorChecked(); + } + @Override public void apply(EditorColorsScheme scheme) { if (scheme == null) scheme = getScheme(); - if (myAttributesToApply != null && !getTextAttributes().equals(myFallbackAttributes)) { + if (myAttributesToApply != null) { + if (equalToFallbackAttributes()) { + getTextAttributes().reset(); + } scheme.setAttributes(key, getTextAttributes()); } }