Merge pull request #1505 from SiboVG/issue-1481

[#1481] Improvements to Preset selection menu
This commit is contained in:
SiboVG 2022-07-19 22:19:33 +02:00 committed by GitHub
commit 01d868a186
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 65 additions and 53 deletions

View File

@ -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. 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.combo.ttip = <html>Select a preset model from a list of favorites (selected in the component preset dialog),<br>or select 'Custom' when no preset is required.</html>
PresetModel.lbl.database = From database\u2026 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 = <none> DecalModel.lbl.select = <none>
DecalModel.lbl.choose = From file\u2026 DecalModel.lbl.choose = From file\u2026
@ -2097,7 +2099,7 @@ ComponentPresetChooserDialog.menu.sortDesc = Sort Descending
ComponentPresetChooserDialog.menu.units = Units ComponentPresetChooserDialog.menu.units = Units
ComponentPresetChooserDialog.checkbox.showAllCompatible = Show all compatible ComponentPresetChooserDialog.checkbox.showAllCompatible = Show all compatible
ComponentPresetChooserDialog.checkbox.showLegacyCheckBox = Show Legacy Database 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.Favorite = Favorite
table.column.Legacy = Legacy table.column.Legacy = Legacy
table.column.Manufacturer = Manufacturer table.column.Manufacturer = Manufacturer

View File

@ -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. 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.custompreset = Vlastní
PresetModel.lbl.database = Z databáze... PresetModel.lbl.partsLib = Knihovna díl?
! Component Preset Chooser Dialog ! Component Preset Chooser Dialog

View File

@ -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. 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.custompreset = Benutzerdefiniert
PresetModel.lbl.database = Aus Datenbank... PresetModel.lbl.partsLib = Teile-Bibliothek
! Component Preset Chooser Dialog ! Component Preset Chooser Dialog

View File

@ -737,8 +737,8 @@ PreferencesDialog.languages.default = Idioma por defecto
PreferencesDialog.lbl.language = Idioma de la interfaz: PreferencesDialog.lbl.language = Idioma de la interfaz:
PreferencesDialog.lbl.languageEffect = El idioma cambiar\u00e1 la pr\u00f3xima vez que abra OpenRocket. PreferencesDialog.lbl.languageEffect = El idioma cambiar\u00e1 la pr\u00f3xima vez que abra OpenRocket.
PresetModel.lbl.database = Desde la Base de Datos... PresetModel.lbl.custompreset = Personalizado
PresetModel.lbl.select = Prefabricado PresetModel.lbl.partsLib = Biblioteca de piezas
PrintDialog.but.previewAndPrint = Vista previa e Imprimir PrintDialog.but.previewAndPrint = Vista previa e Imprimir
PrintDialog.checkbox.showByStage = Mostrar por etapas PrintDialog.checkbox.showByStage = Mostrar por etapas

View File

@ -729,8 +729,8 @@ PreferencesDialog.languages.default = Valeur syst\u00E8me par d\u00E9faut
PreferencesDialog.lbl.language = Langue du programme: PreferencesDialog.lbl.language = Langue du programme:
PreferencesDialog.lbl.languageEffect = La langue sera chang\u00E9e apr\u00E8s avoir red\u00E9marr\u00E9 OpenRocket. 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.custompreset = Personnalisé
PresetModel.lbl.select = Choisir une pi\u00E8ce pr\u00E9d\u00E9finie: PresetModel.lbl.partsLib = Biblioth\u00E8que de pi\u00E8ces
PrintDialog.but.previewAndPrint = Pr\u00E9-visualiser et imprimer PrintDialog.but.previewAndPrint = Pr\u00E9-visualiser et imprimer
PrintDialog.checkbox.showByStage = Montrer par \u00E9tage PrintDialog.checkbox.showByStage = Montrer par \u00E9tage

View File

@ -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. 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.custompreset = Personalizzato
PresetModel.lbl.database = Da database... PresetModel.lbl.partsLib = Libreria di parti
! Component Preset Chooser Dialog ! Component Preset Chooser Dialog

View File

@ -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 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.custompreset = \u30ab\u30b9\u30bf\u30e0
PresetModel.lbl.database = From database... PresetModel.lbl.partsLib = \u30d1\u30fc\u30c4\u30e9\u30a4\u30d6\u30e9\u30ea\u30fc
! Component Preset Chooser Dialog ! Component Preset Chooser Dialog

View File

@ -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. 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.custompreset = Aangepast
PresetModel.lbl.database = Uit databank... PresetModel.lbl.partsLib = Onderdelenbibliotheek
DecalModel.lbl.select = <geen> DecalModel.lbl.select = <geen>
DecalModel.lbl.choose = Van bestand... DecalModel.lbl.choose = Van bestand...

View File

@ -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. 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.custompreset = Niestandardowe
PresetModel.lbl.database = Z bazy danych... PresetModel.lbl.partsLib = Biblioteka cz??ci
! Component Preset Chooser Dialog ! Component Preset Chooser Dialog

View File

@ -715,8 +715,8 @@ PreferencesDialog.languages.default = Padr\u00e3o do sistema
PreferencesDialog.lbl.language = Idioma da interface: PreferencesDialog.lbl.language = Idioma da interface:
PreferencesDialog.lbl.languageEffect = A linguagem vai mudar na pr\u00f3xima vez que voc\u00ea iniciar o OpenRocket. 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.custompreset = Personalizado
PresetModel.lbl.select = Selecione ajustes pr\u00e9-definidos PresetModel.lbl.partsLib = Biblioteca de pe\u00e7as
PrintDialog.but.previewAndPrint = Visualiza\u00e7\u00e3o e impress\u00e3o PrintDialog.but.previewAndPrint = Visualiza\u00e7\u00e3o e impress\u00e3o
PrintDialog.checkbox.showByStage = Mostrar por est\u00e1gio PrintDialog.checkbox.showByStage = Mostrar por est\u00e1gio

View File

@ -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. 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.custompreset = \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0020\u0434\u0435\u0442\u0430\u043b\u0435\u0439
PresetModel.lbl.database = \u0418\u0437 \u0431\u0430\u0437\u044B \u0434\u0430\u043D\u043D\u044B\u0445... 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.select = <\u043D\u0435\u0442>
DecalModel.lbl.choose = \u0418\u0437 \u0444\u0430\u0439\u043B\u0430... DecalModel.lbl.choose = \u0418\u0437 \u0444\u0430\u0439\u043B\u0430...

View File

@ -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. 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.custompreset = Custom
PresetModel.lbl.database = From database... PresetModel.lbl.partsLib = Parts Library
DecalModel.lbl.select = <none> DecalModel.lbl.select = <none>
DecalModel.lbl.choose = From file... DecalModel.lbl.choose = From file...

View File

@ -803,8 +803,8 @@ PreferencesDialog.languages.default = \u7CFB\u7EDF\u9ED8\u8BA4
PreferencesDialog.lbl.language = \u754C\u9762\u8BED\u8A00: PreferencesDialog.lbl.language = \u754C\u9762\u8BED\u8A00:
PreferencesDialog.lbl.languageEffect = \u8BED\u8A00\u8BBE\u7F6E\u5C06\u5728OpenRocket\u91CD\u542F\u540E\u751F\u6548 PreferencesDialog.lbl.languageEffect = \u8BED\u8A00\u8BBE\u7F6E\u5C06\u5728OpenRocket\u91CD\u542F\u540E\u751F\u6548
PresetModel.lbl.database = \u4ECE\u6570\u636E\u5E93... PresetModel.lbl.custompreset = \u5b9a\u5236
PresetModel.lbl.select = \u9009\u62E9\u9884\u8BBE PresetModel.lbl.partsLib = \u96f6\u4ef6\u5e93
PrintDialog.but.previewAndPrint = \u9884\u89C8 & \u6253\u5370 PrintDialog.but.previewAndPrint = \u9884\u89C8 & \u6253\u5370
PrintDialog.checkbox.showByStage = \u6309\u7EA7\u663E\u793A PrintDialog.checkbox.showByStage = \u6309\u7EA7\u663E\u793A

View File

@ -5,17 +5,14 @@ import java.util.List;
import javax.swing.AbstractListModel; import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import net.sf.openrocket.gui.configdialog.RocketComponentConfig;
import net.sf.openrocket.database.Database; import net.sf.openrocket.database.Database;
import net.sf.openrocket.database.DatabaseListener; import net.sf.openrocket.database.DatabaseListener;
import net.sf.openrocket.document.OpenRocketDocument; import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.gui.dialogs.preset.ComponentPresetChooserDialog;
import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.Markers; import net.sf.openrocket.logging.Markers;
import net.sf.openrocket.preset.ComponentPreset; 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 Logger log = LoggerFactory.getLogger(PresetModel.class);
private static final Translator trans = Application.getTranslator(); private static final Translator trans = Application.getTranslator();
private static final String NONE_SELECTED = trans.get("lbl.select"); private static final String NONE_SELECTED = String.format("<html><i>%s</i></html>", trans.get("PresetModel.lbl.custompreset"));
private static final String SELECT_DATABASE = trans.get("lbl.database");
private final Component parent; private final Component parent;
private final RocketComponent component; private final RocketComponent component;
@ -51,7 +47,7 @@ public class PresetModel extends AbstractListModel implements ComboBoxModel, Com
@Override @Override
public int getSize() { public int getSize() {
return presets.size() + 2; return presets.size() + 1;
} }
@Override @Override
@ -59,9 +55,6 @@ public class PresetModel extends AbstractListModel implements ComboBoxModel, Com
if (index == 0) { if (index == 0) {
return NONE_SELECTED; return NONE_SELECTED;
} }
if (index == getSize() - 1) {
return SELECT_DATABASE;
}
return presets.get(index - 1); return presets.get(index - 1);
} }
@ -73,21 +66,6 @@ public class PresetModel extends AbstractListModel implements ComboBoxModel, Com
throw new BugException("item is null"); throw new BugException("item is null");
} else if (item.equals(NONE_SELECTED)) { } else if (item.equals(NONE_SELECTED)) {
component.clearPreset(); 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 { } else {
document.addUndoPosition("Use Preset " + component.getComponentName()); document.addUndoPosition("Use Preset " + component.getComponentName());
component.loadPreset((ComponentPreset) item); component.loadPreset((ComponentPreset) item);

View File

@ -25,6 +25,7 @@ import javax.swing.JTextField;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.database.ComponentPresetDatabase;
import net.sf.openrocket.document.OpenRocketDocument; import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.gui.SpinnerEditor; import net.sf.openrocket.gui.SpinnerEditor;
import net.sf.openrocket.gui.adaptors.BooleanModel; 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;
import net.sf.openrocket.gui.components.StyledLabel.Style; import net.sf.openrocket.gui.components.StyledLabel.Style;
import net.sf.openrocket.gui.components.UnitSelector; 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.util.GUIUtil;
import net.sf.openrocket.gui.widgets.SelectColorButton; import net.sf.openrocket.gui.widgets.SelectColorButton;
import net.sf.openrocket.l10n.Translator; 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. // If the component supports a preset, show the preset selection box.
presetModel = new PresetModel(this, document, component); presetModel = new PresetModel(this, document, component);
presetComboBox = new JComboBox(presetModel); presetComboBox = new JComboBox(presetModel);
presetComboBox.setMaximumRowCount(25);
presetComboBox.setEditable(false); 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(); 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() { public void clearConfigListeners() {
if (appearancePanel != null) { if (appearancePanel != null) {
appearancePanel.clearConfigListeners(); appearancePanel.clearConfigListeners();