Changed the loader to pull *.rkt files from zip containers.
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Wed, 1 Aug 2012 19:25:50 +0000 (19:25 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Wed, 1 Aug 2012 19:25:50 +0000 (19:25 +0000)
Modified the BasicFrame so it doesn't automatically open the Rocket configuration dialog when opening a new rocket.
Unified the behavior for replacing (automatically closing) the base frame when opening a file, loading an example, or picking from the Most-recently-used list.

git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@948 180e2498-e6e9-4542-8430-84ac67f01cd8

core/ChangeLog
core/src/net/sf/openrocket/file/GeneralRocketLoader.java
core/src/net/sf/openrocket/gui/main/BasicFrame.java

index 4a54dba6b3d0979b79f00b11a29b6fb7bc4ee7e5..87738415eca73f3d0c550eed155bc390ee54156d 100644 (file)
@@ -1,3 +1,12 @@
+2012-08-01 Kevin Ruland
+
+   * Changed the loader to pull *.rkt files from zip containers.
+   
+   * Modified the BasicFrame so it doesn't automatically open the Rocket configuration dialog when opening a new rocket.
+   
+   * Unified the behavior for replacing (automatically closing) the base frame when opening a file, loading an example,
+   or picking from the Most-recently-used list.
+
 2012-07-31 Kevin Ruland
 
    * Changed the ORK file format to save "keys" for materials and flight data as well as the localized
index f4b64622949bdf865ce3959d7dccbd7803c4c077..da6858d89cb912f9e424a172c79ccc6b7cbc71d9 100644 (file)
@@ -78,6 +78,9 @@ public class GeneralRocketLoader extends AbstractRocketLoader {
                                        OpenRocketDocument doc = loadFromStream(in, motorFinder);
                                        doc.getDefaultStorageOptions().setCompressionEnabled(true);
                                        return doc;
+                               } else if ( entry.getName().matches(".*\\.[rR][kK][tT]$")) {
+                                       OpenRocketDocument doc = loadFromStream(in, motorFinder);
+                                       return doc;
                                }
                        }
                }
index cfbfec2cec8f0e5440327134ada5c9ea7f414344..9f758c347a5d971150561eab92cc7f476ef53142 100644 (file)
@@ -165,17 +165,6 @@ public class BasicFrame extends JFrame {
                this.rocket = document.getRocket();
                this.rocket.getDefaultConfiguration().setAllStages();
 
-
-               // Set replaceable flag to false at first modification
-               rocket.addComponentChangeListener(new ComponentChangeListener() {
-                       @Override
-                       public void componentChanged(ComponentChangeEvent e) {
-                               replaceable = false;
-                               BasicFrame.this.rocket.removeComponentChangeListener(this);
-                       }
-               });
-
-
                // Create the component tree selection model that will be used
                componentSelectionModel = new DefaultTreeSelectionModel();
                componentSelectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
@@ -417,10 +406,7 @@ public class BasicFrame extends JFrame {
                        public void actionPerformed(ActionEvent e) {
                                log.user("New... selected");
                                newAction();
-                               if (replaceable) {
-                                       log.info("Closing previous window");
-                                       closeAction();
-                               }
+                               closeIfReplaceable();
                        }
                });
                menu.add(item);
@@ -1045,23 +1031,24 @@ public class BasicFrame extends JFrame {
                for (File file : files) {
                        log.info("Opening file: " + file);
                        if (open(file, this)) {
-
-                               // Close previous window if replacing
-                               if (replaceable && document.isSaved()) {
-                                       // We are replacing the frame, make new window have current location
-                                       BasicFrame newFrame = frames.get(frames.size() - 1);
-                                       newFrame.setLocation(this.getLocation());
-
-                                       log.info("Closing window because it is replaceable");
-                                       closeAction();
-                                       replaceable = false;
-                               }
                 MRUDesignFile opts = MRUDesignFile.getInstance();
                 opts.addFile(file.getAbsolutePath());
                        }
                }
        }
 
+       void closeIfReplaceable() {
+               // Close previous window if replacing
+               if (replaceable && document.isSaved()) {
+                       // We are replacing the frame, make new window have current location
+                       BasicFrame newFrame = frames.get(frames.size() - 1);
+                       newFrame.setLocation(this.getLocation());
+
+                       log.info("Closing window because it is replaceable");
+                       closeAction();
+               }
+               
+       }
        /**
         * Open a file based on a URL.
         * @param url           the file to open.
@@ -1103,13 +1090,7 @@ public class BasicFrame extends JFrame {
                log.info("Opening file from url=" + url + " filename=" + filename);
                try {
                        InputStream is = url.openStream();
-                       if (open(is, filename, parent)) {
-                               // Close previous window if replacing
-                               if (parent.replaceable && parent.document.isSaved()) {
-                                       parent.closeAction();
-                                       parent.replaceable = false;
-                               }
-                       }
+                       open(is, filename, parent);
                } catch (IOException e) {
                        log.warn("Error opening file" + e);
                        JOptionPane.showMessageDialog(parent,
@@ -1240,6 +1221,9 @@ public class BasicFrame extends JFrame {
                BasicFrame frame = new BasicFrame(doc);
                frame.setVisible(true);
 
+               if ( parent != null && parent instanceof BasicFrame ) {
+                       ((BasicFrame)parent).closeIfReplaceable();
+               }
                return true;
        }
 
@@ -1473,7 +1457,8 @@ public class BasicFrame extends JFrame {
                BasicFrame frame = new BasicFrame(doc);
                frame.replaceable = true;
                frame.setVisible(true);
-               ComponentConfigDialog.showDialog(frame, doc, rocket);
+               // FIXME - kruland commented this out - I don't like it.
+               //ComponentConfigDialog.showDialog(frame, doc, rocket);
        }
 
        /**