diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 4087f87ce..59f622a28 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -1375,6 +1375,7 @@ TCMotorSelPan.lbl.Ejectionchargedelay = Ejection charge delay: TCMotorSelPan.equalsIgnoreCase.None = None TCMotorSelPan.lbl.NumberofsecondsorNone = (Number of seconds or \"None\") TCMotorSelPan.lbl.Designation = Designation: +TCMotorSelPan.lbl.CommonName = Common name: TCMotorSelPan.lbl.Totalimpulse = Total impulse: TCMotorSelPan.lbl.Avgthrust = Avg. thrust: TCMotorSelPan.lbl.Maxthrust = Max. thrust: diff --git a/core/src/net/sf/openrocket/formatting/MotorConfigurationSubstitutor.java b/core/src/net/sf/openrocket/formatting/MotorConfigurationSubstitutor.java index 9c534d079..864a0ea8a 100644 --- a/core/src/net/sf/openrocket/formatting/MotorConfigurationSubstitutor.java +++ b/core/src/net/sf/openrocket/formatting/MotorConfigurationSubstitutor.java @@ -12,6 +12,7 @@ import net.sf.openrocket.rocketcomponent.FlightConfigurationId; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; +import net.sf.openrocket.startup.Application; import net.sf.openrocket.util.ArrayList; import net.sf.openrocket.util.Chars; @@ -93,7 +94,7 @@ public class MotorConfigurationSubstitutor implements RocketSubstitutor { Motor motor = inst.getMotor(); if (mount.isMotorMount() && config.isComponentActive(mount) && (motor != null)) { - String motorDesignation = motor.getDesignation(inst.getEjectionDelay()); + String motorDesignation = motor.getMotorName(inst.getEjectionDelay()); String manufacturer = ""; if (motor instanceof ThrustCurveMotor) { manufacturer = ((ThrustCurveMotor) motor).getManufacturer().getDisplayName(); diff --git a/core/src/net/sf/openrocket/motor/Motor.java b/core/src/net/sf/openrocket/motor/Motor.java index 61d4eb4f1..fb46a25d6 100644 --- a/core/src/net/sf/openrocket/motor/Motor.java +++ b/core/src/net/sf/openrocket/motor/Motor.java @@ -1,5 +1,7 @@ package net.sf.openrocket.motor; +import net.sf.openrocket.startup.Application; + public interface Motor { /** @@ -110,6 +112,24 @@ public interface Motor { * @return designation with delay. */ public String getDesignation(double delay); + + /** + * Returns the motor name, based on whether the preference is to use the designation or common name. + * @return the motor designation, if the preference is to use the designation, otherwise the common name. + */ + public default String getMotorName() { + boolean useDesignation = Application.getPreferences().getMotorNameColumn(); + return useDesignation ? getDesignation() : getCommonName(); + } + + /** + * Returns the motor name, including a delay, based on whether the preference is to use the designation or common name. + * @return the motor designation, including a delay, if the preference is to use the designation, otherwise the common name. + */ + public default String getMotorName(double delay) { + boolean useDesignation = Application.getPreferences().getMotorNameColumn(); + return useDesignation ? getDesignation(delay) : getCommonName(delay); + } /** diff --git a/core/src/net/sf/openrocket/motor/MotorConfiguration.java b/core/src/net/sf/openrocket/motor/MotorConfiguration.java index dd09675f3..e42c591b4 100644 --- a/core/src/net/sf/openrocket/motor/MotorConfiguration.java +++ b/core/src/net/sf/openrocket/motor/MotorConfiguration.java @@ -7,7 +7,6 @@ import net.sf.openrocket.rocketcomponent.InnerTube; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.startup.Application; -import net.sf.openrocket.util.ArrayList; import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Inertia; @@ -68,11 +67,11 @@ public class MotorConfiguration implements FlightConfigurableParameter= 0) { table.setRowSelectionInterval(selectedRow, selectedRow); } + curveSelectionBox.revalidate(); + curveSelectionBox.repaint(); } }); designation.addActionListener(new ActionListener() { @@ -259,6 +261,8 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec if (selectedRow >= 0) { table.setRowSelectionInterval(selectedRow, selectedRow); } + curveSelectionBox.revalidate(); + curveSelectionBox.repaint(); } }); 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 a3d75664b..fa6480665 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java @@ -507,7 +507,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel throw new NullPointerException("Motor has a null mount... this should never happen: "+curMotorInstance.getID()); } - String str = motor.getCommonName(curMotorInstance.getEjectionDelay()); + String str = motor.getMotorName(curMotorInstance.getEjectionDelay()); int count = mount.getInstanceCount(); if (count > 1) { str = "" + count + Chars.TIMES + " " + str; diff --git a/swing/src/net/sf/openrocket/gui/util/SwingPreferences.java b/swing/src/net/sf/openrocket/gui/util/SwingPreferences.java index 45c5ce476..bf30f6c39 100644 --- a/swing/src/net/sf/openrocket/gui/util/SwingPreferences.java +++ b/swing/src/net/sf/openrocket/gui/util/SwingPreferences.java @@ -362,23 +362,6 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences { // TODO: MEDIUM: Motor fill color (settable?) return new Color(0, 0, 0, 100); } - - - /** - * Check whether to display the common name (false), or designation (true) in the motor selection table "Name" column - * @return true to display designation, false to display common name - */ - public boolean getMotorNameColumn() { - return getBoolean(net.sf.openrocket.startup.Preferences.MOTOR_NAME_COLUMN, true); - } - - /** - * Set whether to display the common name, or designation in the motor selection table "Name" column - * @param value if true, display designation, if false, display common name - */ - public void setMotorNameColumn(boolean value) { - putBoolean(net.sf.openrocket.startup.Preferences.MOTOR_NAME_COLUMN, value); - } public static int getMaxThreadCount() {