[#1820] Don't switch to simulation plot if "Simulate & Plot" resulted in faulty simulation
This commit is contained in:
parent
f68189c3e2
commit
baed200d27
@ -209,12 +209,10 @@ public class SimulationEditDialog extends JDialog {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
copyChangesToAllSims();
|
||||
SimulationRunDialog.runSimulations(parentWindow, SimulationEditDialog.this.document, simulationList);
|
||||
refreshView();
|
||||
if (allowsPlotMode()) {
|
||||
SimulationRunDialog dialog = SimulationRunDialog.runSimulations(parentWindow, SimulationEditDialog.this.document, simulationList);
|
||||
if (allowsPlotMode() && dialog.isAllSimulationsSuccessful()) {
|
||||
refreshView();
|
||||
setPlotMode();
|
||||
} else {
|
||||
setVisible(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -207,9 +207,12 @@ public class SimulationRunDialog extends JDialog {
|
||||
* the parent Window of the dialog to use.
|
||||
* @param simulations
|
||||
* the simulations to run.
|
||||
* @return the simulation run dialog instance.
|
||||
*/
|
||||
public static void runSimulations(Window parent, OpenRocketDocument document, Simulation... simulations) {
|
||||
new SimulationRunDialog(parent, document, simulations).setVisible(true);
|
||||
public static SimulationRunDialog runSimulations(Window parent, OpenRocketDocument document, Simulation... simulations) {
|
||||
SimulationRunDialog dialog = new SimulationRunDialog(parent, document, simulations);
|
||||
dialog.setVisible(true);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
private void updateProgress() {
|
||||
@ -257,6 +260,18 @@ public class SimulationRunDialog extends JDialog {
|
||||
+ u.toStringUnit(simulationMaxVelocity[index]) + ")");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if all the simulations ran successfully. Returns false if the simulations encountered
|
||||
* an exception, or were cancelled.
|
||||
*/
|
||||
public boolean isAllSimulationsSuccessful() {
|
||||
for (SimulationWorker w : simulationWorkers) {
|
||||
if (w.getThrowable() != null)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A SwingWorker that performs a flight simulation. It periodically updates
|
||||
* the simulation statuses of the parent class and calls updateProgress().
|
||||
|
@ -70,6 +70,17 @@ public abstract class SimulationWorker extends SwingWorker<FlightData, Simulatio
|
||||
protected SimulationListener[] getExtraListeners() {
|
||||
return new SimulationListener[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the throwable that caused the simulation to fail or cancel,
|
||||
* or null if the simulation ran successfully.
|
||||
*
|
||||
* @return throwable that caused the simulation to fail or cancel,
|
||||
* or null if the simulation ran successfully.
|
||||
*/
|
||||
public Throwable getThrowable() {
|
||||
return throwable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user