Merge pull request #157 from kruland2607/master
When deleting a flight configuration, delete corresponding simulations
This commit is contained in:
commit
8bb76d72a2
@ -281,6 +281,20 @@ public class OpenRocketDocument implements ComponentChangeListener {
|
|||||||
return simulation;
|
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
|
* 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
|
* 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);
|
getDefaultConfiguration().setFlightConfigurationID(null);
|
||||||
}
|
}
|
||||||
flightConfigurationIDs.remove(id);
|
flightConfigurationIDs.remove(id);
|
||||||
// FIXME - remove corresponding simulations?
|
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
String currentId = rocket.getDefaultConfiguration().getFlightConfigurationID();
|
String currentId = rocket.getDefaultConfiguration().getFlightConfigurationID();
|
||||||
if (currentId == null)
|
if (currentId == null)
|
||||||
return;
|
return;
|
||||||
rocket.removeFlightConfigurationID(currentId);
|
document.removeFlightConfigurationAndSimulations(currentId);
|
||||||
configurationChanged();
|
configurationChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user