[Bugfix] Bugfixes: Ability to Rename, Delete FlightConfigurations.
This commit is contained in:
parent
55acf6cebf
commit
9551ddc0cb
@ -31,7 +31,8 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
|
||||
public final static String DEFAULT_CONFIGURATION_NAME = "Default Configuration";
|
||||
|
||||
protected String configurationName ;
|
||||
protected boolean overrideName = false;
|
||||
protected String configurationName;
|
||||
|
||||
protected final Rocket rocket;
|
||||
protected final FlightConfigurationID fcid;
|
||||
@ -200,6 +201,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
MotorMount mount = (MotorMount)comp;
|
||||
MotorInstance inst = mount.getMotorInstance(this.fcid);
|
||||
|
||||
// NYI: if clustered...
|
||||
// if( mount instanceof Clusterable ){
|
||||
// if( 1 < comp.getInstanceCount() ){
|
||||
// if comp is clustered, it will be clustered from the innerTube, no?
|
||||
@ -217,8 +219,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
// }
|
||||
// // ^^^^ DEVEL ^^^^
|
||||
|
||||
|
||||
// motors go inactive after burnout, so we
|
||||
// motors go inactive after burnout, so include this filter too
|
||||
if (inst.isActive()){
|
||||
toReturn.add(inst);
|
||||
}
|
||||
@ -460,23 +461,28 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
}
|
||||
|
||||
public void setName( final String newName) {
|
||||
if( null == newName ){
|
||||
return;
|
||||
}else if( "".equals(newName)){
|
||||
return;
|
||||
}else if( this.getFlightConfigurationID().equals( FlightConfigurationID.DEFAULT_CONFIGURATION_FCID)){
|
||||
if( this.getFlightConfigurationID().equals( FlightConfigurationID.DEFAULT_CONFIGURATION_FCID)){
|
||||
this.configurationName = FlightConfiguration.DEFAULT_CONFIGURATION_NAME;
|
||||
return;
|
||||
}else if( null == newName ){
|
||||
this.overrideName = false;
|
||||
}else if( "".equals(newName)){
|
||||
return;
|
||||
}else if( ! this.getFlightConfigurationID().isValid()){
|
||||
return;
|
||||
}else if( newName.equals(this.configurationName)){
|
||||
return;
|
||||
}
|
||||
this.overrideName = true;
|
||||
this.configurationName = newName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if( overrideName ){
|
||||
return this.configurationName;
|
||||
}else{
|
||||
return " NYI - motor digest string";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,9 +10,9 @@ import java.util.UUID;
|
||||
public final class FlightConfigurationID implements Comparable<FlightConfigurationID> {
|
||||
final public String key;
|
||||
|
||||
private final static String ERROR_CONFIGURATION_KEYTEXT = "j567uryk2489yfjbr8i1fi";
|
||||
private final static String DEFAULT_CONFIGURATION_KEYTEXT = "default_configuration_662002";
|
||||
private final static String DEFAULT_VALUE_KEYTEXT = "default_value_567866";
|
||||
private final static String ERROR_CONFIGURATION_KEYTEXT = "error_key_2489";
|
||||
private final static String DEFAULT_CONFIGURATION_KEYTEXT = "default_configuration_6602";
|
||||
private final static String DEFAULT_VALUE_KEYTEXT = "default_value_5676";
|
||||
|
||||
public final static FlightConfigurationID ERROR_CONFIGURATION_FCID = new FlightConfigurationID( FlightConfigurationID.ERROR_CONFIGURATION_KEYTEXT);
|
||||
public final static FlightConfigurationID DEFAULT_CONFIGURATION_FCID = new FlightConfigurationID( FlightConfigurationID.DEFAULT_CONFIGURATION_KEYTEXT );
|
||||
|
@ -219,14 +219,10 @@ public class FlightConfigurationSet<E extends FlightConfigurableParameter<E>> im
|
||||
System.err.println("====== Dumping ConfigurationSet for comp: '"+this.component.getName()+"' of type: "+this.component.getClass().getSimpleName()+" ======");
|
||||
System.err.println(" >> FlightConfigurationSet ("+this.size()+ " configurations)");
|
||||
|
||||
for( FlightConfigurationID loopFCID : this.map.keySet()){
|
||||
for( FlightConfigurationID loopFCID : this.getSortedConfigurationIDs()){
|
||||
String shortKey = loopFCID.toShortKey();
|
||||
|
||||
|
||||
E inst = this.map.get(loopFCID);
|
||||
if( this.isDefault(inst)){
|
||||
shortKey = "*"+shortKey+"*";
|
||||
}
|
||||
String designation;
|
||||
if( inst instanceof FlightConfiguration){
|
||||
FlightConfiguration fc = (FlightConfiguration) inst;
|
||||
|
@ -22,15 +22,14 @@ public class RenameConfigDialog extends JDialog {
|
||||
private static final long serialVersionUID = -5423008694485357248L;
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
public RenameConfigDialog(final Window parent, final Rocket rocket) {
|
||||
public RenameConfigDialog(final Window parent, final Rocket rocket, final FlightConfigurationID fcid) {
|
||||
super(parent, trans.get("RenameConfigDialog.title"), Dialog.ModalityType.APPLICATION_MODAL);
|
||||
final FlightConfigurationID configId = rocket.getDefaultConfiguration().getFlightConfigurationID();
|
||||
|
||||
JPanel panel = new JPanel(new MigLayout("fill"));
|
||||
|
||||
panel.add(new JLabel(trans.get("RenameConfigDialog.lbl.name")), "span, wrap rel");
|
||||
|
||||
final JTextField textbox = new JTextField(rocket.getFlightConfiguration(configId).getName());
|
||||
final JTextField textbox = new JTextField(rocket.getFlightConfiguration(fcid).getName());
|
||||
panel.add(textbox, "span, w 200lp, growx, wrap para");
|
||||
|
||||
panel.add(new JPanel(), "growx");
|
||||
@ -40,24 +39,23 @@ public class RenameConfigDialog extends JDialog {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String newName = textbox.getText();
|
||||
|
||||
rocket.getFlightConfiguration(configId).setName( newName);
|
||||
rocket.getFlightConfiguration(fcid).setName( newName);
|
||||
System.err.println(" << just renamed: "+fcid.toShortKey()+" with: "+newName+" to: "+ rocket.getFlightConfiguration(fcid).getName());
|
||||
rocket.getConfigurationSet().printDebug();
|
||||
RenameConfigDialog.this.setVisible(false);
|
||||
}
|
||||
});
|
||||
panel.add(okButton);
|
||||
|
||||
// JButton renameToDefaultButton = new JButton(trans.get("RenameConfigDialog.but.reset")+" (in Devel: is this fixed yet?)");
|
||||
// renameToDefaultButton.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// // why would I bother setting to null?
|
||||
// System.err.println(" NYI: defaultButton (ln:55) in RenameConfigDialog... not sure what it's for...");
|
||||
// //rocket.getFlightConfiguration(configId).setName(null);
|
||||
// RenameConfigDialog.this.setVisible(false);
|
||||
// }
|
||||
// });
|
||||
// panel.add(renameToDefaultButton);
|
||||
JButton renameToDefaultButton = new JButton(trans.get("RenameConfigDialog.but.reset"));
|
||||
renameToDefaultButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
rocket.getFlightConfiguration(fcid).setName(null);
|
||||
RenameConfigDialog.this.setVisible(false);
|
||||
}
|
||||
});
|
||||
panel.add(renameToDefaultButton);
|
||||
|
||||
JButton cancel = new JButton(trans.get("button.cancel"));
|
||||
cancel.addActionListener(new ActionListener() {
|
||||
|
@ -155,18 +155,17 @@ public abstract class FlightConfigurablePanel<T extends FlightConfigurableCompon
|
||||
Object tableValue = table.getModel().getValueAt(row, col);
|
||||
if ( tableValue instanceof Pair ) {
|
||||
Pair<FlightConfigurationID,T> selectedComponent = (Pair<FlightConfigurationID,T>) tableValue;
|
||||
return selectedComponent.getU();
|
||||
} else if ( tableValue instanceof String ){
|
||||
// DEPRECATED
|
||||
System.err.println(" found String instance where expected a Pair....Bug!");
|
||||
throw new IllegalStateException("!!Found String instance where expected a Pair....Bug!");
|
||||
// this really should be un-implemented.
|
||||
//return new FlightConfigurationID((String) tableValue);
|
||||
FlightConfigurationID fcid = selectedComponent.getU();
|
||||
return fcid;
|
||||
} else if ( tableValue instanceof FlightConfigurationID ){
|
||||
return (FlightConfigurationID) tableValue;
|
||||
}
|
||||
return FlightConfigurationID.ERROR_CONFIGURATION_FCID;
|
||||
}
|
||||
|
||||
protected abstract class FlightConfigurableCellRenderer extends DefaultTableCellRenderer {
|
||||
private static final long serialVersionUID = 2026945220957913776L;
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
@ -156,11 +156,12 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
||||
}
|
||||
|
||||
private void renameConfiguration() {
|
||||
new RenameConfigDialog(SwingUtilities.getWindowAncestor(this), rocket).setVisible(true);
|
||||
FlightConfigurationID currentId = this.motorConfigurationPanel.getSelectedConfigurationId();
|
||||
new RenameConfigDialog(SwingUtilities.getWindowAncestor(this), rocket, currentId).setVisible(true);
|
||||
}
|
||||
|
||||
private void removeConfiguration() {
|
||||
FlightConfigurationID currentId = rocket.getDefaultConfiguration().getFlightConfigurationID();
|
||||
FlightConfigurationID currentId = this.motorConfigurationPanel.getSelectedConfigurationId();
|
||||
if (currentId == null)
|
||||
return;
|
||||
document.removeFlightConfigurationAndSimulations(currentId);
|
||||
|
Loading…
x
Reference in New Issue
Block a user