[Bugfix] More Motor Ignition UI issues

- Selecting an option in the Ignition Chooser dialog updates itself
- When updating all motor ignition events, the default is also updated.
- removed isDefaultMotorInstance from MotorMounts
    - default is always the Empty Instance, which has a built in test: 'isEmpty'
- in MotorConfigurationPanel: ignition events are gray out, if they match the default ignition event
This commit is contained in:
Daniel_M_Williams 2015-10-23 17:49:38 -04:00
parent 64417ca93c
commit d977733cf5
8 changed files with 44 additions and 47 deletions

View File

@ -236,6 +236,10 @@ public class MotorInstance implements FlightConfigurableParameter<MotorInstance>
}
}
@Override
public String toString(){
return MotorInstanceId.EMPTY_ID.getComponentId();
}
public int getModID() {
return modID;

View File

@ -366,11 +366,6 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
return this.motors.getDefault();
}
@Override
public boolean isDefaultMotorInstance( final MotorInstance testInstance){
return this.motors.getDefault() == testInstance;
}
@Override
public MotorInstance getMotorInstance( final FlightConfigurationID fcid){
return this.motors.get(fcid);

View File

@ -260,11 +260,6 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
return this.motors.getDefault();
}
@Override
public boolean isDefaultMotorInstance( final MotorInstance testInstance){
return this.motors.isDefault( testInstance);
}
@Override
public MotorInstance getMotorInstance( final FlightConfigurationID fcid){
return this.motors.get(fcid);
@ -377,8 +372,9 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
return copy;
}
public void printMotorDebug( FlightConfigurationID fcid ){
System.err.println(this.motors.toDebug());
@Override
public String toMotorDebug( ){
return this.motors.toDebug();
}
@Override

View File

@ -34,8 +34,10 @@ public class MotorConfigurationSet extends ParameterSet<MotorInstance> {
@Override
public String toDebug(){
StringBuilder buffer = new StringBuilder();
buffer.append("====== Dumping MotorConfigurationSet for mount '"+this.component.getName()+"' of type: "+this.component.getClass().getSimpleName()+" ======");
buffer.append(" >> motorSet ("+this.size()+ " motors)");
buffer.append("====== Dumping MotorConfigurationSet for mount '"+this.component.getName()+"' of type: "+this.component.getClass().getSimpleName()+" ======\n");
buffer.append(" >> motorSet ("+this.size()+ " motors)\n");
MotorInstance emptyInstance = this.getDefault();
buffer.append(" >> (["+emptyInstance.toString()+"]= @ "+ emptyInstance.getIgnitionEvent().name +" +"+emptyInstance.getIgnitionDelay()+"sec )\n");
for( FlightConfigurationID loopFCID : this.map.keySet()){
String shortKey = loopFCID.getShortKey();
@ -47,7 +49,12 @@ public class MotorConfigurationSet extends ParameterSet<MotorInstance> {
}else{
designation = curInstance.getMotor().getDesignation(curInstance.getEjectionDelay());
}
buffer.append(" >> ["+shortKey+"]= "+designation);
String ignition = curInstance.getIgnitionEvent().name;
double delay = curInstance.getIgnitionDelay();
if( 0 != delay ){
ignition += " +"+delay;
}
buffer.append(" >> ["+shortKey+"]= "+designation+" @ "+ignition+"\n");
}
return buffer.toString();
}

View File

@ -54,14 +54,6 @@ public interface MotorMount extends ChangeSource, FlightConfigurableComponent {
*/
public int getInstanceCount();
/**
*
* @param testInstance instance to test
* @return if this motor is the default instance
*/
public boolean isDefaultMotorInstance( final MotorInstance testInstance);
/**
*
* @param fcid id for which to return the motor (null retrieves the default)
@ -116,4 +108,10 @@ public interface MotorMount extends ChangeSource, FlightConfigurableComponent {
*/
public Coordinate getMotorPosition(FlightConfigurationID id);
/**
* Development / Debug method.
*
* @return table describing all the motors configured for this mount.
*/
public String toMotorDebug( );
}

View File

@ -82,6 +82,7 @@ public class EnumModel<T extends Enum<T>> extends AbstractListModel
return currentValue;
}
@Override
public void setSelectedItem(Object item) {
if (item == null) {
@ -101,6 +102,8 @@ public class EnumModel<T extends Enum<T>> extends AbstractListModel
// Comparison with == ok, since both are enums
if (currentValue == item)
return;
// @SuppressWarnings("unchecked")
this.currentValue = (Enum<T>) item;
setMethod.invoke(source, item);
}

View File

@ -53,7 +53,7 @@ public class IgnitionSelectionDialog extends JDialog {
JPanel panel = new JPanel(new MigLayout("fill"));
// Edit default or override option
boolean isDefault = curMount.isDefaultMotorInstance( curMotorInstance );
boolean isDefault = curMotorInstance.isEmpty();
panel.add(new JLabel(trans.get("IgnitionSelectionDialog.opt.title")), "span, wrap rel");
final JRadioButton defaultButton = new JRadioButton(trans.get("IgnitionSelectionDialog.opt.default"), isDefault);
panel.add(defaultButton, "span, gapleft para, wrap rel");
@ -101,11 +101,16 @@ public class IgnitionSelectionDialog extends JDialog {
public void actionPerformed(ActionEvent e) {
if (defaultButton.isSelected()) {
// change the default...
IgnitionEvent cie = curMotorInstance.getIgnitionEvent();
// retrieve our just-set values
double cid = curMotorInstance.getIgnitionDelay();
IgnitionEvent cie = curMotorInstance.getIgnitionEvent();
// and change all remaining configs?
// update the default instance
final MotorInstance defaultMotorInstance = curMount.getDefaultMotorInstance();
defaultMotorInstance.setIgnitionDelay( cid);
defaultMotorInstance.setIgnitionEvent( cie);
// and change all remaining configs
// this seems like odd behavior to me, but it matches the text on the UI dialog popup. -teyrana (equipoise@gmail.com)
Iterator<MotorInstance> iter = curMount.getMotorIterator();
while( iter.hasNext() ){
@ -114,16 +119,13 @@ public class IgnitionSelectionDialog extends JDialog {
next.setIgnitionEvent( cie);
}
final MotorInstance defaultMotorInstance = curMount.getDefaultMotorInstance();
System.err.println("setting default motor ignition ("+defaultMotorInstance.getMotorID().toString()+") to: ");
System.err.println(" event: "+defaultMotorInstance.getIgnitionEvent()+" w/delay: "+defaultMotorInstance.getIgnitionDelay());
}
// else {
// System.err.println("setting default motor ignition ("+defaultMotorInstance.getMotorID().toString()+") to: ");
// System.err.println(" event: "+defaultMotorInstance.getIgnitionEvent().name+" w/delay: "+defaultMotorInstance.getIgnitionDelay());
// }else {
// System.err.println("setting motor ignition to.... new values: ");
// //destMotorInstance.setIgnitionEvent((IgnitionEvent)eventBox.getSelectedItem());
// System.err.println(" "+curMotorInstance.getIgnitionEvent()+" w/ "+curMotorInstance.getIgnitionDelay());
// }
}
IgnitionSelectionDialog.this.setVisible(false);
}
});

View File

@ -288,15 +288,6 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
MotorInstance curMotor = mount.getMotorInstance( configId);
String motorString = getMotorSpecification( curMotor );
// if( mount instanceof InnerTube ){
// System.err.println("Formatting Cell: fcid="+configId.key.substring(0, 8));
// System.err.println( ((InnerTube) mount).toDebugString() );
// }
// System.err.println("rendering "+configId.getShortKey()+" cell: " );
// if( rocket.getConfigurationSet().isDefault( configId) ){
// String newText = label.getText() + " (default)";
// System.err.println(" "+label.getText()+" >> "+newText);
// }
JLabel motorDescriptionLabel = new JLabel(motorString);
label.add(motorDescriptionLabel);
@ -327,11 +318,12 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
}
private JLabel getIgnitionEventString(FlightConfigurationID id, MotorMount mount) {
MotorInstance defInstance = mount.getDefaultMotorInstance();
MotorInstance curInstance = mount.getMotorInstance(id);
IgnitionEvent ignitionEvent = curInstance.getIgnitionEvent();
Double ignitionDelay = curInstance.getIgnitionDelay();
boolean isDefault = mount.isDefaultMotorInstance(curInstance);
boolean isDefault = (defInstance.getIgnitionEvent() == curInstance.getIgnitionEvent());
JLabel label = new JLabel();
String str = trans.get("MotorMount.IgnitionEvent.short." + ignitionEvent.name());