[Refine] Refining the FlightConfiguration UI behavior
- the selected configuration in a rocket is now specified by id instead of instance - tighted up Configuration UI behavior - operations should now start from selected configuration row
This commit is contained in:
parent
345d5952c6
commit
fedda3278e
@ -62,9 +62,7 @@ class MotorConfigurationHandler extends AbstractElementHandler {
|
||||
}
|
||||
|
||||
if ("true".equals(attributes.remove("default"))) {
|
||||
// also associate this configuration with the default.
|
||||
FlightConfiguration fc = rocket.getFlightConfiguration(fcid);
|
||||
rocket.setSelectedConfiguration( fc);
|
||||
rocket.setSelectedConfiguration( fcid);
|
||||
}
|
||||
|
||||
super.closeElement(element, attributes, content, warnings);
|
||||
|
@ -343,15 +343,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
|
||||
modID++;
|
||||
}
|
||||
|
||||
public Set<MotorConfigurationId> getMotorIDs() {
|
||||
return motors.keySet();
|
||||
}
|
||||
|
||||
public MotorConfiguration getMotorInstance(MotorConfigurationId id) {
|
||||
return motors.get(id);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasMotors() {
|
||||
return (0 < motors.size());
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ public class Rocket extends RocketComponent {
|
||||
public void freeze() {
|
||||
checkState();
|
||||
if (freezeList == null) {
|
||||
freezeList = new LinkedList<ComponentChangeEvent>();
|
||||
freezeList = new LinkedList<>();
|
||||
log.debug("Freezing Rocket");
|
||||
} else {
|
||||
Application.getExceptionHandler().handleErrorCondition("Attempting to freeze Rocket when it is already frozen, " +
|
||||
@ -702,24 +702,12 @@ public class Rocket extends RocketComponent {
|
||||
return idList.get(configIndex);
|
||||
}
|
||||
|
||||
public void setSelectedConfiguration(final FlightConfiguration config) {
|
||||
public void setSelectedConfiguration(final FlightConfigurationId selectId) {
|
||||
checkState();
|
||||
this.selectedConfiguration = config;
|
||||
this.selectedConfiguration = this.configSet.get( selectId );
|
||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||
}
|
||||
|
||||
public void setDefaultConfiguration(final FlightConfigurationId fcid) {
|
||||
checkState();
|
||||
|
||||
if( fcid.hasError() ){
|
||||
log.error("attempt to set a 'fcid = config' with a error fcid. Ignored.", new IllegalArgumentException("error id:"+fcid));
|
||||
return;
|
||||
}else if( this.configSet.containsId(fcid)){
|
||||
this.selectedConfiguration = configSet.get(fcid);
|
||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Associate the given ID and flight configuration.
|
||||
* <code>null</code> or an empty string.
|
||||
|
@ -515,7 +515,7 @@ public class TestRockets {
|
||||
bodytube.setMaterial(material);
|
||||
finset.setMaterial(material);
|
||||
|
||||
rocket.setSelectedConfiguration( rocket.getFlightConfiguration( fcid[0]));
|
||||
rocket.setSelectedConfiguration( fcid[0] );
|
||||
rocket.getSelectedConfiguration().setAllStages();
|
||||
rocket.enableEvents();
|
||||
return rocket;
|
||||
@ -535,8 +535,7 @@ public class TestRockets {
|
||||
fcid[i] = new FlightConfigurationId();
|
||||
rocket.createFlightConfiguration(fcid[i]);
|
||||
}
|
||||
FlightConfiguration selectedConfiguration = rocket.getFlightConfiguration(fcid[0]);
|
||||
|
||||
|
||||
double noseconeLength = 0.07;
|
||||
double noseconeRadius = 0.012;
|
||||
NoseCone nosecone = new NoseCone(Transition.Shape.OGIVE, noseconeLength, noseconeRadius);
|
||||
@ -708,7 +707,7 @@ public class TestRockets {
|
||||
|
||||
}
|
||||
rocket.getSelectedConfiguration().setAllStages();
|
||||
rocket.setSelectedConfiguration( selectedConfiguration );
|
||||
rocket.setSelectedConfiguration( fcid[0] );
|
||||
rocket.enableEvents();
|
||||
return rocket;
|
||||
}
|
||||
@ -1024,11 +1023,10 @@ public class TestRockets {
|
||||
Rocket rocket = new Rocket();
|
||||
rocket.setName("Falcon9H Scale Rocket");
|
||||
|
||||
FlightConfiguration selConfig = rocket.createFlightConfiguration(null);
|
||||
FlightConfigurationId selFCID = selConfig.getFlightConfigurationID();
|
||||
rocket.setSelectedConfiguration(selFCID);
|
||||
|
||||
FlightConfiguration selConfig = rocket.createFlightConfiguration(null);
|
||||
rocket.setSelectedConfiguration(selConfig);
|
||||
FlightConfigurationId selFCID = selConfig.getFlightConfigurationID();
|
||||
|
||||
// ====== Payload Stage ======
|
||||
// ====== ====== ====== ======
|
||||
AxialStage payloadStage = new AxialStage();
|
||||
@ -1175,7 +1173,7 @@ public class TestRockets {
|
||||
}
|
||||
|
||||
rocket.enableEvents();
|
||||
rocket.setSelectedConfiguration(selConfig);
|
||||
rocket.setSelectedConfiguration( selFCID);
|
||||
selConfig.setAllStages();
|
||||
|
||||
return rocket;
|
||||
|
@ -1165,11 +1165,7 @@ public class GeneralOptimizationDialog extends JDialog {
|
||||
} else {
|
||||
selectedModifierDescription.setText("");
|
||||
}
|
||||
|
||||
// Update the active configuration
|
||||
FlightConfigurationId fcid = getSelectedSimulation().getId();
|
||||
getSelectedSimulation().getRocket().setDefaultConfiguration(fcid);
|
||||
|
||||
|
||||
updating = false;
|
||||
}
|
||||
|
||||
|
@ -115,23 +115,22 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
||||
updateButtonState();
|
||||
|
||||
this.add(tabs, "spanx, grow, wrap rel");
|
||||
|
||||
}
|
||||
|
||||
private void addConfiguration() {
|
||||
FlightConfigurationId newFCID = new FlightConfigurationId();
|
||||
FlightConfiguration newConfig = new FlightConfiguration( rocket, newFCID );
|
||||
rocket.setFlightConfiguration(newFCID, newConfig);
|
||||
|
||||
FlightConfigurationId newId = new FlightConfigurationId();
|
||||
FlightConfiguration newConfig = new FlightConfiguration( rocket, newId );
|
||||
rocket.setFlightConfiguration( newId, newConfig);
|
||||
|
||||
// Create a new simulation for this configuration.
|
||||
createSimulationForNewConfiguration();
|
||||
createSimulationForNewConfiguration( newId );
|
||||
|
||||
configurationChanged();
|
||||
}
|
||||
|
||||
private void copyConfiguration() {
|
||||
FlightConfiguration oldConfig = rocket.getSelectedConfiguration();
|
||||
FlightConfigurationId oldId = oldConfig.getFlightConfigurationID();
|
||||
FlightConfigurationId oldId = this.motorConfigurationPanel.getSelectedConfigurationId();
|
||||
FlightConfiguration oldConfig = rocket.getFlightConfiguration(oldId);
|
||||
|
||||
FlightConfigurationId newId = new FlightConfigurationId();
|
||||
FlightConfiguration newConfig = oldConfig.copy( newId);
|
||||
@ -141,10 +140,11 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
||||
((FlightConfigurableComponent) c).copyFlightConfiguration(oldId, newId);
|
||||
}
|
||||
}
|
||||
rocket.setFlightConfiguration(newId, newConfig);
|
||||
|
||||
// Create a new simulation for this configuration.
|
||||
createSimulationForNewConfiguration();
|
||||
rocket.setFlightConfiguration( newId, newConfig);
|
||||
|
||||
|
||||
// Create a new simulation for this configuration.
|
||||
createSimulationForNewConfiguration( newId);
|
||||
|
||||
configurationChanged();
|
||||
}
|
||||
@ -165,7 +165,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
||||
/**
|
||||
* prereq - assumes that the new configuration has been set as the default configuration.
|
||||
*/
|
||||
private void createSimulationForNewConfiguration() {
|
||||
private void createSimulationForNewConfiguration( final FlightConfigurationId fcid ) {
|
||||
Simulation newSim = new Simulation(rocket);
|
||||
OpenRocketDocument doc = BasicFrame.findDocument(rocket);
|
||||
if (doc != null) {
|
||||
|
@ -320,7 +320,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ae) {
|
||||
FlightConfiguration newConfig = (FlightConfiguration)configComboBox.getSelectedItem();
|
||||
document.getRocket().setSelectedConfiguration( newConfig);
|
||||
document.getRocket().setSelectedConfiguration( newConfig.getId());
|
||||
updateExtras();
|
||||
updateFigures();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user