]> git.gag.com Git - debian/openrocket/blobdiff - src/net/sf/openrocket/gui/configdialog/ComponentConfigDialog.java
SafetyMutex and rocket optimization updates
[debian/openrocket] / src / net / sf / openrocket / gui / configdialog / ComponentConfigDialog.java
index e37d80ee93b4f9d612f6b0876dab8cae8c722bb7..4b4db2d8b05f4bb9208dfb052ae13b873c951767 100644 (file)
@@ -109,7 +109,7 @@ public class ComponentConfigDialog extends JDialog implements ComponentChangeLis
                                findDialogContentsConstructor(component);
                if (c != null) {
                        try {
-                               return (RocketComponentConfig) c.newInstance(component);
+                               return c.newInstance(component);
                        } catch (InstantiationException e) {
                                throw new BugException("BUG in constructor reflection", e);
                        } catch (IllegalAccessException e) {
@@ -124,6 +124,34 @@ public class ComponentConfigDialog extends JDialog implements ComponentChangeLis
                throw new BugException("Unable to find any configurator for " + component);
        }
        
+       
+       private void closeDialog() {
+               this.setVisible(false);
+               this.dispose();
+               this.configurator.invalidateModels();
+       }
+       
+       
+       @Override
+       public void componentChanged(ComponentChangeEvent e) {
+               if (e.isTreeChange() || e.isUndoChange()) {
+                       
+                       // Hide dialog in case of tree or undo change
+                       dialog.closeDialog();
+                       
+               } else {
+                       /*
+                        * TODO: HIGH:  The line below has caused a NullPointerException (without null check)
+                        * How is this possible?  The null check was added to avoid this, but the
+                        * root cause should be analyzed.
+                        * [Openrocket-bugs] 2009-12-12 19:23:22 Automatic bug report for OpenRocket 0.9.5
+                        */
+                       if (configurator != null)
+                               configurator.updateFields();
+               }
+       }
+       
+       
        /**
         * Finds the Constructor of the given component's config dialog panel in 
         * CONFIGDIALOGPACKAGE.
@@ -192,8 +220,9 @@ public class ComponentConfigDialog extends JDialog implements ComponentChangeLis
         * Hides the configuration dialog.  May be used even if not currently visible.
         */
        public static void hideDialog() {
-               if (dialog != null)
-                       dialog.setVisible(false);
+               if (dialog != null) {
+                       dialog.closeDialog();
+               }
        }
        
        
@@ -225,23 +254,4 @@ public class ComponentConfigDialog extends JDialog implements ComponentChangeLis
                return (dialog != null) && (dialog.isVisible());
        }
        
-       
-       public void componentChanged(ComponentChangeEvent e) {
-               if (e.isTreeChange() || e.isUndoChange()) {
-                       
-                       // Hide dialog in case of tree or undo change
-                       dialog.setVisible(false);
-                       
-               } else {
-                       /*
-                        * TODO: HIGH:  The line below has caused a NullPointerException (without null check)
-                        * How is this possible?  The null check was added to avoid this, but the
-                        * root cause should be analyzed.
-                        * [Openrocket-bugs] 2009-12-12 19:23:22 Automatic bug report for OpenRocket 0.9.5
-                        */
-                       if (configurator != null)
-                               configurator.updateFields();
-               }
-       }
-       
 }