From b02e164bce96e6f7bb46af0485cc2345ae7abf8a Mon Sep 17 00:00:00 2001 From: Daniel_M_Williams Date: Sat, 16 Apr 2016 11:10:33 -0400 Subject: [PATCH] [bugfix] RocketPanel configuration list now updates changes - Pulled JComboBoxModel into its own class: ConfigurationModel -- removed Rocket.toConfigArray() --> getFlightConfigurationByIndex(int,bool) -Refactored document.getDefaultConfiguration -> getSelected... -- because that's what it does. Default is a different thing. -minor: minor spelling errors and unused fields/functions --- .../document/OpenRocketDocument.java | 2 +- .../openrocket/importt/OpenRocketLoader.java | 2 +- .../rocketcomponent/FlightConfiguration.java | 28 ++++---- .../sf/openrocket/rocketcomponent/Rocket.java | 42 ++++++----- .../FlightConfigurationTest.java | 47 ++++++------ .../gui/components/ConfigurationModel.java | 71 +++++++++++++++++++ .../gui/dialogs/ComponentAnalysisDialog.java | 21 +++--- .../gui/figure3d/photo/PhotoPanel.java | 2 +- .../FlightConfigurationPanel.java | 1 + .../gui/scalefigure/RocketPanel.java | 57 ++++++++------- .../gui/simulation/SimulationEditDialog.java | 8 ++- 11 files changed, 182 insertions(+), 99 deletions(-) create mode 100644 swing/src/net/sf/openrocket/gui/components/ConfigurationModel.java diff --git a/core/src/net/sf/openrocket/document/OpenRocketDocument.java b/core/src/net/sf/openrocket/document/OpenRocketDocument.java index 15d63c32c..376728c21 100644 --- a/core/src/net/sf/openrocket/document/OpenRocketDocument.java +++ b/core/src/net/sf/openrocket/document/OpenRocketDocument.java @@ -164,7 +164,7 @@ public class OpenRocketDocument implements ComponentChangeListener { } - public FlightConfiguration getDefaultConfiguration() { + public FlightConfiguration getSelectedConfiguration() { return rocket.getSelectedConfiguration(); } diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java b/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java index 8bfba9ae7..7662c80ad 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/OpenRocketLoader.java @@ -53,7 +53,7 @@ public class OpenRocketLoader extends AbstractRocketLoader { throw new RocketLoadException("Malformed XML in input.", e); } - doc.getDefaultConfiguration().setAllStages(); + doc.getSelectedConfiguration().setAllStages(); // Deduce suitable time skip double timeSkip = StorageOptions.SIMULATION_DATA_NONE; diff --git a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java index fc562d5e2..a8d48be8e 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java @@ -6,7 +6,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Queue; -import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,10 +51,6 @@ public class FlightConfiguration implements FlightConfigurableParameterFlightConfigurationId.DEFAULT_VALUE_FCID ID cannot be removed, @@ -668,7 +663,7 @@ public class Rocket extends RocketComponent { return this.getFlightConfiguration(fcid); } FlightConfiguration nextConfig = new FlightConfiguration(this, fcid); - this.configSet.set(nextConfig.getFlightConfigurationID(), nextConfig); + this.configSet.set(nextConfig.getId(), nextConfig); fireComponentChangeEvent(ComponentChangeEvent.TREE_CHANGE); return nextConfig; } @@ -685,13 +680,25 @@ public class Rocket extends RocketComponent { return this.configSet.get(fcid); } + public FlightConfiguration getFlightConfigurationByIndex(final int configIndex) { + return getFlightConfigurationByIndex( configIndex, false); + } + /** - * Return a flight configuration. If the supplied index is out of bounds, an exception is thrown. + * Return a flight configuration. If the supplied index is out of bounds, an exception is thrown. + * If the default instance is allowed, the default will be at index 0. * - * @param configIndex the flight configuration index number - * @return a FlightConfiguration instance + * @param includeDefault Whether to allow returning the default instance + * @param configIndex The flight configuration index number + * @return a FlightConfiguration instance */ - public FlightConfiguration getFlightConfiguration(final int configIndex) { + public FlightConfiguration getFlightConfigurationByIndex( int configIndex, final boolean allowDefault ) { + if( allowDefault ){ + if( 0 == configIndex ){ + return configSet.getDefault(); + } + --configIndex; + } return this.configSet.get( this.getId(configIndex)); } @@ -704,7 +711,7 @@ public class Rocket extends RocketComponent { checkState(); this.selectedConfiguration = this.configSet.get( selectId ); fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE); - } + } /** * Associate the given ID and flight configuration. @@ -728,7 +735,6 @@ public class Rocket extends RocketComponent { fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE); } - //////// Obligatory component information @Override public String getComponentName() { diff --git a/core/test/net/sf/openrocket/rocketcomponent/FlightConfigurationTest.java b/core/test/net/sf/openrocket/rocketcomponent/FlightConfigurationTest.java index 8740ad46a..47bcfb3e1 100644 --- a/core/test/net/sf/openrocket/rocketcomponent/FlightConfigurationTest.java +++ b/core/test/net/sf/openrocket/rocketcomponent/FlightConfigurationTest.java @@ -162,23 +162,7 @@ public class FlightConfigurationTest extends BaseTestCase { } @Test - public void testGetNullSelectedConfiguration(){ - Rocket rkt = new Rocket(); - - // PRE-CONDITION: - // test that all configurations correctly loaded: - int expectedConfigCount = 0; - int actualConfigCount = rkt.getConfigurationCount(); - assertThat("number of loaded configuration counts doesn't actually match.", actualConfigCount, equalTo(expectedConfigCount)); - - rkt.getSelectedConfiguration(); - expectedConfigCount = 1; - actualConfigCount = rkt.getConfigurationCount(); - assertThat("createFlightConfiguration with null: doesn't actually work.", actualConfigCount, equalTo(expectedConfigCount)); - } - - @Test - public void testConfigurationSpecific() { + public void testMotorConfigurations() { /* Setup */ Rocket rkt = TestRockets.makeEstesAlphaIII(); @@ -188,6 +172,12 @@ public class FlightConfigurationTest extends BaseTestCase { int actualMotorCount = smmt.getMotorCount(); assertThat("number of motor configurations doesn't match.", actualMotorCount, equalTo(expectedMotorCount)); + } + + @Test + public void testFlightConfigurationGetters(){ + Rocket rkt = TestRockets.makeEstesAlphaIII(); + // test that all configurations correctly loaded: int expectedConfigCount = 5; int actualConfigCount = rkt.getConfigurationCount(); @@ -197,10 +187,25 @@ public class FlightConfigurationTest extends BaseTestCase { assertThat("number of configuration array ids doesn't actually match.", actualConfigCount, equalTo(expectedConfigCount)); - int expectedConfigArraySize = 6; - int actualConfigArraySize = rkt.toConfigArray().length; - assertThat("Size of configuration arrays doesn't actually match.", - actualConfigArraySize, equalTo(expectedConfigArraySize)); + // upon success, these silently complete. + // upon failure, they'll throw exceptions: + rkt.getFlightConfigurationByIndex(4); + rkt.getFlightConfigurationByIndex(5, true); + } + + + @Test(expected=java.lang.IndexOutOfBoundsException.class) + public void testGetFlightConfigurationOutOfBounds(){ + Rocket rkt = TestRockets.makeEstesAlphaIII(); + + // test that all configurations correctly loaded: + int expectedConfigCount = 5; + int actualConfigCount = rkt.getConfigurationCount(); + assertThat("number of loaded configuration counts doesn't actually match.", actualConfigCount, equalTo(expectedConfigCount)); + + // this SHOULD throw an exception -- + // it's out of bounds on, and no configuration exists at index 5. + rkt.getFlightConfigurationByIndex(5); } /** diff --git a/swing/src/net/sf/openrocket/gui/components/ConfigurationModel.java b/swing/src/net/sf/openrocket/gui/components/ConfigurationModel.java new file mode 100644 index 000000000..a7d1219f3 --- /dev/null +++ b/swing/src/net/sf/openrocket/gui/components/ConfigurationModel.java @@ -0,0 +1,71 @@ +package net.sf.openrocket.gui.components; + +import net.sf.openrocket.rocketcomponent.FlightConfigurationId; +import net.sf.openrocket.rocketcomponent.Rocket; +import net.sf.openrocket.rocketcomponent.FlightConfiguration; +import net.sf.openrocket.util.StateChangeListener; + +import javax.swing.*; +import javax.swing.event.ListDataListener; + +import java.util.EventObject; + +public class ConfigurationModel implements ComboBoxModel, StateChangeListener { + + private final Rocket rkt; + + //private FlightConfigurationSelector(){} + + public ConfigurationModel( final Rocket _rkt) { + rkt = _rkt; + } + + + @Override + public void stateChanged(EventObject e) { +// FlightConfiguration newConfig = (FlightConfiguration)this.getSelectedItem(); +// rkt.setSelectedConfiguration( newConfig.getId()); + } + + + @Override + public Object getSelectedItem() { + return rkt.getSelectedConfiguration(); + } + + + @Override + public void setSelectedItem(Object nextItem) { + if( nextItem instanceof FlightConfiguration ){ + FlightConfigurationId selectedId = ((FlightConfiguration)nextItem).getId(); + rkt.setSelectedConfiguration(selectedId); + } + } + + @Override + public void addListDataListener(ListDataListener l) { + // let the rocket send events, if necessary + // ignore any listen requests here... + } + + + public FlightConfiguration getElementAt( final int configIndex) { + return rkt.getFlightConfigurationByIndex(configIndex, true); + } + + + @Override + public int getSize() { + // plus the default config + return rkt.getConfigurationCount()+1; + } + + + @Override + public void removeListDataListener(ListDataListener l) { + // delegate event handling to the rocket + // ignore any listen requests here... + } + + +} diff --git a/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java index 8d7133a88..860f5cdbf 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java @@ -47,6 +47,7 @@ import net.sf.openrocket.gui.adaptors.ColumnTable; import net.sf.openrocket.gui.adaptors.ColumnTableModel; import net.sf.openrocket.gui.adaptors.DoubleModel; import net.sf.openrocket.gui.components.BasicSlider; +import net.sf.openrocket.gui.components.ConfigurationModel; import net.sf.openrocket.gui.components.StageSelector; import net.sf.openrocket.gui.components.StyledLabel; import net.sf.openrocket.gui.components.UnitSelector; @@ -75,7 +76,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe private final FlightConditions conditions; - private final FlightConfiguration configuration; + private final Rocket rkt; private final DoubleModel theta, aoa, mach, roll; private final JToggleButton worstToggle; private boolean fakeChange = false; @@ -105,11 +106,11 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe JPanel panel = new JPanel(new MigLayout("fill")); add(panel); - this.configuration = rocketPanel.getConfiguration(); + rkt = rocketPanel.getDocument().getRocket(); this.aerodynamicCalculator = rocketPanel.getAerodynamicCalculator().newInstance(); - conditions = new FlightConditions(configuration); + conditions = new FlightConditions(rkt.getSelectedConfiguration()); rocketPanel.setCPAOA(0); aoa = new DoubleModel(rocketPanel, "CPAOA", UnitGroup.UNITS_ANGLE, 0, Math.PI); @@ -169,7 +170,6 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe // Stage and motor selection: //// Active stages: panel.add(new JLabel(trans.get("componentanalysisdlg.lbl.activestages")), "spanx, split, gapafter rel"); - Rocket rkt = rocketPanel.getDocument().getRocket(); panel.add(new StageSelector( rkt), "gapafter paragraph"); //// Motor configuration: @@ -177,9 +177,9 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe label.setHorizontalAlignment(JLabel.RIGHT); panel.add(label, "growx, right"); - JComboBox combo = new JComboBox( configuration.getRocket().toConfigArray()); - - panel.add(combo, "wrap"); + final ConfigurationModel configModel = new ConfigurationModel(rkt); + final JComboBox configComboBox = new JComboBox<>(configModel); + panel.add( configComboBox, "wrap"); // Tabbed pane @@ -517,6 +517,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe */ @Override public void stateChanged(EventObject e) { + final FlightConfiguration configuration = rkt.getSelectedConfiguration(); AerodynamicForces forces; WarningSet set = new WarningSet(); conditions.setAOA(aoa.getValue()); @@ -580,12 +581,12 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe data[1] = MassCalcType.LAUNCH_MASS.getCG(motorConfig); } - forces = aeroData.get(configuration.getRocket()); + forces = aeroData.get(rkt); if (forces != null) { Object[] data = new Object[3]; cgData.add(data); - data[0] = configuration.getRocket(); - data[1] = massData.get(configuration.getRocket()); + data[0] = rkt; + data[1] = massData.get(rkt); data[2] = forces; dragData.add(forces); rollData.add(forces); diff --git a/swing/src/net/sf/openrocket/gui/figure3d/photo/PhotoPanel.java b/swing/src/net/sf/openrocket/gui/figure3d/photo/PhotoPanel.java index 5ddcec25a..7e92db8b4 100644 --- a/swing/src/net/sf/openrocket/gui/figure3d/photo/PhotoPanel.java +++ b/swing/src/net/sf/openrocket/gui/figure3d/photo/PhotoPanel.java @@ -91,7 +91,7 @@ public class PhotoPanel extends JPanel implements GLEventListener { ((GLAutoDrawable) canvas).invoke(false, new GLRunnable() { @Override public boolean run(final GLAutoDrawable drawable) { - PhotoPanel.this.configuration = doc.getDefaultConfiguration(); + PhotoPanel.this.configuration = doc.getSelectedConfiguration(); cachedBounds = null; rr = new RealisticRenderer(doc); rr.init(drawable); 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 724ed3b95..607e978fe 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java @@ -26,6 +26,7 @@ import net.sf.openrocket.rocketvisitors.ListMotorMounts; import net.sf.openrocket.startup.Application; import net.sf.openrocket.util.StateChangeListener; +@SuppressWarnings("serial") public class FlightConfigurationPanel extends JPanel implements StateChangeListener { private static final Translator trans = Application.getTranslator(); diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java index a843a00e8..f61bc3a63 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java @@ -5,8 +5,6 @@ import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Font; import java.awt.Point; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.InputEvent; import java.awt.event.MouseEvent; import java.util.ArrayList; @@ -42,6 +40,7 @@ import net.sf.openrocket.gui.adaptors.DoubleModel; import net.sf.openrocket.gui.components.BasicSlider; import net.sf.openrocket.gui.components.StageSelector; import net.sf.openrocket.gui.components.UnitSelector; +import net.sf.openrocket.gui.components.ConfigurationModel; import net.sf.openrocket.gui.configdialog.ComponentConfigDialog; import net.sf.openrocket.gui.figure3d.RocketFigure3d; import net.sf.openrocket.gui.figureelements.CGCaret; @@ -75,6 +74,7 @@ import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.MathUtil; import net.sf.openrocket.util.StateChangeListener; + /** * A JPanel that contains a RocketFigure and buttons to manipulate the figure. * @@ -86,7 +86,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change private static final Translator trans = Application.getTranslator(); - public static enum VIEW_TYPE { + public enum VIEW_TYPE { SideView(false, RocketFigure.VIEW_SIDE), BackView(false, RocketFigure.VIEW_BACK), Figure3D(true, RocketFigure3d.TYPE_FIGURE), @@ -96,7 +96,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change public final boolean is3d; private final int type; - private VIEW_TYPE(final boolean is3d, final int type) { + VIEW_TYPE(final boolean is3d, final int type) { this.is3d = is3d; this.type = type; }; @@ -140,7 +140,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change // The functional ID of the rocket that was simulated private int flightDataFunctionalID = -1; - private FlightConfigurationId flightDataMotorID = null; + private FlightConfigurationId flightDataMotorID = null; private SimulationWorker backgroundSimulationWorker = null; @@ -271,12 +271,21 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change * Creates the layout and components of the panel. */ private void createPanel() { + final Rocket rkt = document.getRocket(); + + rkt.addChangeListener(new StateChangeListener(){ + @Override + public void stateChanged(EventObject eo) { + updateExtras(); + updateFigures(); + } + }); + setLayout(new MigLayout("", "[shrink][grow]", "[shrink][shrink][grow][shrink]")); setPreferredSize(new Dimension(800, 300)); - // View Type Dropdown - @SuppressWarnings("serial") // because java throws a warning without this. + // View Type drop-down ComboBoxModel cm = new DefaultComboBoxModel(VIEW_TYPE.values()) { @Override @@ -301,7 +310,6 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change add(scaleSelector); // Stage selector - final Rocket rkt = document.getRocket(); StageSelector stageSelector = new StageSelector( rkt ); rkt.addChangeListener(stageSelector); add(stageSelector); @@ -311,21 +319,12 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change JLabel label = new JLabel(trans.get("RocketPanel.lbl.Flightcfg")); label.setHorizontalAlignment(JLabel.RIGHT); add(label, "growx, right"); - - final JComboBox configComboBox = new JComboBox( document.getRocket().toConfigArray()); - + + final ConfigurationModel configModel = new ConfigurationModel(rkt); + final JComboBox configComboBox = new JComboBox<>(configModel); + rkt.addChangeListener( configModel ); add(configComboBox, "wrap, width 16%, wmin 100"); - configComboBox.addActionListener(new ActionListener(){ - @Override - public void actionPerformed(ActionEvent ae) { - FlightConfiguration newConfig = (FlightConfiguration)configComboBox.getSelectedItem(); - document.getRocket().setSelectedConfiguration( newConfig.getId()); - updateExtras(); - updateFigures(); - } - }); - // Create slider and scroll pane DoubleModel theta = new DoubleModel(figure, "Rotation", @@ -361,8 +360,8 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change return aerodynamicCalculator; } - public FlightConfiguration getConfiguration() { - return document.getDefaultConfiguration(); + public FlightConfiguration getSelectedConfiguration() { + return document.getSelectedConfiguration(); } /** @@ -565,7 +564,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change Coordinate cp, cg; double cpx, cgx; - FlightConfiguration curConfig = document.getDefaultConfiguration(); + FlightConfiguration curConfig = document.getSelectedConfiguration(); // TODO: MEDIUM: User-definable conditions FlightConditions conditions = new FlightConditions(curConfig); warnings.clear(); @@ -644,7 +643,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change extraText.setLength(length); extraText.setDiameter(diameter); extraText.setMass(cg.weight); - extraText.setMassWithoutMotors( massCalculator.getCG( getConfiguration(), MassCalcType.NO_MOTORS ).weight ); + extraText.setMassWithoutMotors( massCalculator.getCG( getSelectedConfiguration(), MassCalcType.NO_MOTORS ).weight ); extraText.setWarnings(warnings); if (figure.getType() == RocketPanel.VIEW_TYPE.SideView && length > 0) { @@ -672,12 +671,12 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change // Check whether data is already up to date if (flightDataFunctionalID == curConfig.getRocket().getFunctionalModID() && - flightDataMotorID == curConfig.getFlightConfigurationID()) { + flightDataMotorID == curConfig.getId()) { return; } flightDataFunctionalID = curConfig.getRocket().getFunctionalModID(); - flightDataMotorID = curConfig.getFlightConfigurationID(); + flightDataMotorID = curConfig.getId(); // Stop previous computation (if any) stopBackgroundSimulation(); @@ -695,7 +694,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change Rocket duplicate = (Rocket) document.getRocket().copy(); Simulation simulation = ((SwingPreferences) Application.getPreferences()).getBackgroundSimulation(duplicate); - simulation.setFlightConfigurationId( document.getDefaultConfiguration().getFlightConfigurationID()); + simulation.setFlightConfigurationId( document.getSelectedConfiguration().getId()); backgroundSimulationWorker = new BackgroundSimulationWorker(document, simulation); backgroundSimulationExecutor.execute(backgroundSimulationWorker); @@ -781,7 +780,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change * Adds the extra data to the figure. Currently this includes the CP and CG carets. */ private void addExtras() { - FlightConfiguration curConfig = document.getDefaultConfiguration(); + FlightConfiguration curConfig = document.getSelectedConfiguration(); extraCG = new CGCaret(0, 0); extraCP = new CPCaret(0, 0); extraText = new RocketInfo(curConfig); diff --git a/swing/src/net/sf/openrocket/gui/simulation/SimulationEditDialog.java b/swing/src/net/sf/openrocket/gui/simulation/SimulationEditDialog.java index 18dad4a30..05c6c587d 100644 --- a/swing/src/net/sf/openrocket/gui/simulation/SimulationEditDialog.java +++ b/swing/src/net/sf/openrocket/gui/simulation/SimulationEditDialog.java @@ -21,10 +21,12 @@ import javax.swing.event.DocumentListener; import net.miginfocom.swing.MigLayout; import net.sf.openrocket.document.OpenRocketDocument; import net.sf.openrocket.document.Simulation; +import net.sf.openrocket.gui.components.ConfigurationModel; import net.sf.openrocket.gui.util.GUIUtil; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.rocketcomponent.FlightConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfigurationId; +import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.simulation.extension.SimulationExtension; import net.sf.openrocket.startup.Application; @@ -145,8 +147,10 @@ public class SimulationEditDialog extends JDialog { label.setToolTipText(trans.get("simedtdlg.lbl.ttip.Flightcfg")); panel.add(label, "growx 0, gapright para"); - final JComboBox configComboBox = new JComboBox( document.getRocket().toConfigArray()); - configComboBox.setSelectedItem( document.getRocket().getSelectedConfiguration().getId() ); + final Rocket rkt = document.getRocket(); + final ConfigurationModel configModel = new ConfigurationModel( rkt); + final JComboBox configComboBox = new JComboBox<>(configModel); + configComboBox.setSelectedItem( rkt.getSelectedConfiguration().getId() ); //// Select the motor configuration to use. configComboBox.setToolTipText(trans.get("simedtdlg.combo.ttip.Flightcfg"));