Only show error checkbox if there are errors

This commit is contained in:
JoePfeiffer 2024-01-09 17:36:44 -07:00
parent 1dda428b2f
commit 843c2e6d22
2 changed files with 27 additions and 11 deletions

View File

@ -19,6 +19,7 @@ import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.simulation.BasicEventSimulationEngine;
import net.sf.openrocket.simulation.DefaultSimulationOptionFactory;
import net.sf.openrocket.simulation.FlightData;
import net.sf.openrocket.simulation.FlightEvent;
import net.sf.openrocket.simulation.RK4SimulationStepper;
import net.sf.openrocket.simulation.SimulationConditions;
import net.sf.openrocket.simulation.SimulationEngine;
@ -349,7 +350,20 @@ public class Simulation implements ChangeSource, Cloneable {
}
/**
* Returns true is the status indicates that the simulation data is up-to-date.
* Determines whether the simulation has errors
*/
public boolean hasErrors() {
FlightData data = getSimulatedData();
for (int branchNo = 0; branchNo < data.getBranchCount(); branchNo++) {
if (data.getBranch(branchNo).getFirstEvent(FlightEvent.Type.SIM_ABORT) != null) {
return true;
}
}
return false;
}
/**
* Returns true if the status indicates that the simulation data is up-to-date.
* @param status status of the simulation to check for if its data is up-to-date
*/
public static boolean isStatusUpToDate(Status status) {

View File

@ -98,8 +98,9 @@ public class SimulationPlotDialog extends JDialog {
});
panel.add(checkData, "split, left");
//// Show errors
//// Show errors if any
//// ALWAYS show errors initially; make user turn it off for themselves
if (simulation.hasErrors()) {
final JCheckBox checkErrors = new JCheckBox(trans.get("PlotDialog.CheckBox.ShowErrors"));
checkErrors.setSelected(true);
checkErrors.addActionListener(new ActionListener() {
@ -109,6 +110,7 @@ public class SimulationPlotDialog extends JDialog {
}
});
panel.add(checkErrors, "split, left");
}
//// Add series selection box
ArrayList<String> stages = new ArrayList<String>();