diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index f088e27d7..2478fe6b7 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -50,7 +50,8 @@ RocketPanel.FigTypeAct.Figure3D = 3D Figure RocketPanel.FigTypeAct.Realistic3D = 3D Realistic -RocketPanel.lbl.Motorcfg = Motor configuration: +RocketPanel.lbl.Flightcfg = Flight configuration: +RocketPanel.but.FlightcfgEdit = Edit RocketPanel.lbl.infoMessage = Click to select    Shift+click to select other    Double-click to edit    Click+drag to move @@ -179,7 +180,7 @@ edtmotorconfdlg.but.Newconfiguration = New edtmotorconfdlg.but.Copyconfiguration = Copy edtmotorconfdlg.but.Selectignition = Select ignition edtmotorconfdlg.lbl.Motormounts = Motor mounts: -edtmotorconfdlg.title.Editmotorconf = Edit motor configurations +edtmotorconfdlg.title.Editmotorconf = Edit Flight configurations edtmotorconfdlg.selectcomp = Select which components function as motor mounts: edtmotorconfdlg.lbl.Motorconfig = Motor configurations: edtmotorconfdlg.lbl.Configname = Configuration name: @@ -306,9 +307,10 @@ simedtdlg.tab.Simopt = Simulation options simedtdlg.tab.Plotdata = Plot data simedtdlg.tab.CustomExpressions = Custom expressions simedtdlg.tab.Exportdata = Export data -simedtdlg.lbl.Motorcfg = Motor configuration: -simedtdlg.lbl.ttip.Motorcfg = Select the motor configuration to use. -simedtdlg.combo.ttip.motorconf = Select the motor configuration to use. +simedtdlg.lbl.Flightcfg = Flight configuration: +simedtdlg.but.FlightcfgEdit = Edit +simedtdlg.lbl.ttip.Flightcfg = Select the flight configuration to use. +simedtdlg.combo.ttip.Flightcfg = Select the flight configuration to use. simedtdlg.lbl.Wind = Wind simedtdlg.lbl.Averwindspeed = Average windspeed: simedtdlg.lbl.ttip.Averwindspeed = The average windspeed relative to the ground. @@ -894,8 +896,8 @@ MassComponentCfg.but.Reset = Reset ! MotorConfig MotorCfg.checkbox.compmotormount = This component is a motor mount -MotorCfg.lbl.Motorcfg = Motor configuration: -MotorCfg.but.New = New +MotorCfg.lbl.Flightcfg = Flight configuration: +MotorCfg.but.FlightcfgEdit = Edit MotorCfg.lbl.Currentmotor = Current motor: MotorCfg.lbl.Motoroverhang = Motor overhang: MotorCfg.lbl.Ignitionat = Ignition at: diff --git a/core/src/net/sf/openrocket/gui/configdialog/MotorConfig.java b/core/src/net/sf/openrocket/gui/configdialog/MotorConfig.java index d8a87bcc3..bd7db397a 100644 --- a/core/src/net/sf/openrocket/gui/configdialog/MotorConfig.java +++ b/core/src/net/sf/openrocket/gui/configdialog/MotorConfig.java @@ -10,6 +10,7 @@ import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; +import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSpinner; @@ -26,13 +27,13 @@ import net.sf.openrocket.gui.adaptors.FlightConfigurationModel; import net.sf.openrocket.gui.components.BasicSlider; import net.sf.openrocket.gui.components.StyledLabel; import net.sf.openrocket.gui.components.UnitSelector; +import net.sf.openrocket.gui.dialogs.flightconfiguration.FlightConfigurationDialog; import net.sf.openrocket.gui.dialogs.motor.MotorChooserDialog; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.motor.Motor; import net.sf.openrocket.motor.ThrustCurveMotor; import net.sf.openrocket.rocketcomponent.Configuration; import net.sf.openrocket.rocketcomponent.MotorConfiguration; -import net.sf.openrocket.rocketcomponent.MotorConfiguration.IgnitionEvent; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; @@ -40,115 +41,115 @@ import net.sf.openrocket.startup.Application; import net.sf.openrocket.unit.UnitGroup; public class MotorConfig extends JPanel { - + private final Rocket rocket; private final MotorMount mount; private final Configuration configuration; private JPanel panel; private JLabel motorLabel; private static final Translator trans = Application.getTranslator(); - + public MotorConfig(MotorMount motorMount) { super(new MigLayout("fill")); - + this.rocket = ((RocketComponent) motorMount).getRocket(); this.mount = motorMount; this.configuration = ((RocketComponent) motorMount).getRocket().getDefaultConfiguration(); - + BooleanModel model; - + model = new BooleanModel(motorMount, "MotorMount"); JCheckBox check = new JCheckBox(model); ////This component is a motor mount check.setText(trans.get("MotorCfg.checkbox.compmotormount")); this.add(check, "wrap"); - + panel = new JPanel(new MigLayout("fill")); this.add(panel, "grow, wrap"); - + // Motor configuration selector //// Motor configuration: - panel.add(new JLabel(trans.get("MotorCfg.lbl.Motorcfg")), "shrink"); - + panel.add(new JLabel(trans.get("MotorCfg.lbl.Flightcfg")), "shrink"); + JComboBox combo = new JComboBox(new FlightConfigurationModel(configuration)); panel.add(combo, "growx"); - + configuration.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateFields(); } }); - - //// New button - JButton button = new JButton(trans.get("MotorCfg.but.New")); + + //// Edit button + JButton button = new JButton(trans.get("MotorCfg.but.FlightcfgEdit")); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - String id = rocket.newFlightConfigurationID(); - configuration.setFlightConfigurationID(id); + JDialog configDialog = new FlightConfigurationDialog(rocket,SwingUtilities.windowForComponent(MotorConfig.this)); + configDialog.show(); } }); panel.add(button, "wrap unrel"); - + // Current motor: panel.add(new JLabel(trans.get("MotorCfg.lbl.Currentmotor")), "shrink"); - + motorLabel = new JLabel(); motorLabel.setFont(motorLabel.getFont().deriveFont(Font.BOLD)); updateFields(); panel.add(motorLabel, "wrap unrel"); - + // Overhang //// Motor overhang: panel.add(new JLabel(trans.get("MotorCfg.lbl.Motoroverhang"))); - + DoubleModel dm = new DoubleModel(motorMount, "MotorOverhang", UnitGroup.UNITS_LENGTH); - + JSpinner spin = new JSpinner(dm.getSpinnerModel()); spin.setEditor(new SpinnerEditor(spin)); panel.add(spin, "span, split, width :65lp:"); - + panel.add(new UnitSelector(dm), "width :30lp:"); panel.add(new BasicSlider(dm.getSliderModel(-0.02, 0.06)), "w 100lp, wrap unrel"); - + // Select ignition event //// Ignition at: panel.add(new JLabel(trans.get("MotorCfg.lbl.Ignitionat")), ""); - + combo = new JComboBox(new EnumModel(mount, "DefaultIgnitionEvent")); panel.add(combo, "growx, wrap"); - + // ... and delay //// plus panel.add(new JLabel(trans.get("MotorCfg.lbl.plus")), "gap indent, skip 1, span, split"); - + dm = new DoubleModel(mount, "DefaultIgnitionDelay", 0); spin = new JSpinner(dm.getSpinnerModel()); spin.setEditor(new SpinnerEditor(spin,3)); panel.add(spin, "gap rel rel"); - + //// seconds panel.add(new JLabel(trans.get("MotorCfg.lbl.seconds")), "wrap unrel"); - + // Check stage count RocketComponent c = (RocketComponent) mount; c = c.getRocket(); int stages = c.getChildCount(); - + if (stages == 1) { //// The current design has only one stage. //// Stages can be added by clicking \"New stage\". - + panel.add(new StyledLabel(trans.get("MotorCfg.lbl.longA1") + " " + trans.get("MotorCfg.lbl.longA2"), -1), "spanx, right, wrap para"); @@ -159,7 +160,7 @@ public class MotorConfig extends JPanel { trans.get("MotorCfg.lbl.longB2"), -1), "skip 1, spanx, wrap para"); } - + // Select etc. buttons //// Select motor @@ -168,14 +169,14 @@ public class MotorConfig extends JPanel { @Override public void actionPerformed(ActionEvent e) { String id = configuration.getFlightConfigurationID(); - + MotorChooserDialog dialog = new MotorChooserDialog(mount.getMotor(id), mount.getMotorDelay(id), mount.getMotorMountDiameter(), SwingUtilities.getWindowAncestor(MotorConfig.this)); dialog.setVisible(true); Motor m = dialog.getSelectedMotor(); double d = dialog.getSelectedDelay(); - + if (m != null) { if (id == null) { id = rocket.newFlightConfigurationID(); @@ -188,7 +189,7 @@ public class MotorConfig extends JPanel { } }); panel.add(button, "span, split, growx"); - + //// Remove motor button = new JButton(trans.get("MotorCfg.but.Removemotor")); button.addActionListener(new ActionListener() { @@ -199,13 +200,13 @@ public class MotorConfig extends JPanel { } }); panel.add(button, "growx, wrap"); - + // Set enabled status - + setDeepEnabled(panel, motorMount.isMotorMount()); check.addChangeListener(new ChangeListener() { @Override @@ -213,9 +214,9 @@ public class MotorConfig extends JPanel { setDeepEnabled(panel, mount.isMotorMount()); } }); - + } - + public void updateFields() { String id = configuration.getFlightConfigurationID(); Motor m = mount.getMotor(id); @@ -230,8 +231,8 @@ public class MotorConfig extends JPanel { motorLabel.setText(str); } } - - + + private static void setDeepEnabled(Component component, boolean enabled) { component.setEnabled(enabled); if (component instanceof Container) { @@ -240,5 +241,5 @@ public class MotorConfig extends JPanel { } } } - + } diff --git a/core/src/net/sf/openrocket/gui/main/SimulationEditDialog.java b/core/src/net/sf/openrocket/gui/main/SimulationEditDialog.java index f7bf60be6..0a7448f85 100644 --- a/core/src/net/sf/openrocket/gui/main/SimulationEditDialog.java +++ b/core/src/net/sf/openrocket/gui/main/SimulationEditDialog.java @@ -24,6 +24,7 @@ import javax.swing.JSpinner; import javax.swing.JTabbedPane; import javax.swing.JTextField; import javax.swing.ListCellRenderer; +import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; @@ -41,9 +42,11 @@ import net.sf.openrocket.gui.components.BasicSlider; import net.sf.openrocket.gui.components.DescriptionArea; import net.sf.openrocket.gui.components.SimulationExportPanel; import net.sf.openrocket.gui.components.UnitSelector; +import net.sf.openrocket.gui.dialogs.flightconfiguration.FlightConfigurationDialog; import net.sf.openrocket.gui.plot.Axis; import net.sf.openrocket.gui.plot.PlotConfiguration; import net.sf.openrocket.gui.plot.SimulationPlotPanel; +import net.sf.openrocket.gui.scalefigure.RocketPanel; import net.sf.openrocket.gui.util.GUIUtil; import net.sf.openrocket.gui.util.Icons; import net.sf.openrocket.l10n.Translator; @@ -208,24 +211,34 @@ public class SimulationEditDialog extends JDialog { DoubleModel m; JSpinner spin; - //// Motor selector - //// Motor configuration: - JLabel label = new JLabel(trans.get("simedtdlg.lbl.Motorcfg")); + //// Flight selector + //// Flight configuration: + JLabel label = new JLabel(trans.get("simedtdlg.lbl.Flightcfg")); //// Select the motor configuration to use. - label.setToolTipText(trans.get("simedtdlg.lbl.ttip.Motorcfg")); + label.setToolTipText(trans.get("simedtdlg.lbl.ttip.Flightcfg")); panel.add(label, "shrinkx, spanx, split 2"); JComboBox combo = new JComboBox(new FlightConfigurationModel(configuration)); //// Select the motor configuration to use. - combo.setToolTipText(trans.get("simedtdlg.combo.ttip.motorconf")); + combo.setToolTipText(trans.get("simedtdlg.combo.ttip.Flightcfg")); combo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { conditions.setMotorConfigurationID(configuration.getFlightConfigurationID()); } }); - panel.add(combo, "growx, wrap para"); + panel.add(combo, ""); + //// Edit button + JButton button = new JButton(trans.get("simedtdlg.but.FlightcfgEdit")); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JDialog configDialog = new FlightConfigurationDialog(document.getRocket(),SwingUtilities.windowForComponent(SimulationEditDialog.this)); + configDialog.show(); + } + }); + panel.add(button, "wrap"); //// Wind settings: Average wind speed, turbulence intensity, std. deviation sub = new JPanel(new MigLayout("fill, gap rel unrel", diff --git a/core/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java b/core/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java index 4331a7124..0615a3330 100644 --- a/core/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java +++ b/core/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java @@ -6,6 +6,7 @@ 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; @@ -21,7 +22,9 @@ import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.ComboBoxModel; import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; import javax.swing.JComboBox; +import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSlider; @@ -45,6 +48,8 @@ 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.configdialog.ComponentConfigDialog; +import net.sf.openrocket.gui.configdialog.MotorConfig; +import net.sf.openrocket.gui.dialogs.flightconfiguration.FlightConfigurationDialog; import net.sf.openrocket.gui.figure3d.RocketFigure3d; import net.sf.openrocket.gui.figureelements.CGCaret; import net.sf.openrocket.gui.figureelements.CPCaret; @@ -304,13 +309,23 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change - // Motor configuration selector - //// Motor configuration: - JLabel label = new JLabel(trans.get("RocketPanel.lbl.Motorcfg")); + // Flight configuration selector + //// Flight configuration: + JLabel label = new JLabel(trans.get("RocketPanel.lbl.Flightcfg")); label.setHorizontalAlignment(JLabel.RIGHT); add(label, "growx, right"); - add(new JComboBox(new FlightConfigurationModel(configuration)), "wrap"); + add(new JComboBox(new FlightConfigurationModel(configuration)), ""); + //// Edit button + JButton button = new JButton(trans.get("RocketPanel.but.FlightcfgEdit")); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JDialog configDialog = new FlightConfigurationDialog(document.getRocket(),SwingUtilities.windowForComponent(RocketPanel.this)); + configDialog.show(); + } + }); + add(button, "wrap");