diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 563738509..e70342af9 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -2074,8 +2074,10 @@ CustomFinImport.error.badimage = Could not deduce fin shape from image. CustomFinImport.description = The image will be converted internally to black and white image (black for the fin), so make sure you use a solid dark color for the fin, and white or a light color for the background. The fin must be touching the bottom of the image, which is the base of the fin. -PresetModel.lbl.select = Select preset -PresetModel.lbl.database = From database\u2026 +PresetModel.combo.ttip = Select a preset model from a list of favorites (selected in the component preset dialog),
or select 'Custom' when no preset is required. +PresetModel.lbl.custompreset = Custom +PresetModel.lbl.partsLib = Parts Library +PresetModel.lbl.partsLib.ttip = Select a preset model for this rocket component from a library of parts. DecalModel.lbl.select = DecalModel.lbl.choose = From file\u2026 @@ -2097,7 +2099,7 @@ ComponentPresetChooserDialog.menu.sortDesc = Sort Descending ComponentPresetChooserDialog.menu.units = Units ComponentPresetChooserDialog.checkbox.showAllCompatible = Show all compatible ComponentPresetChooserDialog.checkbox.showLegacyCheckBox = Show Legacy Database -ComponentPresetChooserDialog.lbl.favorites = Select to add preset to drop-down menu +ComponentPresetChooserDialog.lbl.favorites = Check to add preset to the preset drop-down menu in the component edit dialog table.column.Favorite = Favorite table.column.Legacy = Legacy table.column.Manufacturer = Manufacturer diff --git a/core/resources/l10n/messages_cs.properties b/core/resources/l10n/messages_cs.properties index 627fe287f..a30ef6392 100644 --- a/core/resources/l10n/messages_cs.properties +++ b/core/resources/l10n/messages_cs.properties @@ -1587,8 +1587,8 @@ CustomFinImport.error.badimage = Nemohu vyvodit tvar stabiliz CustomFinImport.description = Obrázek bude zmenen na cernobílý \n(cerná pro stabilizátor), ujistete se prosím, \u017Ee jste pou\u017Eily cernou barvu na stabilizátor \na bílou nebo svetlou barvu na pozadí. Stabilizátor \nse musí dotýkat steny obrázku, která predstavuje uchycení pro stabilizátor. -PresetModel.lbl.select = Výber predvolby: -PresetModel.lbl.database = Z databáze... +PresetModel.lbl.custompreset = Vlastní +PresetModel.lbl.partsLib = Knihovna díl? ! Component Preset Chooser Dialog diff --git a/core/resources/l10n/messages_de.properties b/core/resources/l10n/messages_de.properties index 30b6df86c..5a1d9a7ec 100644 --- a/core/resources/l10n/messages_de.properties +++ b/core/resources/l10n/messages_de.properties @@ -1645,8 +1645,8 @@ CustomFinImport.error.badimage = Konnte keine Leitwerksform aus dem Bild erzeuge CustomFinImport.description = Das Bild wird intern in ein Schwarz-Weiß-Bild konvertiert (Leitwerk: schwarz). Bitte sicherstellen, dass das Leitwerk in einer dichten, dunklen Farbe ist, während der Hintergrund weiß oder sehr hell sein sollte. Das Leitwerk muss das untere Bildende berühren, da dies die Verbindungsstelle zur Rakete wird. -PresetModel.lbl.select = Voreinstellung auswählen: -PresetModel.lbl.database = Aus Datenbank... +PresetModel.lbl.custompreset = Benutzerdefiniert +PresetModel.lbl.partsLib = Teile-Bibliothek ! Component Preset Chooser Dialog diff --git a/core/resources/l10n/messages_es.properties b/core/resources/l10n/messages_es.properties index 6386c101d..556fd9ede 100644 --- a/core/resources/l10n/messages_es.properties +++ b/core/resources/l10n/messages_es.properties @@ -737,8 +737,8 @@ PreferencesDialog.languages.default = Idioma por defecto PreferencesDialog.lbl.language = Idioma de la interfaz: PreferencesDialog.lbl.languageEffect = El idioma cambiar\u00e1 la pr\u00f3xima vez que abra OpenRocket. -PresetModel.lbl.database = Desde la Base de Datos... -PresetModel.lbl.select = Prefabricado +PresetModel.lbl.custompreset = Personalizado +PresetModel.lbl.partsLib = Biblioteca de piezas PrintDialog.but.previewAndPrint = Vista previa e Imprimir PrintDialog.checkbox.showByStage = Mostrar por etapas diff --git a/core/resources/l10n/messages_fr.properties b/core/resources/l10n/messages_fr.properties index 2ea355901..350bc5874 100644 --- a/core/resources/l10n/messages_fr.properties +++ b/core/resources/l10n/messages_fr.properties @@ -729,8 +729,8 @@ PreferencesDialog.languages.default = Valeur syst\u00E8me par d\u00E9faut PreferencesDialog.lbl.language = Langue du programme: PreferencesDialog.lbl.languageEffect = La langue sera chang\u00E9e apr\u00E8s avoir red\u00E9marr\u00E9 OpenRocket. -PresetModel.lbl.database = A partir d'une base de donn\u00E9es... -PresetModel.lbl.select = Choisir une pi\u00E8ce pr\u00E9d\u00E9finie: +PresetModel.lbl.custompreset = Personnalisé +PresetModel.lbl.partsLib = Biblioth\u00E8que de pi\u00E8ces PrintDialog.but.previewAndPrint = Pr\u00E9-visualiser et imprimer PrintDialog.checkbox.showByStage = Montrer par \u00E9tage diff --git a/core/resources/l10n/messages_it.properties b/core/resources/l10n/messages_it.properties index 6d44cadf1..0596e8fc5 100644 --- a/core/resources/l10n/messages_it.properties +++ b/core/resources/l10n/messages_it.properties @@ -1651,8 +1651,8 @@ CustomFinImport.error.badimage = Non riesco a capire la forma della pinna dall CustomFinImport.description = L'immagine sar\u00e0 convertita in bianco e nero internamente (nero per le pinne), cos\u00ec assicurati di usare un nero pieno per le pinne e bianco, o colore chiaro, per lo sfondo. La pinna ndeve toccare il fondo dell'immagine, che \u00e8 la base della pinna. -PresetModel.lbl.select = Seleziona precaricati: -PresetModel.lbl.database = Da database... +PresetModel.lbl.custompreset = Personalizzato +PresetModel.lbl.partsLib = Libreria di parti ! Component Preset Chooser Dialog diff --git a/core/resources/l10n/messages_ja.properties b/core/resources/l10n/messages_ja.properties index 44e7e9004..3daf4089e 100644 --- a/core/resources/l10n/messages_ja.properties +++ b/core/resources/l10n/messages_ja.properties @@ -1713,8 +1713,8 @@ CustomFinImport.error.badimage = \u753B\u50CF\u304B\u3089\u30D5\u30A3\u30F3\u5F CustomFinImport.description = \u753B\u50CF\u306F\u5185\u90E8\u3067\u767D\u80CC\u666F\u3068\u9ED2\u7DDA\u306B\u5909\u63DB\u3055\u308C\u307E\u3059\u3002\u306A\u306E\u3067\u30D5\u30A3\u30F3\u306B\u306F\u6697\u3044\u8272\u306E\u5B9F\u7DDA\u3001\u80CC\u666F\u306B\u306F\u767D\u304B\u660E\u308B\u3044\u8272\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u30D5\u30A3\u30F3\u306F\u753B\u50CF\u306E\u5E95\u9762\u306B\u63A5\u3057\u3066\u3044\u306A\u304F\u3066\u306F\u3044\u3051\u307E\u305B\u3093\u3001\u3053\u308C\u306F\u30D5\u30A3\u30F3\u306E\u5E95\u9762\u306B\u306A\u308A\u307E\u3059\u3002 -PresetModel.lbl.select = Select preset -PresetModel.lbl.database = From database... +PresetModel.lbl.custompreset = \u30ab\u30b9\u30bf\u30e0 +PresetModel.lbl.partsLib = \u30d1\u30fc\u30c4\u30e9\u30a4\u30d6\u30e9\u30ea\u30fc ! Component Preset Chooser Dialog diff --git a/core/resources/l10n/messages_nl.properties b/core/resources/l10n/messages_nl.properties index 78365b1c9..08c3faeed 100644 --- a/core/resources/l10n/messages_nl.properties +++ b/core/resources/l10n/messages_nl.properties @@ -1967,8 +1967,8 @@ CustomFinImport.error.badimage = Kon de vorm van de vin niet afleiden uit het be CustomFinImport.description = De afbeelding wordt intern geconverteerd naar een zwart-wit afbeelding (zwart voor de vin), dus zorg ervoor dat je een effen donkere kleur gebruikt voor de vin, en wit of een lichte kleur voor de achtergrond. De vin moet de onderkant van het beeld raken, dat is de basis van de vin. -PresetModel.lbl.select = Selecteer preset -PresetModel.lbl.database = Uit databank... +PresetModel.lbl.custompreset = Aangepast +PresetModel.lbl.partsLib = Onderdelenbibliotheek DecalModel.lbl.select = DecalModel.lbl.choose = Van bestand... diff --git a/core/resources/l10n/messages_pl.properties b/core/resources/l10n/messages_pl.properties index 6ed2c71de..4c1cefc01 100644 --- a/core/resources/l10n/messages_pl.properties +++ b/core/resources/l10n/messages_pl.properties @@ -1592,8 +1592,8 @@ update.dlg.latestVersion = Korzystasz z najnowszej wersji OpenRocket: %s. CustomFinImport.description = Obraz zostanie automatycznie zamieniony na czarno-bia\u0142y (statecznik w kolorze czarnym), wi\u0119c upewnij si\u0119, \u017Ce kszta\u0142t statecznika jest wype\u0142niony ciemnym kolorem, a t\u0142o jest bia\u0142e lub jasne. Podstawa statecznika musi przylega\u0107 do dolnej kraw\u0119dzi obrazu. - PresetModel.lbl.select = Wybierz ustawienia: - PresetModel.lbl.database = Z bazy danych... + PresetModel.lbl.custompreset = Niestandardowe + PresetModel.lbl.partsLib = Biblioteka cz??ci ! Component Preset Chooser Dialog diff --git a/core/resources/l10n/messages_pt.properties b/core/resources/l10n/messages_pt.properties index 04abc97fe..18ce530f8 100644 --- a/core/resources/l10n/messages_pt.properties +++ b/core/resources/l10n/messages_pt.properties @@ -715,8 +715,8 @@ PreferencesDialog.languages.default = Padr\u00e3o do sistema PreferencesDialog.lbl.language = Idioma da interface: PreferencesDialog.lbl.languageEffect = A linguagem vai mudar na pr\u00f3xima vez que voc\u00ea iniciar o OpenRocket. -PresetModel.lbl.database = \u00c0 partir do banco de dados... -PresetModel.lbl.select = Selecione ajustes pr\u00e9-definidos +PresetModel.lbl.custompreset = Personalizado +PresetModel.lbl.partsLib = Biblioteca de pe\u00e7as PrintDialog.but.previewAndPrint = Visualiza\u00e7\u00e3o e impress\u00e3o PrintDialog.checkbox.showByStage = Mostrar por est\u00e1gio diff --git a/core/resources/l10n/messages_ru.properties b/core/resources/l10n/messages_ru.properties index 1688fc775..2ae02679c 100644 --- a/core/resources/l10n/messages_ru.properties +++ b/core/resources/l10n/messages_ru.properties @@ -2075,8 +2075,8 @@ CustomFinImport.error.badimage = \u041D\u0435\u0432\u043E\u0437\u043C\u043E\u043 CustomFinImport.description = \u0418\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435 \u043F\u0440\u0435\u043E\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044F \u0432 \u0447\u0435\u0440\u043D\u043E-\u0431\u0435\u043B\u043E\u0435 (\u0433\u0434\u0435 \u0447\u0435\u0440\u043D\u044B\u0439 - \u0446\u0432\u0435\u0442 \u0441\u0442\u0430\u0431\u0438\u043B\u0438\u0437\u0430\u0442\u043E\u0440\u0430), \u0442\u0430\u043A \u0447\u0442\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 \u0447\u0435\u0440\u043D\u044B\u0439 \u0446\u0432\u0435\u0442 \u0434\u043B\u044F \u0440\u0438\u0441\u0443\u043D\u043A\u0430 \u0441\u0442\u0430\u0431\u0438\u043B\u0438\u0437\u0430\u0442\u043E\u0440\u0430 \u0438 \u0431\u0435\u043B\u044B\u0439 \u0438\u043B\u0438 \u0441\u0432\u0435\u0442\u043B\u044B\u0439 \u0446\u0432\u0435\u0442 \u0434\u043B\u044F \u0444\u043E\u043D\u0430. \u041E\u0441\u043D\u043E\u0432\u0430\u043D\u0438\u0435 \u0441\u0442\u0430\u0431\u0438\u043B\u0438\u0437\u0430\u0442\u043E\u0440\u0430 \u0434\u043E\u043B\u0436\u043D\u043E \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441\u043D\u0438\u0437\u0443 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F. -PresetModel.lbl.select = \u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0437\u0430\u0433\u043E\u0442\u043E\u0432\u043A\u0443 -PresetModel.lbl.database = \u0418\u0437 \u0431\u0430\u0437\u044B \u0434\u0430\u043D\u043D\u044B\u0445... +PresetModel.lbl.custompreset = \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0020\u0434\u0435\u0442\u0430\u043b\u0435\u0439 +PresetModel.lbl.partsLib = \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0020\u0434\u0435\u0442\u0430\u043b\u0435\u0439 DecalModel.lbl.select = <\u043D\u0435\u0442> DecalModel.lbl.choose = \u0418\u0437 \u0444\u0430\u0439\u043B\u0430... diff --git a/core/resources/l10n/messages_uk_UA.properties b/core/resources/l10n/messages_uk_UA.properties index c5da6e887..a7fc899ed 100644 --- a/core/resources/l10n/messages_uk_UA.properties +++ b/core/resources/l10n/messages_uk_UA.properties @@ -1812,8 +1812,8 @@ CustomFinImport.error.badimage = Could not deduce fin shape from image. CustomFinImport.description = The image will be converted internally to black and white image (black for the fin), so make sure you use a solid dark color for the fin, and white or a light color for the background. The fin must be touching the bottom of the image, which is the base of the fin. -PresetModel.lbl.select = Select preset -PresetModel.lbl.database = From database... +PresetModel.lbl.custompreset = Custom +PresetModel.lbl.partsLib = Parts Library DecalModel.lbl.select = DecalModel.lbl.choose = From file... diff --git a/core/resources/l10n/messages_zh_CN.properties b/core/resources/l10n/messages_zh_CN.properties index b06908d10..e968675da 100644 --- a/core/resources/l10n/messages_zh_CN.properties +++ b/core/resources/l10n/messages_zh_CN.properties @@ -803,8 +803,8 @@ PreferencesDialog.languages.default = \u7CFB\u7EDF\u9ED8\u8BA4 PreferencesDialog.lbl.language = \u754C\u9762\u8BED\u8A00: PreferencesDialog.lbl.languageEffect = \u8BED\u8A00\u8BBE\u7F6E\u5C06\u5728OpenRocket\u91CD\u542F\u540E\u751F\u6548 -PresetModel.lbl.database = \u4ECE\u6570\u636E\u5E93... -PresetModel.lbl.select = \u9009\u62E9\u9884\u8BBE +PresetModel.lbl.custompreset = \u5b9a\u5236 +PresetModel.lbl.partsLib = \u96f6\u4ef6\u5e93 PrintDialog.but.previewAndPrint = \u9884\u89C8 & \u6253\u5370 PrintDialog.checkbox.showByStage = \u6309\u7EA7\u663E\u793A diff --git a/swing/src/net/sf/openrocket/gui/adaptors/PresetModel.java b/swing/src/net/sf/openrocket/gui/adaptors/PresetModel.java index e62eac2d5..2fcec306e 100644 --- a/swing/src/net/sf/openrocket/gui/adaptors/PresetModel.java +++ b/swing/src/net/sf/openrocket/gui/adaptors/PresetModel.java @@ -5,17 +5,14 @@ import java.util.List; import javax.swing.AbstractListModel; import javax.swing.ComboBoxModel; -import javax.swing.SwingUtilities; -import net.sf.openrocket.database.ComponentPresetDatabase; -import net.sf.openrocket.gui.configdialog.RocketComponentConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import net.sf.openrocket.gui.configdialog.RocketComponentConfig; import net.sf.openrocket.database.Database; import net.sf.openrocket.database.DatabaseListener; import net.sf.openrocket.document.OpenRocketDocument; -import net.sf.openrocket.gui.dialogs.preset.ComponentPresetChooserDialog; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.logging.Markers; import net.sf.openrocket.preset.ComponentPreset; @@ -30,8 +27,7 @@ public class PresetModel extends AbstractListModel implements ComboBoxModel, Com private static final Logger log = LoggerFactory.getLogger(PresetModel.class); private static final Translator trans = Application.getTranslator(); - private static final String NONE_SELECTED = trans.get("lbl.select"); - private static final String SELECT_DATABASE = trans.get("lbl.database"); + private static final String NONE_SELECTED = String.format("%s", trans.get("PresetModel.lbl.custompreset")); private final Component parent; private final RocketComponent component; @@ -51,7 +47,7 @@ public class PresetModel extends AbstractListModel implements ComboBoxModel, Com @Override public int getSize() { - return presets.size() + 2; + return presets.size() + 1; } @Override @@ -59,9 +55,6 @@ public class PresetModel extends AbstractListModel implements ComboBoxModel, Com if (index == 0) { return NONE_SELECTED; } - if (index == getSize() - 1) { - return SELECT_DATABASE; - } return presets.get(index - 1); } @@ -73,21 +66,6 @@ public class PresetModel extends AbstractListModel implements ComboBoxModel, Com throw new BugException("item is null"); } else if (item.equals(NONE_SELECTED)) { component.clearPreset(); - } else if (item.equals(SELECT_DATABASE)) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - ((ComponentPresetDatabase) Application.getComponentPresetDao()).addDatabaseListener(PresetModel.this); - ComponentPresetChooserDialog dialog = - new ComponentPresetChooserDialog(SwingUtilities.getWindowAncestor(parent), component); - dialog.setVisible(true); - ComponentPreset preset = dialog.getSelectedComponentPreset(); - if (preset != null) { - setSelectedItem(preset); - } - ((ComponentPresetDatabase) Application.getComponentPresetDao()).removeChangeListener(PresetModel.this); - } - }); } else { document.addUndoPosition("Use Preset " + component.getComponentName()); component.loadPreset((ComponentPreset) item); diff --git a/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java index dd27f02c3..59628c5ac 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java @@ -25,6 +25,7 @@ import javax.swing.JTextField; import javax.swing.SwingUtilities; import net.miginfocom.swing.MigLayout; +import net.sf.openrocket.database.ComponentPresetDatabase; import net.sf.openrocket.document.OpenRocketDocument; import net.sf.openrocket.gui.SpinnerEditor; import net.sf.openrocket.gui.adaptors.BooleanModel; @@ -37,6 +38,7 @@ import net.sf.openrocket.gui.components.BasicSlider; import net.sf.openrocket.gui.components.StyledLabel; import net.sf.openrocket.gui.components.StyledLabel.Style; import net.sf.openrocket.gui.components.UnitSelector; +import net.sf.openrocket.gui.dialogs.preset.ComponentPresetChooserDialog; import net.sf.openrocket.gui.util.GUIUtil; import net.sf.openrocket.gui.widgets.SelectColorButton; import net.sf.openrocket.l10n.Translator; @@ -117,8 +119,20 @@ public class RocketComponentConfig extends JPanel { // If the component supports a preset, show the preset selection box. presetModel = new PresetModel(this, document, component); presetComboBox = new JComboBox(presetModel); + presetComboBox.setMaximumRowCount(25); presetComboBox.setEditable(false); - this.add(presetComboBox, ""); + presetComboBox.setToolTipText(trans.get("PresetModel.combo.ttip")); + this.add(presetComboBox, "growx 110"); + + final JButton selectPreset = new SelectColorButton(trans.get("PresetModel.lbl.partsLib")); + selectPreset.setToolTipText(trans.get("PresetModel.lbl.partsLib.ttip")); + selectPreset.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + selectPreset(); + } + }); + this.add(selectPreset); } tabbedPane = new JTabbedPane(); @@ -243,6 +257,24 @@ public class RocketComponentConfig extends JPanel { } } + private void selectPreset() { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (presetComboBox == null || presetModel == null) return; + ((ComponentPresetDatabase) Application.getComponentPresetDao()).addDatabaseListener(presetModel); + ComponentPresetChooserDialog dialog = + new ComponentPresetChooserDialog(SwingUtilities.getWindowAncestor(RocketComponentConfig.this), component); + dialog.setVisible(true); + ComponentPreset preset = dialog.getSelectedComponentPreset(); + if (preset != null) { + presetModel.setSelectedItem(preset); + } + ((ComponentPresetDatabase) Application.getComponentPresetDao()).removeChangeListener(presetModel); + } + }); + } + public void clearConfigListeners() { if (appearancePanel != null) { appearancePanel.clearConfigListeners();