When deleting a flight configuration, delete corresponding simulations
as well.
This commit is contained in:
parent
9f20889688
commit
0e8adeaf1f
@ -281,6 +281,20 @@ public class OpenRocketDocument implements ComponentChangeListener {
|
||||
return simulation;
|
||||
}
|
||||
|
||||
public void removeFlightConfigurationAndSimulations(String configId) {
|
||||
if (configId == null) {
|
||||
return;
|
||||
}
|
||||
for (Simulation s : getSimulations()) {
|
||||
// Assumes modifiable collection - which it is
|
||||
if (s.getConfiguration().getFlightConfigurationID().equals(configId)) {
|
||||
removeSimulation(s);
|
||||
}
|
||||
}
|
||||
rocket.removeFlightConfigurationID(configId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a unique name suitable for the next simulation. The name begins
|
||||
* with {@link #SIMULATION_NAME_PREFIX} and has a unique number larger than any
|
||||
|
@ -552,7 +552,6 @@ public class Rocket extends RocketComponent {
|
||||
getDefaultConfiguration().setFlightConfigurationID(null);
|
||||
}
|
||||
flightConfigurationIDs.remove(id);
|
||||
// FIXME - remove corresponding simulations?
|
||||
fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE);
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
||||
String currentId = rocket.getDefaultConfiguration().getFlightConfigurationID();
|
||||
if (currentId == null)
|
||||
return;
|
||||
rocket.removeFlightConfigurationID(currentId);
|
||||
document.removeFlightConfigurationAndSimulations(currentId);
|
||||
configurationChanged();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user