diff --git a/core/src/net/sf/openrocket/motor/MotorInstance.java b/core/src/net/sf/openrocket/motor/MotorInstance.java index cc855d39f..a18b3f98d 100644 --- a/core/src/net/sf/openrocket/motor/MotorInstance.java +++ b/core/src/net/sf/openrocket/motor/MotorInstance.java @@ -164,6 +164,10 @@ public class MotorInstance implements FlightConfigurableParameter return false; } + public boolean isEmpty(){ + return this == MotorInstance.EMPTY_INSTANCE; + } + @Override public boolean equals( Object other ){ if( other == null ) diff --git a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java index 228871729..2f7e5f77e 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java @@ -29,9 +29,9 @@ import net.sf.openrocket.util.StateChangeListener; public class FlightConfiguration implements FlightConfigurableParameter, ChangeSource, ComponentChangeListener, Monitorable { 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 FlightConfigurationID fcid; @@ -62,6 +62,12 @@ public class FlightConfiguration implements FlightConfigurableParameterRocket. * @@ -75,6 +81,7 @@ public class FlightConfiguration implements FlightConfigurableParameter(this, ComponentChangeEvent.ALL_CHANGE, defaultConfiguration); } diff --git a/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/RenameConfigDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/RenameConfigDialog.java index adb71c53b..303aa54e6 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/RenameConfigDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/RenameConfigDialog.java @@ -47,17 +47,17 @@ public class RenameConfigDialog extends JDialog { }); panel.add(okButton); - JButton defaultButton = new JButton(trans.get("RenameConfigDialog.but.reset")+" (NYI)- what do I do? "); - defaultButton.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(defaultButton); +// 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 cancel = new JButton(trans.get("button.cancel")); cancel.addActionListener(new ActionListener() { diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java index f3fc68cad..73dcf1dfe 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java @@ -27,7 +27,6 @@ import net.sf.openrocket.startup.Application; import net.sf.openrocket.util.StateChangeListener; public class FlightConfigurationPanel extends JPanel implements StateChangeListener { - private static final long serialVersionUID = -5467500312467789009L; //private static final Logger log = LoggerFactory.getLogger(FlightConfigurationPanel.class); private static final Translator trans = Application.getTranslator(); @@ -124,9 +123,10 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe } private void addConfiguration() { + FlightConfigurationID newFCID = new FlightConfigurationID(); + FlightConfiguration newConfig = new FlightConfiguration( newFCID, rocket ); - //FlightConfiguration newConfig = new FlightConfiguration( rocket ); - //FlightConfigurationID newFCID = newConfig.getFlightConfigurationID(); + rocket.setFlightConfiguration(newFCID, newConfig); // Create a new simulation for this configuration. createSimulationForNewConfiguration(); diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java index ef1e59163..3b415abf0 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java @@ -31,13 +31,13 @@ import net.sf.openrocket.rocketcomponent.FlightConfigurationID; import net.sf.openrocket.rocketcomponent.IgnitionEvent; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.Rocket; -import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.unit.UnitGroup; import net.sf.openrocket.util.Chars; -import net.sf.openrocket.util.Coordinate; public class MotorConfigurationPanel extends FlightConfigurablePanel { + private static final long serialVersionUID = -5046535300435793744L; + private static final String NONE = trans.get("edtmotorconfdlg.tbl.None"); private final JButton selectMotorButton, removeMotorButton, selectIgnitionButton, resetIgnitionButton; @@ -61,6 +61,8 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel subpanel.add(label, "wrap"); MotorMountConfigurationPanel mountConfigPanel = new MotorMountConfigurationPanel(this,rocket) { + private static final long serialVersionUID = -238261338962282816L; + @Override public void onDataChanged() { MotorConfigurationPanel.this.fireTableDataChanged(); @@ -139,6 +141,8 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel //// Motor selection table. configurationTableModel = new FlightConfigurableTableModel(MotorMount.class,rocket) { + private static final long serialVersionUID = -1210899988369000567L; + @Override protected boolean includeComponent(MotorMount component) { return component.isMotorMount(); @@ -201,8 +205,9 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel MotorMount mount = getSelectedComponent(); if (id == null || mount == null) return; - MotorInstance inst = mount.getMotorInstance(id); + if( inst.isEmpty() ) + return; motorChooserDialog.setMotorMountAndConfig(mount, id); @@ -263,13 +268,14 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel private class MotorTableCellRenderer extends FlightConfigurablePanel.FlightConfigurableCellRenderer { + private static final long serialVersionUID = -7462331042920067984L; @Override protected JLabel format( MotorMount mount, FlightConfigurationID configId, JLabel l ) { JLabel label = new JLabel(); label.setLayout(new BoxLayout(label, BoxLayout.X_AXIS)); - MotorInstance motorConfig = mount.getMotorInstance( configId); - String motorString = getMotorSpecification(mount, motorConfig); + MotorInstance curMotor = mount.getMotorInstance( configId); + String motorString = getMotorSpecification( curMotor ); JLabel motorDescriptionLabel = new JLabel(motorString); label.add(motorDescriptionLabel); label.add( Box.createRigidArea(new Dimension(10,0))); @@ -279,25 +285,22 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel return label; } - private String getMotorSpecification(MotorMount mount, MotorInstance motorConfig) { - Motor motor = motorConfig.getMotor(); - - if (motor == null) + private String getMotorSpecification(MotorInstance curMotorInstance ) { + if( curMotorInstance.isEmpty()){ return NONE; + } - String str = motor.getDesignation(motorConfig.getEjectionDelay()); - int count = getMountMultiplicity(mount); + MotorMount mount = curMotorInstance.getMount(); + Motor motor = curMotorInstance.getMotor(); + + String str = motor.getDesignation(curMotorInstance.getEjectionDelay()); + int count = mount.getInstanceCount(); if (count > 1) { str = "" + count + Chars.TIMES + " " + 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) { MotorInstance curInstance = mount.getMotorInstance(id);