dispose child configurables when Colors and Fonts is disposed (PY-1324); handle DataC...
authorDmitry Jemerov <yole@jetbrains.com>
Tue, 14 Sep 2010 15:54:07 +0000 (19:54 +0400)
committerDmitry Jemerov <yole@jetbrains.com>
Tue, 14 Sep 2010 17:20:59 +0000 (21:20 +0400)
platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java
platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java

index f66721427ac5e5090dd0a3a406a7ec775898dfd3..4d7fe3a4ff8a61418cff4db300fed1dd2d07b9a5 100644 (file)
@@ -316,6 +316,14 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
     }
 
     result.addAll(new ArrayList<SearchableConfigurable>(mySubPanelFactories.values()));
+    for (final Configurable configurable : result) {
+      Disposer.register(myDisposable, new Disposable() {
+        @Override
+        public void dispose() {
+          configurable.disposeUIResources();
+        }
+      });
+    }
 
     return result.toArray(new Configurable[result.size()]);
   }
@@ -633,8 +641,8 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
           super.disposeUIResources();
           Disposer.dispose(myDisposable);
           if (myRootSchemesPanel != null) {
-              myRootSchemesPanel.disposeUIResources();
-            }
+            myRootSchemesPanel.disposeUIResources();
+          }
         }
         finally {
           myDisposeCompleted = true;
index 0a30f0afc92efb1c6e8042bb212b006d99e26be8..3e9d0e6f6ebaa41ce4477f027e4021ce44ecead4 100644 (file)
@@ -117,26 +117,7 @@ public class SeverityEditorDialog extends DialogWrapper {
     final JButton button = new JButton(InspectionsBundle.message("severities.default.settings.message"));
     button.addActionListener(new ActionListener(){
       public void actionPerformed(final ActionEvent e) {
-        final String toConfigure = getSelectedType().getSeverity(null).myName;
-        doOKAction();
-        myOptionsList.clearSelection();
-        ColorAndFontOptions colorAndFontOptions = ColorAndFontOptions.getColorAndFontsInstance();
-        assert colorAndFontOptions != null;
-        final SearchableConfigurable javaPage = colorAndFontOptions.findSubConfigurable(InspectionColorSettingsPage.class);
-        LOG.assertTrue(javaPage != null);
-        final OptionsEditor optionsEditor = OptionsEditor.KEY.getData(DataManager.getInstance().getDataContext());
-        if (optionsEditor != null) {
-          optionsEditor.select(javaPage).doWhenDone(new Runnable(){
-            public void run() {
-              final Runnable runnable = javaPage.enableSearch(toConfigure);
-              if (runnable != null) {
-                SwingUtilities.invokeLater(runnable);
-              }
-            }
-          });
-        } else {
-          ShowSettingsUtil.getInstance().editConfigurable(PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext()), javaPage);
-        }
+        editColorsAndFonts();
       }
     });
     disabled.add(button, new GridBagConstraints(0,0,1,1,0,0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0,0,0,0),0,0));
@@ -150,6 +131,35 @@ public class SeverityEditorDialog extends DialogWrapper {
     reset((SeverityRegistrar.SeverityBasedTextAttributes)myOptionsList.getSelectedValue());
   }
 
+  private void editColorsAndFonts() {
+    final String toConfigure = getSelectedType().getSeverity(null).myName;
+    doOKAction();
+    myOptionsList.clearSelection();
+    final DataContext dataContext = DataManager.getInstance().getDataContext(myPanel);
+    final OptionsEditor optionsEditor = OptionsEditor.KEY.getData(dataContext);
+    if (optionsEditor != null) {
+      final ColorAndFontOptions colorAndFontOptions = optionsEditor.findConfigurable(ColorAndFontOptions.class);
+      assert colorAndFontOptions != null;
+      final SearchableConfigurable javaPage = colorAndFontOptions.findSubConfigurable(InspectionColorSettingsPage.class);
+      LOG.assertTrue(javaPage != null);
+      optionsEditor.select(javaPage).doWhenDone(new Runnable(){
+        public void run() {
+          final Runnable runnable = javaPage.enableSearch(toConfigure);
+          if (runnable != null) {
+            SwingUtilities.invokeLater(runnable);
+          }
+        }
+      });
+    } else {
+      ColorAndFontOptions colorAndFontOptions = ColorAndFontOptions.getColorAndFontsInstance();
+      assert colorAndFontOptions != null;
+      final SearchableConfigurable javaPage = colorAndFontOptions.findSubConfigurable(InspectionColorSettingsPage.class);
+      LOG.assertTrue(javaPage != null);
+      ShowSettingsUtil.getInstance().editConfigurable(PlatformDataKeys.PROJECT.getData(dataContext), javaPage);
+      colorAndFontOptions.disposeUIResources();
+    }
+  }
+
   private void fillList(final HighlightSeverity severity) {
     DefaultListModel model = new DefaultListModel();
     model.removeAllElements();