Added buttons to the edit and plot dialogs to switch to the other one.
This commit is contained in:
parent
9a43a01663
commit
02f3f48f3a
@ -374,7 +374,21 @@ public class Simulation implements ChangeSource, Cloneable {
|
||||
return simulatedData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return true if this simulation contains plotable flight data.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean hasSimulationData() {
|
||||
FlightData data = getSimulatedData();
|
||||
if (data == null) {
|
||||
return false;
|
||||
}
|
||||
if (data.getBranchCount() == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of this simulation suitable for cut/copy/paste operations.
|
||||
|
@ -228,7 +228,7 @@ public class SimulationPanel extends JPanel {
|
||||
|
||||
Simulation sim = document.getSimulations().get(selected);
|
||||
|
||||
if (sim.getSimulatedData() == null || sim.getSimulatedData().getBranchCount() == 0) {
|
||||
if (!sim.hasSimulationData()) {
|
||||
new SimulationRunDialog(SwingUtilities.getWindowAncestor(
|
||||
SimulationPanel.this), document, sim).setVisible(true);
|
||||
}
|
||||
|
@ -149,11 +149,28 @@ public class SimulationEditDialog extends JDialog {
|
||||
mainPanel.add(tabbedPane, "spanx, grow, wrap");
|
||||
|
||||
|
||||
// Buttons
|
||||
mainPanel.add(new JPanel(), "spanx, split, growx");
|
||||
//// Open Plot button
|
||||
JButton button = new JButton("<<Plot");
|
||||
button.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
});
|
||||
mainPanel.add(button, "spanx, split 3, align left");
|
||||
if (sims.length == 1 && sims[0].hasSimulationData()) {
|
||||
button.setVisible(true);
|
||||
} else {
|
||||
button.setVisible(false);
|
||||
}
|
||||
|
||||
//// Run simulation button
|
||||
JButton button = new JButton(trans.get("simedtdlg.but.runsimulation"));
|
||||
button = new JButton(trans.get("simedtdlg.but.runsimulation"));
|
||||
button.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@ -162,7 +179,7 @@ public class SimulationEditDialog extends JDialog {
|
||||
SimulationRunDialog.runSimulations(parentWindow, SimulationEditDialog.this.document, simulation);
|
||||
}
|
||||
});
|
||||
mainPanel.add(button, "gapright para");
|
||||
mainPanel.add(button, " align right, tag ok");
|
||||
|
||||
//// Close button
|
||||
JButton close = new JButton(trans.get("dlg.but.close"));
|
||||
@ -173,7 +190,7 @@ public class SimulationEditDialog extends JDialog {
|
||||
SimulationEditDialog.this.dispose();
|
||||
}
|
||||
});
|
||||
mainPanel.add(close, "");
|
||||
mainPanel.add(close, "tag ok");
|
||||
|
||||
|
||||
this.add(mainPanel);
|
||||
|
@ -24,7 +24,7 @@ public class SimulationPlotExportDialog extends JDialog {
|
||||
private final Simulation simulation;
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
public SimulationPlotExportDialog(Window parent, OpenRocketDocument document, Simulation s) {
|
||||
public SimulationPlotExportDialog(Window parent, final OpenRocketDocument document, Simulation s) {
|
||||
//// Plot/Export simulation
|
||||
super(parent, trans.get("simedtdlg.title.Editsim"), JDialog.ModalityType.DOCUMENT_MODAL);
|
||||
this.parentWindow = parent;
|
||||
@ -49,6 +49,21 @@ public class SimulationPlotExportDialog extends JDialog {
|
||||
|
||||
mainPanel.add(tabbedPane, "grow, wrap");
|
||||
|
||||
JButton button = new JButton("<<Edit");
|
||||
button.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
SimulationPlotExportDialog.this.dispose();
|
||||
SimulationEditDialog edit = new SimulationEditDialog(SimulationPlotExportDialog.this.parentWindow,
|
||||
document, SimulationPlotExportDialog.this.simulation);
|
||||
edit.setVisible(true);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mainPanel.add(button, "spanx, split 3, align left");
|
||||
|
||||
JButton ok = new JButton(trans.get("dlg.but.ok"));
|
||||
ok.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
@ -87,5 +102,4 @@ public class SimulationPlotExportDialog extends JDialog {
|
||||
GUIUtil.setDisposableDialogOptions(this, close);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user