diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 318668bf8..e736fe5de 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -1303,6 +1303,10 @@ StorageOptChooser.lbl.Saveopt = Save options TCMotorSelPan.lbl.Selrocketmotor = Select rocket motor: TCMotorSelPan.checkbox.hideSimilar = Hide very similar thrust curves TCMotorSelPan.checkbox.hideUsed = Hide motors already used in the mount +TCMotorSelPan.lbl.motorNameColumn = Motor name column: +TCMotorSelPan.lbl.motorNameColumn.ttip = Select which motor property to display in the motor name column. +TCMotorSelPan.btn.commonName = Use common name +TCMotorSelPan.btn.designation = Use manufacturer's designation TCMotorSelPan.lbl.nrOfMotors = Number of motors: TCMotorSelPan.lbl.ttip.nrOfMotors = Number of motors currently visible in the motor selection table TCMotorSelPan.checkbox.limitlength = Limit motor length to mount length @@ -1695,8 +1699,7 @@ FlightEvent.Type.EXCEPTION = Exception ! ThrustCurveMotorColumns TCurveMotorCol.MANUFACTURER = Manufacturer -TCurveMotorCol.COMMON_NAME = Name -TCurveMotorCol.DESIGNATION = Designation +TCurveMotorCol.NAME = Name TCurveMotorCol.CASEINFO = Case TCurveMotorCol.DIAMETER = Diameter TCurveMotorCol.LENGTH = Length diff --git a/core/resources/l10n/messages_cs.properties b/core/resources/l10n/messages_cs.properties index cbde32398..3e9b5ea5f 100644 --- a/core/resources/l10n/messages_cs.properties +++ b/core/resources/l10n/messages_cs.properties @@ -1213,7 +1213,7 @@ FlightEvent.Type.ALTITUDE = Zmena v ! ThrustCurveMotorColumns TCurveMotorCol.MANUFACTURER = Výrobce -TCurveMotorCol.COMMON_NAME = Jméno +TCurveMotorCol.NAME = Jméno ! TCurveMotorCol.DESIGNATION = Pojmenování TCurveMotorCol.TYPE = Druh TCurveMotorCol.DIAMETER = Prumer diff --git a/core/resources/l10n/messages_de.properties b/core/resources/l10n/messages_de.properties index ba51cc96e..e2cda7b33 100644 --- a/core/resources/l10n/messages_de.properties +++ b/core/resources/l10n/messages_de.properties @@ -1273,7 +1273,7 @@ FlightEvent.Type.ALTITUDE = H ! ThrustCurveMotorColumns TCurveMotorCol.MANUFACTURER = Hersteller -TCurveMotorCol.COMMON_NAME = Name +TCurveMotorCol.NAME = Name ! TCurveMotorCol.DESIGNATION = Bezeichnung TCurveMotorCol.TYPE = Typ TCurveMotorCol.DIAMETER = Durchmesser diff --git a/core/resources/l10n/messages_es.properties b/core/resources/l10n/messages_es.properties index 80f565efa..7bfe090c5 100644 --- a/core/resources/l10n/messages_es.properties +++ b/core/resources/l10n/messages_es.properties @@ -1157,7 +1157,7 @@ TCurveMotor.ttip.maxThrust = Empuje m\u00e1ximo: TCurveMotor.ttip.totalImpulse = Impulso total: ! ThrustCurveMotorColumns -TCurveMotorCol.COMMON_NAME = Nombre +TCurveMotorCol.NAME = Nombre ! TCurveMotorCol.DESIGNATION = Designaci\u00f3n TCurveMotorCol.DIAMETER = Di\u00e1metro TCurveMotorCol.LENGTH = Longitud diff --git a/core/resources/l10n/messages_fr.properties b/core/resources/l10n/messages_fr.properties index 57709d450..210605775 100644 --- a/core/resources/l10n/messages_fr.properties +++ b/core/resources/l10n/messages_fr.properties @@ -1151,7 +1151,7 @@ TCurveMotor.ttip.maxThrust = Pouss\u00E9e Maximum: TCurveMotor.ttip.totalImpulse = Impulsion Totale: ! ThrustCurveMotorColumns -TCurveMotorCol.COMMON_NAME = Nom +TCurveMotorCol.NAME = Nom ! TCurveMotorCol.DESIGNATION = D\u00E9signation TCurveMotorCol.DIAMETER = Diam\u00E8tre TCurveMotorCol.LENGTH = Longueur diff --git a/core/resources/l10n/messages_it.properties b/core/resources/l10n/messages_it.properties index 30e240111..784de45de 100644 --- a/core/resources/l10n/messages_it.properties +++ b/core/resources/l10n/messages_it.properties @@ -1276,7 +1276,7 @@ FlightEvent.Type.ALTITUDE = Cambio altitudine ! ThrustCurveMotorColumns TCurveMotorCol.MANUFACTURER = Produttore -TCurveMotorCol.COMMON_NAME = Nome +TCurveMotorCol.NAME = Nome ! TCurveMotorCol.DESIGNATION = Classe TCurveMotorCol.TYPE = Tipo TCurveMotorCol.DIAMETER = Diametro diff --git a/core/resources/l10n/messages_ja.properties b/core/resources/l10n/messages_ja.properties index d2b35d286..7286f837c 100644 --- a/core/resources/l10n/messages_ja.properties +++ b/core/resources/l10n/messages_ja.properties @@ -1325,7 +1325,7 @@ FlightEvent.Type.ALTITUDE = \u59FF\u52E2\u5909\u66F4 ! ThrustCurveMotorColumns TCurveMotorCol.MANUFACTURER = \u30E1\u30FC\u30AB\u30FC ! TCurveMotorCol.DESIGNATION = \u8A18\u53F7 -TCurveMotorCol.COMMON_NAME = \u8A18\u53F7 +TCurveMotorCol.NAME = \u8A18\u53F7 TCurveMotorCol.TYPE = \u30BF\u30A4\u30D7 TCurveMotorCol.DIAMETER = \u76F4\u5F84 TCurveMotorCol.LENGTH = \u9577\u3055 diff --git a/core/resources/l10n/messages_nl.properties b/core/resources/l10n/messages_nl.properties index 7c73fb9b1..d1d153caf 100644 --- a/core/resources/l10n/messages_nl.properties +++ b/core/resources/l10n/messages_nl.properties @@ -1573,7 +1573,7 @@ FlightEvent.Type.EXCEPTION = Uitzondering ! ThrustCurveMotorColumns TCurveMotorCol.MANUFACTURER = Fabrikant -TCurveMotorCol.COMMON_NAME = Naam +TCurveMotorCol.NAME = Naam ! TCurveMotorCol.DESIGNATION = Benaming TCurveMotorCol.CASEINFO = Behuizing TCurveMotorCol.DIAMETER = Diameter diff --git a/core/resources/l10n/messages_pl.properties b/core/resources/l10n/messages_pl.properties index e8311050b..f3cbe0a19 100644 --- a/core/resources/l10n/messages_pl.properties +++ b/core/resources/l10n/messages_pl.properties @@ -1217,7 +1217,7 @@ update.dlg.latestVersion = Korzystasz z najnowszej wersji OpenRocket: %s. ! ThrustCurveMotorColumns TCurveMotorCol.MANUFACTURER = Producent - TCurveMotorCol.COMMON_NAME = Nazwa + TCurveMotorCol.NAME = Nazwa ! TCurveMotorCol.DESIGNATION = Oznaczenie TCurveMotorCol.TYPE = Typ TCurveMotorCol.DIAMETER = \u015Arednica diff --git a/core/resources/l10n/messages_pt.properties b/core/resources/l10n/messages_pt.properties index 85b28b7e2..67a3df719 100644 --- a/core/resources/l10n/messages_pt.properties +++ b/core/resources/l10n/messages_pt.properties @@ -1117,7 +1117,7 @@ TCurveMotor.ttip.maxThrust = M\u00e1ximo de impulso: TCurveMotor.ttip.totalImpulse = Impulso total: # ThrustCurveMotorColumns -TCurveMotorCol.COMMON_NAME = Nome +TCurveMotorCol.NAME = Nome ! TCurveMotorCol.DESIGNATION = Designa\u00e7\u00e3o TCurveMotorCol.DIAMETER = Di\u00e2metro TCurveMotorCol.LENGTH = Comprimento diff --git a/core/resources/l10n/messages_ru.properties b/core/resources/l10n/messages_ru.properties index 622206d70..d00e78672 100644 --- a/core/resources/l10n/messages_ru.properties +++ b/core/resources/l10n/messages_ru.properties @@ -1696,7 +1696,7 @@ FlightEvent.Type.EXCEPTION = \u041E\u0448\u0438\u0431\u043A\u0430 ! ThrustCurveMotorColumns TCurveMotorCol.MANUFACTURER = \u041F\u0440\u043E\u0438\u0437\u0432\u043E\u0434\u0438\u0442\u0435\u043B\u044C -TCurveMotorCol.COMMON_NAME = \u041E\u0431\u043E\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 +TCurveMotorCol.NAME = \u041E\u0431\u043E\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 TCurveMotorCol.CASEINFO = \u041A\u043E\u0440\u043F\u0443\u0441 TCurveMotorCol.TYPE = \u0422\u0438\u043F TCurveMotorCol.DIAMETER = \u0414\u0438\u0430\u043C\u0435\u0442\u0440 diff --git a/core/resources/l10n/messages_uk_UA.properties b/core/resources/l10n/messages_uk_UA.properties index 09c8a5319..e0745534d 100644 --- a/core/resources/l10n/messages_uk_UA.properties +++ b/core/resources/l10n/messages_uk_UA.properties @@ -1421,7 +1421,7 @@ FlightEvent.Type.EXCEPTION = Exception ! ThrustCurveMotorColumns TCurveMotorCol.MANUFACTURER = Manufacturer -TCurveMotorCol.COMMON_NAME = Name +TCurveMotorCol.NAME = Name ! TCurveMotorCol.DESIGNATION = Designation TCurveMotorCol.TYPE = Type TCurveMotorCol.DIAMETER = Diameter diff --git a/core/resources/l10n/messages_zh_CN.properties b/core/resources/l10n/messages_zh_CN.properties index 9049a78c9..e9a1f5735 100644 --- a/core/resources/l10n/messages_zh_CN.properties +++ b/core/resources/l10n/messages_zh_CN.properties @@ -1221,7 +1221,7 @@ TCurveMotor.ttip.maxThrust = \u6700\u5927\u63A8\u529B: TCurveMotor.ttip.totalImpulse = \u603B\u51B2\u529B: ! ThrustCurveMotorColumns -TCurveMotorCol.COMMON_NAME = \u540D\u79F0 +TCurveMotorCol.NAME = \u540D\u79F0 ! TCurveMotorCol.DESIGNATION = \u540D\u79F0 TCurveMotorCol.DIAMETER = \u76F4\u5F84 TCurveMotorCol.LENGTH = \u957F\u5EA6 diff --git a/core/src/net/sf/openrocket/startup/Preferences.java b/core/src/net/sf/openrocket/startup/Preferences.java index 0b27c19f1..be58fb2a5 100644 --- a/core/src/net/sf/openrocket/startup/Preferences.java +++ b/core/src/net/sf/openrocket/startup/Preferences.java @@ -65,6 +65,8 @@ public abstract class Preferences implements ChangeSource { public static final String MOTOR_HIDE_SIMILAR = "MotorHideSimilar"; public static final String MOTOR_HIDE_UNAVAILABLE = "MotorHideUnavailable"; + public static final String MOTOR_NAME_COLUMN = "MotorNameColumn"; + public static final String MATCH_FORE_DIAMETER = "MatchForeDiameter"; public static final String MATCH_AFT_DIAMETER = "MatchAftDiameter"; diff --git a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorRowFilter.java b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorRowFilter.java index 98d2a4308..e0cdfdda9 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorRowFilter.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorRowFilter.java @@ -223,6 +223,15 @@ public class MotorRowFilter extends RowFilter implements Ch continue main; } } + + // Make sure that you can search on both the common name, and designation + // Yes, there is some duplication here because the common name or designation is already checked in the previous loop + // but it's not worth checking that... + String common = m.getCommonName().toLowerCase(Locale.getDefault()); + String designation = m.getDesignation().toLowerCase(Locale.getDefault()); + if (common.contains(s) || designation.contains(s)) { + continue main; + } return false; } return true; diff --git a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorColumns.java b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorColumns.java index ad5319cb3..72fb93ca2 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorColumns.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorColumns.java @@ -4,6 +4,7 @@ import java.text.Collator; import java.util.Comparator; import net.sf.openrocket.database.motor.ThrustCurveMotorSet; +import net.sf.openrocket.gui.util.SwingPreferences; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.motor.DesignationComparator; import net.sf.openrocket.motor.ThrustCurveMotor; @@ -31,10 +32,14 @@ enum ThrustCurveMotorColumns { } }, //// Common name - COMMON_NAME("TCurveMotorCol.COMMON_NAME") { + NAME("TCurveMotorCol.NAME") { @Override public String getValue(ThrustCurveMotorSet m) { - return m.getCommonName(); + if (((SwingPreferences) Application.getPreferences()).getMotorNameColumn()) { + return m.getDesignation(); + } else { + return m.getCommonName(); + } } @Override @@ -42,18 +47,6 @@ enum ThrustCurveMotorColumns { return new DesignationComparator(); } }, - //// Designation - DESIGNATION("TCurveMotorCol.DESIGNATION") { - @Override - public String getValue(ThrustCurveMotorSet m) { - return m.getDesignation(); - } - - @Override - public Comparator getComparator() { - return new DesignationComparator(); - } - }, //// TotalImpulse TOTAL_IMPULSE("TCurveMotorCol.TOTAL_IMPULSE") { @Override diff --git a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java index 9bf036f25..e827d52c7 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Set; import java.util.prefs.Preferences; +import javax.swing.ButtonGroup; import javax.swing.DefaultComboBoxModel; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -25,6 +26,7 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; +import javax.swing.JRadioButton; import javax.swing.JScrollPane; import javax.swing.JSeparator; import javax.swing.JTabbedPane; @@ -228,6 +230,39 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec } + //// Motor name column + { + JLabel motorNameColumn = new JLabel(trans.get("TCMotorSelPan.lbl.motorNameColumn")); + motorNameColumn.setToolTipText(trans.get("TCMotorSelPan.lbl.motorNameColumn.ttip")); + JRadioButton commonName = new JRadioButton(trans.get("TCMotorSelPan.btn.commonName")); + JRadioButton designation = new JRadioButton(trans.get("TCMotorSelPan.btn.designation")); + ButtonGroup bg = new ButtonGroup(); + bg.add(commonName); + bg.add(designation); + commonName.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ((SwingPreferences) Application.getPreferences()).setMotorNameColumn(false); + model.fireTableDataChanged(); + } + }); + designation.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ((SwingPreferences) Application.getPreferences()).setMotorNameColumn(true); + model.fireTableDataChanged(); + } + }); + + boolean initValue = ((SwingPreferences) Application.getPreferences()).getMotorNameColumn(); + commonName.setSelected(!initValue); + designation.setSelected(initValue); + + panel.add(motorNameColumn, "gapleft para"); + panel.add(commonName); + panel.add(designation, "spanx, growx, wrap"); + } + //// Motor selection table { table = new JTable(model); diff --git a/swing/src/net/sf/openrocket/gui/util/SwingPreferences.java b/swing/src/net/sf/openrocket/gui/util/SwingPreferences.java index 6d95e208a..19bef0b5c 100644 --- a/swing/src/net/sf/openrocket/gui/util/SwingPreferences.java +++ b/swing/src/net/sf/openrocket/gui/util/SwingPreferences.java @@ -331,7 +331,23 @@ 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() {