From a8c028a93bce10c7350a8bb17407f160deb98acb Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Wed, 17 Oct 2012 22:40:17 +0400 Subject: [PATCH] fix applying of predefined style when code style configurable is wrapped in a tab --- .../options/CodeStyleAbstractConfigurable.java | 10 ++++++---- .../options/TabbedLanguageCodeStylePanel.java | 11 ++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractConfigurable.java index 793790b0c7bd..58662d694d9b 100644 --- a/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractConfigurable.java +++ b/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractConfigurable.java @@ -62,14 +62,16 @@ public abstract class CodeStyleAbstractConfigurable implements Configurable, Opt @Override public void reset() { - if (myPanel != null) { - myPanel.reset(mySettings); - } + reset(mySettings); } public void resetFromClone(){ + reset(myCloneSettings); + } + + public void reset(CodeStyleSettings settings) { if (myPanel != null) { - myPanel.reset(myCloneSettings); + myPanel.reset(settings); } } diff --git a/platform/lang-impl/src/com/intellij/application/options/TabbedLanguageCodeStylePanel.java b/platform/lang-impl/src/com/intellij/application/options/TabbedLanguageCodeStylePanel.java index 35a2ba0a6a00..207e393d40c6 100644 --- a/platform/lang-impl/src/com/intellij/application/options/TabbedLanguageCodeStylePanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/TabbedLanguageCodeStylePanel.java @@ -541,7 +541,16 @@ public abstract class TabbedLanguageCodeStylePanel extends CodeStyleAbstractPane @Override protected void resetImpl(CodeStyleSettings settings) { - myConfigurable.reset(); + if (myConfigurable instanceof CodeStyleAbstractConfigurable) { + // when a predefined style is chosen and the configurable is wrapped in a tab, + // we apply it to CLONED code style settings and then pass them to this method to reset, + // usual reset() won't work in such case + ((CodeStyleAbstractConfigurable)myConfigurable).reset(settings); + } + else { + // todo: support for other configurables + myConfigurable.reset(); + } } }