Make the simulation edit dialog operate a little more friendly. When
the Run Simulation button is pressed, the simulations are executed and the edit dialog changes to support plotting (when not in multi-edit mode). The edit dialog will not close in any case. When the user presses close, the dialog is closed. The close button no longer copies the changed simulation conditions to the other selected simulations.
This commit is contained in:
parent
4b9fb6b2fc
commit
4cfc65fbe2
@ -42,6 +42,28 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
private final static String EDITMODE = "EDIT";
|
private final static String EDITMODE = "EDIT";
|
||||||
private final static String PLOTMODE = "PLOT";
|
private final static String PLOTMODE = "PLOT";
|
||||||
|
|
||||||
|
public SimulationEditDialog(Window parent, final OpenRocketDocument document, Simulation... sims) {
|
||||||
|
//// Edit simulation
|
||||||
|
super(parent, trans.get("simedtdlg.title.Editsim"), JDialog.ModalityType.DOCUMENT_MODAL);
|
||||||
|
this.document = document;
|
||||||
|
this.parentWindow = parent;
|
||||||
|
this.simulation = sims;
|
||||||
|
this.conditions = simulation[0].getOptions();
|
||||||
|
configuration = simulation[0].getConfiguration();
|
||||||
|
|
||||||
|
this.cards = new JPanel(new CardLayout());
|
||||||
|
this.add(cards);
|
||||||
|
buildEditCard();
|
||||||
|
buildPlotCard();
|
||||||
|
|
||||||
|
this.validate();
|
||||||
|
this.pack();
|
||||||
|
|
||||||
|
this.setLocationByPlatform(true);
|
||||||
|
|
||||||
|
GUIUtil.setDisposableDialogOptions(this, null);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isSingleEdit() {
|
private boolean isSingleEdit() {
|
||||||
return simulation.length == 1;
|
return simulation.length == 1;
|
||||||
}
|
}
|
||||||
@ -65,23 +87,29 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
cards.validate();
|
cards.validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimulationEditDialog(Window parent, OpenRocketDocument document, Simulation... sims) {
|
private void copyChangesToAllSims() {
|
||||||
//// Edit simulation
|
if (simulation.length > 1) {
|
||||||
super(parent, trans.get("simedtdlg.title.Editsim"), JDialog.ModalityType.DOCUMENT_MODAL);
|
for (int i = 1; i < simulation.length; i++) {
|
||||||
this.document = document;
|
simulation[i].getOptions().copyConditionsFrom(simulation[0].getOptions());
|
||||||
this.parentWindow = parent;
|
simulation[i].getSimulationListeners().clear();
|
||||||
this.simulation = sims;
|
simulation[i].getSimulationListeners().addAll(simulation[0].getSimulationListeners());
|
||||||
this.conditions = simulation[0].getOptions();
|
}
|
||||||
configuration = simulation[0].getConfiguration();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.cards = new JPanel(new CardLayout());
|
private void refreshView() {
|
||||||
this.add(cards);
|
cards.removeAll();
|
||||||
{
|
buildEditCard();
|
||||||
|
buildPlotCard();
|
||||||
|
this.validate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildEditCard() {
|
||||||
JPanel simEditPanel = new JPanel(new MigLayout("fill"));
|
JPanel simEditPanel = new JPanel(new MigLayout("fill"));
|
||||||
|
|
||||||
if (isSingleEdit()) {
|
if (isSingleEdit()) {
|
||||||
//// Simulation name:
|
//// Simulation name:
|
||||||
simEditPanel.add(new JLabel(trans.get("simedtdlg.lbl.Simname") + " "), "shrink");
|
simEditPanel.add(new JLabel(trans.get("simedtdlg.lbl.Simname") + " "), "span, split 2, shrink");
|
||||||
final JTextField field = new JTextField(simulation[0].getName());
|
final JTextField field = new JTextField(simulation[0].getName());
|
||||||
field.getDocument().addDocumentListener(new DocumentListener() {
|
field.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -115,7 +143,7 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
JLabel label = new JLabel(trans.get("simedtdlg.lbl.Flightcfg"));
|
JLabel label = new JLabel(trans.get("simedtdlg.lbl.Flightcfg"));
|
||||||
//// Select the motor configuration to use.
|
//// Select the motor configuration to use.
|
||||||
label.setToolTipText(trans.get("simedtdlg.lbl.ttip.Flightcfg"));
|
label.setToolTipText(trans.get("simedtdlg.lbl.ttip.Flightcfg"));
|
||||||
simEditPanel.add(label, "shrink");
|
simEditPanel.add(label, "span, split 2, shrink");
|
||||||
|
|
||||||
JComboBox combo = new JComboBox(new FlightConfigurationModel(configuration));
|
JComboBox combo = new JComboBox(new FlightConfigurationModel(configuration));
|
||||||
//// Select the motor configuration to use.
|
//// Select the motor configuration to use.
|
||||||
@ -137,7 +165,7 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
configDialog.setVisible(true);
|
configDialog.setVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
simEditPanel.add(button, "shrink, wrap");
|
simEditPanel.add(button, "shrink, align left, wrap");
|
||||||
}
|
}
|
||||||
JTabbedPane tabbedPane = new JTabbedPane();
|
JTabbedPane tabbedPane = new JTabbedPane();
|
||||||
|
|
||||||
@ -157,10 +185,6 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
// SimulationEditDialog.this.dispose();
|
|
||||||
// SimulationPlotExportDialog plot = new SimulationPlotExportDialog(SimulationEditDialog.this.parentWindow,
|
|
||||||
// SimulationEditDialog.this.document, SimulationEditDialog.this.simulation[0]);
|
|
||||||
// plot.setVisible(true);
|
|
||||||
SimulationEditDialog.this.setPlotMode();
|
SimulationEditDialog.this.setPlotMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,8 +202,8 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
copyChangesToAllSims();
|
copyChangesToAllSims();
|
||||||
SimulationEditDialog.this.dispose();
|
|
||||||
SimulationRunDialog.runSimulations(parentWindow, SimulationEditDialog.this.document, simulation);
|
SimulationRunDialog.runSimulations(parentWindow, SimulationEditDialog.this.document, simulation);
|
||||||
|
refreshView();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
simEditPanel.add(button, " align right, tag ok");
|
simEditPanel.add(button, " align right, tag ok");
|
||||||
@ -189,14 +213,15 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
close.addActionListener(new ActionListener() {
|
close.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
copyChangesToAllSims();
|
|
||||||
SimulationEditDialog.this.dispose();
|
SimulationEditDialog.this.dispose();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
simEditPanel.add(close, "tag ok");
|
simEditPanel.add(close, "tag ok");
|
||||||
//simEditPanel.validate();
|
|
||||||
cards.add(simEditPanel, EDITMODE);
|
cards.add(simEditPanel, EDITMODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buildPlotCard() {
|
||||||
if (allowsPlotMode()) {
|
if (allowsPlotMode()) {
|
||||||
JPanel plotExportPanel = new JPanel(new MigLayout("fill"));
|
JPanel plotExportPanel = new JPanel(new MigLayout("fill"));
|
||||||
|
|
||||||
@ -233,6 +258,10 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
ok.addActionListener(new ActionListener() {
|
ok.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
// If the simulation is out of date, run the simulation.
|
||||||
|
if (simulation[0].getStatus() != Simulation.Status.UPTODATE) {
|
||||||
|
new SimulationRunDialog(SimulationEditDialog.this.parentWindow, document, simulation[0]).setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (tabbedPane.getSelectedIndex() == 0) {
|
if (tabbedPane.getSelectedIndex() == 0) {
|
||||||
JDialog plot = plotTab.doPlot(SimulationEditDialog.this.parentWindow);
|
JDialog plot = plotTab.doPlot(SimulationEditDialog.this.parentWindow);
|
||||||
@ -261,23 +290,5 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
cards.add(plotExportPanel, PLOTMODE);
|
cards.add(plotExportPanel, PLOTMODE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.validate();
|
|
||||||
this.pack();
|
|
||||||
|
|
||||||
this.setLocationByPlatform(true);
|
|
||||||
|
|
||||||
GUIUtil.setDisposableDialogOptions(this, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void copyChangesToAllSims() {
|
|
||||||
if (simulation.length > 1) {
|
|
||||||
for (int i = 1; i < simulation.length; i++) {
|
|
||||||
simulation[i].getOptions().copyConditionsFrom(simulation[0].getOptions());
|
|
||||||
simulation[i].getSimulationListeners().clear();
|
|
||||||
simulation[i].getSimulationListeners().addAll(simulation[0].getSimulationListeners());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user