import net.sf.openrocket.file.rocksim.export.RocksimSaver;
import net.sf.openrocket.gui.StorageOptionChooser;
import net.sf.openrocket.gui.configdialog.ComponentConfigDialog;
+import net.sf.openrocket.gui.customexpression.CustomExpressionDialog;
import net.sf.openrocket.gui.dialogs.AboutDialog;
import net.sf.openrocket.gui.dialogs.BugReportDialog;
import net.sf.openrocket.gui.dialogs.ComponentAnalysisDialog;
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);
public void actionPerformed(ActionEvent e) {
log.user("New... selected");
newAction();
- if (replaceable) {
- log.info("Closing previous window");
- closeAction();
- }
+ closeIfReplaceable();
}
});
menu.add(item);
});
menu.add(item);
-
+ //// Optimize
item = new JMenuItem(trans.get("main.menu.analyze.optimization"), KeyEvent.VK_O);
item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.analyze.optimization.desc"));
item.addActionListener(new ActionListener() {
});
menu.add(item);
-
+ //// Custom expressions
+ item = new JMenuItem(trans.get("main.menu.analyze.customExpressions"), KeyEvent.VK_E);
+ item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.analyze.customExpressions.desc"));
+ item.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ log.debug("Custom expressions selected");
+ new CustomExpressionDialog(document, BasicFrame.this).setVisible(true);
+ }
+ });
+ menu.add(item);
//// Debug
// (shown if openrocket.debug.menu is defined)
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.
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,
BasicFrame frame = new BasicFrame(doc);
frame.setVisible(true);
+ if ( parent != null && parent instanceof BasicFrame ) {
+ ((BasicFrame)parent).closeIfReplaceable();
+ }
return true;
}
BasicFrame frame = new BasicFrame(doc);
frame.replaceable = true;
frame.setVisible(true);
- ComponentConfigDialog.showDialog(frame, doc, rocket);
+ // kruland commented this out - I don't like it.
+ //ComponentConfigDialog.showDialog(frame, doc, rocket);
}
/**