[bugfix] Flight Configuration management bugs fixed
Removed "Rename Configuration" Button => "Reset to Default" (is now obsolete) Re-implemented 'create new configuration' button
This commit is contained in:
parent
0a55f59548
commit
059c9cf0db
@ -164,6 +164,10 @@ public class MotorInstance implements FlightConfigurableParameter<MotorInstance>
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty(){
|
||||||
|
return this == MotorInstance.EMPTY_INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals( Object other ){
|
public boolean equals( Object other ){
|
||||||
if( other == null )
|
if( other == null )
|
||||||
|
@ -29,9 +29,9 @@ import net.sf.openrocket.util.StateChangeListener;
|
|||||||
public class FlightConfiguration implements FlightConfigurableParameter<FlightConfiguration>, ChangeSource, ComponentChangeListener, Monitorable {
|
public class FlightConfiguration implements FlightConfigurableParameter<FlightConfiguration>, ChangeSource, ComponentChangeListener, Monitorable {
|
||||||
private static final Logger log = LoggerFactory.getLogger(FlightConfiguration.class);
|
private static final Logger log = LoggerFactory.getLogger(FlightConfiguration.class);
|
||||||
|
|
||||||
public final static String DEFAULT_CONFIGURATION_NAME = "default configuration";
|
public final static String DEFAULT_CONFIGURATION_NAME = "Default Configuration";
|
||||||
|
|
||||||
protected String configurationName = FlightConfiguration.DEFAULT_CONFIGURATION_NAME;
|
protected String configurationName ;
|
||||||
|
|
||||||
protected final Rocket rocket;
|
protected final Rocket rocket;
|
||||||
protected final FlightConfigurationID fcid;
|
protected final FlightConfigurationID fcid;
|
||||||
@ -62,6 +62,12 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
|
|
||||||
private int modID = 0;
|
private int modID = 0;
|
||||||
|
|
||||||
|
public FlightConfiguration( ){
|
||||||
|
this.fcid = FlightConfigurationID.ERROR_CONFIGURATION_ID;
|
||||||
|
this.rocket = new Rocket();
|
||||||
|
this.configurationName = "<ERROR: FlightConfiguration created without an id or rocket instance. ERROR!> ";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new configuration with the specified <code>Rocket</code>.
|
* Create a new configuration with the specified <code>Rocket</code>.
|
||||||
*
|
*
|
||||||
@ -75,6 +81,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
this.fcid = _fcid;
|
this.fcid = _fcid;
|
||||||
}
|
}
|
||||||
this.rocket = rocket;
|
this.rocket = rocket;
|
||||||
|
this.setName( fcid.key);
|
||||||
|
|
||||||
updateStageMap();
|
updateStageMap();
|
||||||
rocket.addComponentChangeListener(this);
|
rocket.addComponentChangeListener(this);
|
||||||
@ -450,6 +457,11 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
return;
|
return;
|
||||||
}else if( "".equals(newName)){
|
}else if( "".equals(newName)){
|
||||||
return;
|
return;
|
||||||
|
}else if( this.getFlightConfigurationID().equals( FlightConfigurationID.DEFAULT_CONFIGURATION_ID)){
|
||||||
|
this.configurationName = FlightConfiguration.DEFAULT_CONFIGURATION_NAME;
|
||||||
|
return;
|
||||||
|
}else if( ! this.getFlightConfigurationID().isValid()){
|
||||||
|
return;
|
||||||
}else if( newName.equals(this.configurationName)){
|
}else if( newName.equals(this.configurationName)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,14 @@ public interface MotorMount extends ChangeSource, FlightConfigurableComponent {
|
|||||||
*/
|
*/
|
||||||
public MotorInstance getDefaultMotorInstance();
|
public MotorInstance getDefaultMotorInstance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default implementatino supplied by RocketComponent (returns 1);
|
||||||
|
*
|
||||||
|
* @return number of times this component is instanced
|
||||||
|
*/
|
||||||
|
public int getInstanceCount();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param testInstance instance to test
|
* @param testInstance instance to test
|
||||||
|
@ -84,9 +84,9 @@ public class Rocket extends RocketComponent {
|
|||||||
aeroModID = modID;
|
aeroModID = modID;
|
||||||
treeModID = modID;
|
treeModID = modID;
|
||||||
functionalModID = modID;
|
functionalModID = modID;
|
||||||
FlightConfiguration defaultConfiguration = new FlightConfiguration(null, this);
|
|
||||||
//FlightConfigurationID defaultFCID = defaultConfiguration.getFlightConfigurationID();
|
FlightConfigurationID defaultFCID = FlightConfigurationID.DEFAULT_CONFIGURATION_ID;
|
||||||
defaultConfiguration.setName( "Default Configuration" );
|
FlightConfiguration defaultConfiguration = new FlightConfiguration( defaultFCID, this);
|
||||||
this.configurations = new FlightConfigurationSet<FlightConfiguration>(this, ComponentChangeEvent.ALL_CHANGE, defaultConfiguration);
|
this.configurations = new FlightConfigurationSet<FlightConfiguration>(this, ComponentChangeEvent.ALL_CHANGE, defaultConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,17 +47,17 @@ public class RenameConfigDialog extends JDialog {
|
|||||||
});
|
});
|
||||||
panel.add(okButton);
|
panel.add(okButton);
|
||||||
|
|
||||||
JButton defaultButton = new JButton(trans.get("RenameConfigDialog.but.reset")+" (NYI)- what do I do? ");
|
// JButton renameToDefaultButton = new JButton(trans.get("RenameConfigDialog.but.reset")+" (in Devel: is this fixed yet?)");
|
||||||
defaultButton.addActionListener(new ActionListener() {
|
// renameToDefaultButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
// @Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
// public void actionPerformed(ActionEvent e) {
|
||||||
// why would I bother setting to null?
|
// // why would I bother setting to null?
|
||||||
System.err.println(" NYI: defaultButton (ln:55) in RenameConfigDialog... not sure what it's for...");
|
// System.err.println(" NYI: defaultButton (ln:55) in RenameConfigDialog... not sure what it's for...");
|
||||||
//rocket.getFlightConfiguration(configId).setName(null);
|
// //rocket.getFlightConfiguration(configId).setName(null);
|
||||||
RenameConfigDialog.this.setVisible(false);
|
// RenameConfigDialog.this.setVisible(false);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
panel.add(defaultButton);
|
// panel.add(renameToDefaultButton);
|
||||||
|
|
||||||
JButton cancel = new JButton(trans.get("button.cancel"));
|
JButton cancel = new JButton(trans.get("button.cancel"));
|
||||||
cancel.addActionListener(new ActionListener() {
|
cancel.addActionListener(new ActionListener() {
|
||||||
|
@ -27,7 +27,6 @@ import net.sf.openrocket.startup.Application;
|
|||||||
import net.sf.openrocket.util.StateChangeListener;
|
import net.sf.openrocket.util.StateChangeListener;
|
||||||
|
|
||||||
public class FlightConfigurationPanel extends JPanel implements StateChangeListener {
|
public class FlightConfigurationPanel extends JPanel implements StateChangeListener {
|
||||||
|
|
||||||
private static final long serialVersionUID = -5467500312467789009L;
|
private static final long serialVersionUID = -5467500312467789009L;
|
||||||
//private static final Logger log = LoggerFactory.getLogger(FlightConfigurationPanel.class);
|
//private static final Logger log = LoggerFactory.getLogger(FlightConfigurationPanel.class);
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
@ -124,9 +123,10 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addConfiguration() {
|
private void addConfiguration() {
|
||||||
|
FlightConfigurationID newFCID = new FlightConfigurationID();
|
||||||
|
FlightConfiguration newConfig = new FlightConfiguration( newFCID, rocket );
|
||||||
|
|
||||||
//FlightConfiguration newConfig = new FlightConfiguration( rocket );
|
rocket.setFlightConfiguration(newFCID, newConfig);
|
||||||
//FlightConfigurationID newFCID = newConfig.getFlightConfigurationID();
|
|
||||||
|
|
||||||
// Create a new simulation for this configuration.
|
// Create a new simulation for this configuration.
|
||||||
createSimulationForNewConfiguration();
|
createSimulationForNewConfiguration();
|
||||||
|
@ -31,13 +31,13 @@ import net.sf.openrocket.rocketcomponent.FlightConfigurationID;
|
|||||||
import net.sf.openrocket.rocketcomponent.IgnitionEvent;
|
import net.sf.openrocket.rocketcomponent.IgnitionEvent;
|
||||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
|
||||||
import net.sf.openrocket.unit.UnitGroup;
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
import net.sf.openrocket.util.Chars;
|
import net.sf.openrocket.util.Chars;
|
||||||
import net.sf.openrocket.util.Coordinate;
|
|
||||||
|
|
||||||
public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount> {
|
public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -5046535300435793744L;
|
||||||
|
|
||||||
private static final String NONE = trans.get("edtmotorconfdlg.tbl.None");
|
private static final String NONE = trans.get("edtmotorconfdlg.tbl.None");
|
||||||
|
|
||||||
private final JButton selectMotorButton, removeMotorButton, selectIgnitionButton, resetIgnitionButton;
|
private final JButton selectMotorButton, removeMotorButton, selectIgnitionButton, resetIgnitionButton;
|
||||||
@ -61,6 +61,8 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
|||||||
subpanel.add(label, "wrap");
|
subpanel.add(label, "wrap");
|
||||||
|
|
||||||
MotorMountConfigurationPanel mountConfigPanel = new MotorMountConfigurationPanel(this,rocket) {
|
MotorMountConfigurationPanel mountConfigPanel = new MotorMountConfigurationPanel(this,rocket) {
|
||||||
|
private static final long serialVersionUID = -238261338962282816L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataChanged() {
|
public void onDataChanged() {
|
||||||
MotorConfigurationPanel.this.fireTableDataChanged();
|
MotorConfigurationPanel.this.fireTableDataChanged();
|
||||||
@ -139,6 +141,8 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
|||||||
//// Motor selection table.
|
//// Motor selection table.
|
||||||
configurationTableModel = new FlightConfigurableTableModel<MotorMount>(MotorMount.class,rocket) {
|
configurationTableModel = new FlightConfigurableTableModel<MotorMount>(MotorMount.class,rocket) {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -1210899988369000567L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean includeComponent(MotorMount component) {
|
protected boolean includeComponent(MotorMount component) {
|
||||||
return component.isMotorMount();
|
return component.isMotorMount();
|
||||||
@ -201,8 +205,9 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
|||||||
MotorMount mount = getSelectedComponent();
|
MotorMount mount = getSelectedComponent();
|
||||||
if (id == null || mount == null)
|
if (id == null || mount == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MotorInstance inst = mount.getMotorInstance(id);
|
MotorInstance inst = mount.getMotorInstance(id);
|
||||||
|
if( inst.isEmpty() )
|
||||||
|
return;
|
||||||
|
|
||||||
motorChooserDialog.setMotorMountAndConfig(mount, id);
|
motorChooserDialog.setMotorMountAndConfig(mount, id);
|
||||||
|
|
||||||
@ -263,13 +268,14 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
|||||||
|
|
||||||
|
|
||||||
private class MotorTableCellRenderer extends FlightConfigurablePanel<MotorMount>.FlightConfigurableCellRenderer {
|
private class MotorTableCellRenderer extends FlightConfigurablePanel<MotorMount>.FlightConfigurableCellRenderer {
|
||||||
|
private static final long serialVersionUID = -7462331042920067984L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JLabel format( MotorMount mount, FlightConfigurationID configId, JLabel l ) {
|
protected JLabel format( MotorMount mount, FlightConfigurationID configId, JLabel l ) {
|
||||||
JLabel label = new JLabel();
|
JLabel label = new JLabel();
|
||||||
label.setLayout(new BoxLayout(label, BoxLayout.X_AXIS));
|
label.setLayout(new BoxLayout(label, BoxLayout.X_AXIS));
|
||||||
MotorInstance motorConfig = mount.getMotorInstance( configId);
|
MotorInstance curMotor = mount.getMotorInstance( configId);
|
||||||
String motorString = getMotorSpecification(mount, motorConfig);
|
String motorString = getMotorSpecification( curMotor );
|
||||||
JLabel motorDescriptionLabel = new JLabel(motorString);
|
JLabel motorDescriptionLabel = new JLabel(motorString);
|
||||||
label.add(motorDescriptionLabel);
|
label.add(motorDescriptionLabel);
|
||||||
label.add( Box.createRigidArea(new Dimension(10,0)));
|
label.add( Box.createRigidArea(new Dimension(10,0)));
|
||||||
@ -279,25 +285,22 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
|||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMotorSpecification(MotorMount mount, MotorInstance motorConfig) {
|
private String getMotorSpecification(MotorInstance curMotorInstance ) {
|
||||||
Motor motor = motorConfig.getMotor();
|
if( curMotorInstance.isEmpty()){
|
||||||
|
|
||||||
if (motor == null)
|
|
||||||
return NONE;
|
return NONE;
|
||||||
|
}
|
||||||
|
|
||||||
String str = motor.getDesignation(motorConfig.getEjectionDelay());
|
MotorMount mount = curMotorInstance.getMount();
|
||||||
int count = getMountMultiplicity(mount);
|
Motor motor = curMotorInstance.getMotor();
|
||||||
|
|
||||||
|
String str = motor.getDesignation(curMotorInstance.getEjectionDelay());
|
||||||
|
int count = mount.getInstanceCount();
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
str = "" + count + Chars.TIMES + " " + str;
|
str = "" + count + Chars.TIMES + " " + str;
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getMountMultiplicity(MotorMount mount) {
|
|
||||||
RocketComponent c = (RocketComponent) mount;
|
|
||||||
return c.toAbsolute(Coordinate.NUL).length;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JLabel getIgnitionEventString(FlightConfigurationID id, MotorMount mount) {
|
private JLabel getIgnitionEventString(FlightConfigurationID id, MotorMount mount) {
|
||||||
MotorInstance curInstance = mount.getMotorInstance(id);
|
MotorInstance curInstance = mount.getMotorInstance(id);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user