Clean up recovery deployment selection
This commit is contained in:
parent
347c38ef96
commit
bb01c859f6
@ -47,11 +47,9 @@ public class DeploymentSelectionDialog extends JDialog {
|
|||||||
private final UnitSelector altUnit;
|
private final UnitSelector altUnit;
|
||||||
private final JSlider altSlider;
|
private final JSlider altSlider;
|
||||||
|
|
||||||
public DeploymentSelectionDialog(Window parent, final Rocket rocket, final RecoveryDevice component) {
|
public DeploymentSelectionDialog(Window parent, final Rocket rocket, final FlightConfigurationId id, final RecoveryDevice component) {
|
||||||
super(parent, trans.get("edtmotorconfdlg.title.Selectdeploymentconf"), Dialog.ModalityType.APPLICATION_MODAL);
|
super(parent, trans.get("edtmotorconfdlg.title.Selectdeploymentconf"), Dialog.ModalityType.APPLICATION_MODAL);
|
||||||
|
|
||||||
final FlightConfigurationId id = rocket.getSelectedConfiguration().getFlightConfigurationID();
|
|
||||||
|
|
||||||
newConfiguration = component.getDeploymentConfigurations().get(id).clone();
|
newConfiguration = component.getDeploymentConfigurations().get(id).clone();
|
||||||
|
|
||||||
JPanel panel = new JPanel(new MigLayout("fill"));
|
JPanel panel = new JPanel(new MigLayout("fill"));
|
||||||
@ -149,6 +147,7 @@ public class DeploymentSelectionDialog extends JDialog {
|
|||||||
|
|
||||||
this.setContentPane(panel);
|
this.setContentPane(panel);
|
||||||
GUIUtil.setDisposableDialogOptions(this, okButton);
|
GUIUtil.setDisposableDialogOptions(this, okButton);
|
||||||
|
// TODO: closes wrong, doesn't use okButton action
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateState() {
|
private void updateState() {
|
||||||
|
@ -171,7 +171,7 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel<Recovery
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean update = false;
|
// Get the device and fcid that will be used in the config dialog
|
||||||
RecoveryDevice initDevice = devices.get(0);
|
RecoveryDevice initDevice = devices.get(0);
|
||||||
FlightConfigurationId initFcId = fcIds.get(0);
|
FlightConfigurationId initFcId = fcIds.get(0);
|
||||||
|
|
||||||
@ -179,32 +179,30 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel<Recovery
|
|||||||
JDialog d = new DeploymentSelectionDialog(SwingUtilities.getWindowAncestor(this), rocket, initDevice);
|
JDialog d = new DeploymentSelectionDialog(SwingUtilities.getWindowAncestor(this), rocket, initDevice);
|
||||||
d.setVisible(true);
|
d.setVisible(true);
|
||||||
|
|
||||||
if (!initialConfig.equals(initDevice.getDeploymentConfigurations().get(initFcId))) {
|
final DeploymentConfiguration modifiedConfig = initDevice.getDeploymentConfigurations().get(initFcId);
|
||||||
update = true;
|
boolean update = !initialConfig.equals(modifiedConfig);
|
||||||
}
|
|
||||||
|
|
||||||
double deployDelay = initDevice.getDeploymentConfigurations().get(initFcId).getDeployDelay();
|
double deployDelay = modifiedConfig.getDeployDelay();
|
||||||
double deployAltitude = initDevice.getDeploymentConfigurations().get(initFcId).getDeployAltitude();
|
double deployAltitude = modifiedConfig.getDeployAltitude();
|
||||||
DeployEvent deployEvent = initDevice.getDeploymentConfigurations().get(initFcId).getDeployEvent();
|
DeployEvent deployEvent = modifiedConfig.getDeployEvent();
|
||||||
|
|
||||||
for (int i = 0; i < devices.size(); i++) {
|
for (RecoveryDevice device : devices) {
|
||||||
for (int j = 0; j < fcIds.size(); j++) {
|
for (FlightConfigurationId fcId : fcIds) {
|
||||||
if ((i == 0) && (j == 0)) break;
|
// Skip the config that was used for the config dialog (it has already been modified)
|
||||||
|
if ((device == initDevice) && (fcId == initFcId))
|
||||||
|
continue;
|
||||||
|
|
||||||
final RecoveryDevice device = devices.get(i);
|
DeploymentConfiguration currentConfig = device.getDeploymentConfigurations().get(fcId);
|
||||||
final FlightConfigurationId fcId = fcIds.get(j);
|
|
||||||
DeploymentConfiguration config = device.getDeploymentConfigurations().get(fcId).copy(fcId);
|
|
||||||
initialConfig = config.copy(fcId);
|
|
||||||
|
|
||||||
config.setDeployDelay(deployDelay);
|
if (currentConfig.equals(modifiedConfig)) {
|
||||||
config.setDeployAltitude(deployAltitude);
|
continue;
|
||||||
config.setDeployEvent(deployEvent);
|
|
||||||
|
|
||||||
device.getDeploymentConfigurations().set(fcId, config);
|
|
||||||
|
|
||||||
if (!initialConfig.equals(device.getDeploymentConfigurations().get(fcId))) {
|
|
||||||
update = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update = true;
|
||||||
|
|
||||||
|
currentConfig.setDeployDelay(deployDelay);
|
||||||
|
currentConfig.setDeployAltitude(deployAltitude);
|
||||||
|
currentConfig.setDeployEvent(deployEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user