[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"))) {
|
if ("true".equals(attributes.remove("default"))) {
|
||||||
// also associate this configuration with the default.
|
rocket.setSelectedConfiguration( fcid);
|
||||||
FlightConfiguration fc = rocket.getFlightConfiguration(fcid);
|
|
||||||
rocket.setSelectedConfiguration( fc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
super.closeElement(element, attributes, content, warnings);
|
super.closeElement(element, attributes, content, warnings);
|
||||||
|
@ -344,14 +344,6 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
modID++;
|
modID++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<MotorConfigurationId> getMotorIDs() {
|
|
||||||
return motors.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MotorConfiguration getMotorInstance(MotorConfigurationId id) {
|
|
||||||
return motors.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasMotors() {
|
public boolean hasMotors() {
|
||||||
return (0 < motors.size());
|
return (0 < motors.size());
|
||||||
}
|
}
|
||||||
|
@ -511,7 +511,7 @@ public class Rocket extends RocketComponent {
|
|||||||
public void freeze() {
|
public void freeze() {
|
||||||
checkState();
|
checkState();
|
||||||
if (freezeList == null) {
|
if (freezeList == null) {
|
||||||
freezeList = new LinkedList<ComponentChangeEvent>();
|
freezeList = new LinkedList<>();
|
||||||
log.debug("Freezing Rocket");
|
log.debug("Freezing Rocket");
|
||||||
} else {
|
} else {
|
||||||
Application.getExceptionHandler().handleErrorCondition("Attempting to freeze Rocket when it is already frozen, " +
|
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);
|
return idList.get(configIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedConfiguration(final FlightConfiguration config) {
|
public void setSelectedConfiguration(final FlightConfigurationId selectId) {
|
||||||
checkState();
|
checkState();
|
||||||
this.selectedConfiguration = config;
|
this.selectedConfiguration = this.configSet.get( selectId );
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
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.
|
* Associate the given ID and flight configuration.
|
||||||
* <code>null</code> or an empty string.
|
* <code>null</code> or an empty string.
|
||||||
|
@ -515,7 +515,7 @@ public class TestRockets {
|
|||||||
bodytube.setMaterial(material);
|
bodytube.setMaterial(material);
|
||||||
finset.setMaterial(material);
|
finset.setMaterial(material);
|
||||||
|
|
||||||
rocket.setSelectedConfiguration( rocket.getFlightConfiguration( fcid[0]));
|
rocket.setSelectedConfiguration( fcid[0] );
|
||||||
rocket.getSelectedConfiguration().setAllStages();
|
rocket.getSelectedConfiguration().setAllStages();
|
||||||
rocket.enableEvents();
|
rocket.enableEvents();
|
||||||
return rocket;
|
return rocket;
|
||||||
@ -535,7 +535,6 @@ public class TestRockets {
|
|||||||
fcid[i] = new FlightConfigurationId();
|
fcid[i] = new FlightConfigurationId();
|
||||||
rocket.createFlightConfiguration(fcid[i]);
|
rocket.createFlightConfiguration(fcid[i]);
|
||||||
}
|
}
|
||||||
FlightConfiguration selectedConfiguration = rocket.getFlightConfiguration(fcid[0]);
|
|
||||||
|
|
||||||
double noseconeLength = 0.07;
|
double noseconeLength = 0.07;
|
||||||
double noseconeRadius = 0.012;
|
double noseconeRadius = 0.012;
|
||||||
@ -708,7 +707,7 @@ public class TestRockets {
|
|||||||
|
|
||||||
}
|
}
|
||||||
rocket.getSelectedConfiguration().setAllStages();
|
rocket.getSelectedConfiguration().setAllStages();
|
||||||
rocket.setSelectedConfiguration( selectedConfiguration );
|
rocket.setSelectedConfiguration( fcid[0] );
|
||||||
rocket.enableEvents();
|
rocket.enableEvents();
|
||||||
return rocket;
|
return rocket;
|
||||||
}
|
}
|
||||||
@ -1024,10 +1023,9 @@ public class TestRockets {
|
|||||||
Rocket rocket = new Rocket();
|
Rocket rocket = new Rocket();
|
||||||
rocket.setName("Falcon9H Scale Rocket");
|
rocket.setName("Falcon9H Scale Rocket");
|
||||||
|
|
||||||
|
|
||||||
FlightConfiguration selConfig = rocket.createFlightConfiguration(null);
|
FlightConfiguration selConfig = rocket.createFlightConfiguration(null);
|
||||||
rocket.setSelectedConfiguration(selConfig);
|
|
||||||
FlightConfigurationId selFCID = selConfig.getFlightConfigurationID();
|
FlightConfigurationId selFCID = selConfig.getFlightConfigurationID();
|
||||||
|
rocket.setSelectedConfiguration(selFCID);
|
||||||
|
|
||||||
// ====== Payload Stage ======
|
// ====== Payload Stage ======
|
||||||
// ====== ====== ====== ======
|
// ====== ====== ====== ======
|
||||||
@ -1175,7 +1173,7 @@ public class TestRockets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rocket.enableEvents();
|
rocket.enableEvents();
|
||||||
rocket.setSelectedConfiguration(selConfig);
|
rocket.setSelectedConfiguration( selFCID);
|
||||||
selConfig.setAllStages();
|
selConfig.setAllStages();
|
||||||
|
|
||||||
return rocket;
|
return rocket;
|
||||||
|
@ -1166,10 +1166,6 @@ public class GeneralOptimizationDialog extends JDialog {
|
|||||||
selectedModifierDescription.setText("");
|
selectedModifierDescription.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the active configuration
|
|
||||||
FlightConfigurationId fcid = getSelectedSimulation().getId();
|
|
||||||
getSelectedSimulation().getRocket().setDefaultConfiguration(fcid);
|
|
||||||
|
|
||||||
updating = false;
|
updating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,23 +115,22 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
updateButtonState();
|
updateButtonState();
|
||||||
|
|
||||||
this.add(tabs, "spanx, grow, wrap rel");
|
this.add(tabs, "spanx, grow, wrap rel");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addConfiguration() {
|
private void addConfiguration() {
|
||||||
FlightConfigurationId newFCID = new FlightConfigurationId();
|
FlightConfigurationId newId = new FlightConfigurationId();
|
||||||
FlightConfiguration newConfig = new FlightConfiguration( rocket, newFCID );
|
FlightConfiguration newConfig = new FlightConfiguration( rocket, newId );
|
||||||
rocket.setFlightConfiguration(newFCID, newConfig);
|
rocket.setFlightConfiguration( newId, newConfig);
|
||||||
|
|
||||||
// Create a new simulation for this configuration.
|
// Create a new simulation for this configuration.
|
||||||
createSimulationForNewConfiguration();
|
createSimulationForNewConfiguration( newId );
|
||||||
|
|
||||||
configurationChanged();
|
configurationChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyConfiguration() {
|
private void copyConfiguration() {
|
||||||
FlightConfiguration oldConfig = rocket.getSelectedConfiguration();
|
FlightConfigurationId oldId = this.motorConfigurationPanel.getSelectedConfigurationId();
|
||||||
FlightConfigurationId oldId = oldConfig.getFlightConfigurationID();
|
FlightConfiguration oldConfig = rocket.getFlightConfiguration(oldId);
|
||||||
|
|
||||||
FlightConfigurationId newId = new FlightConfigurationId();
|
FlightConfigurationId newId = new FlightConfigurationId();
|
||||||
FlightConfiguration newConfig = oldConfig.copy( newId);
|
FlightConfiguration newConfig = oldConfig.copy( newId);
|
||||||
@ -143,8 +142,9 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
}
|
}
|
||||||
rocket.setFlightConfiguration( newId, newConfig);
|
rocket.setFlightConfiguration( newId, newConfig);
|
||||||
|
|
||||||
|
|
||||||
// Create a new simulation for this configuration.
|
// Create a new simulation for this configuration.
|
||||||
createSimulationForNewConfiguration();
|
createSimulationForNewConfiguration( newId);
|
||||||
|
|
||||||
configurationChanged();
|
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.
|
* 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);
|
Simulation newSim = new Simulation(rocket);
|
||||||
OpenRocketDocument doc = BasicFrame.findDocument(rocket);
|
OpenRocketDocument doc = BasicFrame.findDocument(rocket);
|
||||||
if (doc != null) {
|
if (doc != null) {
|
||||||
|
@ -320,7 +320,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent ae) {
|
public void actionPerformed(ActionEvent ae) {
|
||||||
FlightConfiguration newConfig = (FlightConfiguration)configComboBox.getSelectedItem();
|
FlightConfiguration newConfig = (FlightConfiguration)configComboBox.getSelectedItem();
|
||||||
document.getRocket().setSelectedConfiguration( newConfig);
|
document.getRocket().setSelectedConfiguration( newConfig.getId());
|
||||||
updateExtras();
|
updateExtras();
|
||||||
updateFigures();
|
updateFigures();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user