import javax.swing.ImageIcon;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
+import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import net.miginfocom.swing.MigLayout;
+import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.document.Simulation;
import net.sf.openrocket.gui.util.Icons;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.LogHelper;
-import net.sf.openrocket.simulation.CustomExpression;
+import net.sf.openrocket.rocketcomponent.Rocket;
+import net.sf.openrocket.simulation.customexpression.CustomExpression;
import net.sf.openrocket.startup.Application;
/**
private CustomExpression previousExpressionCopy;
private final Window parentWindow;
- private final Simulation simulation;
+ private final OpenRocketDocument doc;
// Define these check indicators to show if fields are OK
private final JLabel nameCheck = new JLabel(RedIcon);
private final JButton okButton = new JButton(trans.get("dlg.but.ok"));
private final JTextField expressionField = new JTextField(20);
- public ExpressionBuilderDialog(Window parent, Simulation simulation){
- this(parent, simulation, new CustomExpression(simulation));
+ public ExpressionBuilderDialog(Window parent, OpenRocketDocument doc){
+ this(parent, doc, new CustomExpression(doc));
}
- public ExpressionBuilderDialog(Window parent, final Simulation simulation, final CustomExpression previousExpression){
+ public ExpressionBuilderDialog(Window parent, final OpenRocketDocument doc, final CustomExpression previousExpression){
super(parent, trans.get("ExpressionBuilderDialog.title"), JDialog.ModalityType.DOCUMENT_MODAL);
+ this.doc = doc;
this.parentWindow = parent;
- this.simulation = simulation;
this.previousExpressionCopy = (CustomExpression) previousExpression.clone();
this.expression = previousExpression;
public void actionPerformed(ActionEvent e) {
log.debug("Opening insert variable window");
Window parentWindow = SwingUtilities.getWindowAncestor(ExpressionBuilderDialog.this);
- new VariableSelector(parentWindow, ExpressionBuilderDialog.this, simulation).setVisible(true);
+ new VariableSelector(parentWindow, ExpressionBuilderDialog.this, doc).setVisible(true);
}
});
}
});
-
//// OK Button
okButton.setEnabled(false);
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- expression.addToSimulation();
+ // add to this simulation
+ expression.addToDocument();
+
+ // close window
ExpressionBuilderDialog.this.dispose();
}
});