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 c45acb38add3..5d7ae51e43e9 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 @@ -1067,10 +1067,10 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract } public void apply(EditorColorsScheme scheme) { - getFontPreferences().copyTo(scheme.getFontPreferences()); + scheme.setFontPreferences(getFontPreferences()); scheme.setLineSpacing(myLineSpacing); scheme.setQuickDocFontSize(getQuickDocFontSize()); - getConsoleFontPreferences().copyTo(scheme.getConsoleFontPreferences()); + scheme.setConsoleFontPreferences(getConsoleFontPreferences()); scheme.setConsoleLineSpacing(getConsoleLineSpacing()); for (EditorSchemeAttributeDescriptor descriptor : myDescriptors) { diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java b/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java index d0e32bc0e239..d21e26e750b7 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java @@ -54,6 +54,7 @@ public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, Schem */ @NotNull FontPreferences getFontPreferences(); + void setFontPreferences(@NotNull FontPreferences preferences); String getEditorFontName(); void setEditorFontName(String fontName); @@ -78,6 +79,7 @@ public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, Schem */ @NotNull FontPreferences getConsoleFontPreferences(); + void setConsoleFontPreferences(@NotNull FontPreferences preferences); String getConsoleFontName(); void setConsoleFontName(String fontName); diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java b/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java index 73d1b8f4b991..2d88151f088e 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java @@ -44,21 +44,33 @@ public class FontPreferences { @NotNull private final TObjectIntHashMap myFontSizes = new TObjectIntHashMap(); @NotNull private final List myEffectiveFontFamilies = ContainerUtilRt.newArrayList(); @NotNull private final List myRealFontFamilies = ContainerUtilRt.newArrayList(); + + @Nullable Runnable myChangeListener; /** * Font size to use by default. Default value is {@link #DEFAULT_FONT_SIZE}. */ private int myTemplateFontSize = DEFAULT_FONT_SIZE; - + + public void setChangeListener(@Nullable Runnable changeListener) { + myChangeListener = changeListener; + } + public void clear() { myEffectiveFontFamilies.clear(); myRealFontFamilies.clear(); myFontSizes.clear(); + if (myChangeListener != null) { + myChangeListener.run(); + } } public void clearFonts() { myEffectiveFontFamilies.clear(); myRealFontFamilies.clear(); + if (myChangeListener != null) { + myChangeListener.run(); + } } public boolean hasSize(@NotNull String fontName) { @@ -76,6 +88,9 @@ public class FontPreferences { public void setSize(@NotNull String fontFamily, int size) { myFontSizes.put(fontFamily, size); myTemplateFontSize = size; + if (myChangeListener != null) { + myChangeListener.run(); + } } /** @@ -132,6 +147,9 @@ public class FontPreferences { if (!myEffectiveFontFamilies.contains(effectiveFontFamily)) { myEffectiveFontFamilies.add(effectiveFontFamily); } + if (myChangeListener != null) { + myChangeListener.run(); + } } public void copyTo(@NotNull final FontPreferences preferences) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java index d41e826c268c..b446df31d6a4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java @@ -90,6 +90,12 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { protected AbstractColorsScheme(EditorColorsScheme parentScheme, DefaultColorSchemesManager defaultColorSchemesManager) { myParentScheme = parentScheme; myDefaultColorSchemesManager = defaultColorSchemesManager; + myFontPreferences.setChangeListener(new Runnable() { + @Override + public void run() { + initFonts(); + } + }); } public AbstractColorsScheme(DefaultColorSchemesManager defaultColorSchemesManager) { @@ -179,7 +185,13 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { public FontPreferences getFontPreferences() { return myFontPreferences; } - + + @Override + public void setFontPreferences(@NotNull FontPreferences preferences) { + preferences.copyTo(myFontPreferences); + initFonts(); + } + @Override public String getEditorFontName() { if (myFallbackFontName != null) { @@ -581,7 +593,13 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { public FontPreferences getConsoleFontPreferences() { return myConsoleFontPreferences; } - + + @Override + public void setConsoleFontPreferences(@NotNull FontPreferences preferences) { + preferences.copyTo(myConsoleFontPreferences); + initFonts(); + } + @Override public String getConsoleFontName() { return myConsoleFontPreferences.getFontFamily(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java index 1e0b2e285007..663b84789653 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java @@ -84,6 +84,11 @@ public abstract class DelegateColorScheme implements EditorColorsScheme { return myDelegate.getFontPreferences(); } + @Override + public void setFontPreferences(@NotNull FontPreferences preferences) { + myDelegate.setFontPreferences(preferences); + } + @Override public int getEditorFontSize() { return myDelegate.getEditorFontSize(); @@ -158,6 +163,11 @@ public abstract class DelegateColorScheme implements EditorColorsScheme { return myDelegate.getConsoleFontPreferences(); } + @Override + public void setConsoleFontPreferences(@NotNull FontPreferences preferences) { + myDelegate.setConsoleFontPreferences(preferences); + } + @Override public String getConsoleFontName() { return myDelegate.getConsoleFontName(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 09e75b3f70f2..9f76d6a6a943 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -5684,7 +5684,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi private class MyColorSchemeDelegate implements EditorColorsScheme { - private final FontPreferences myFontPreferences = new FontPreferences(); + private final FontPreferences myFontPreferences = new FontPreferences(); private final Map myOwnAttributes = ContainerUtilRt.newHashMap(); private final Map myOwnColors = ContainerUtilRt.newHashMap(); private final EditorColorsScheme myCustomGlobalScheme; @@ -5807,6 +5807,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi return myFontPreferences.getEffectiveFontFamilies().isEmpty() ? getGlobal().getFontPreferences() : myFontPreferences; } + @Override + public void setFontPreferences(@NotNull FontPreferences preferences) { + preferences.copyTo(myFontPreferences); + initFonts(); + } + @Override public String getEditorFontName() { if (myFaceName == null) { @@ -5874,7 +5880,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi public FontPreferences getConsoleFontPreferences() { return getGlobal().getConsoleFontPreferences(); } - + + @Override + public void setConsoleFontPreferences(@NotNull FontPreferences preferences) { + getGlobal().setConsoleFontPreferences(preferences); + } + @Override public String getConsoleFontName() { return getGlobal().getConsoleFontName();