From b3b2303f272bf7e5ff02573c667e9d34769133d9 Mon Sep 17 00:00:00 2001 From: Sampo Niskanen Date: Sun, 27 Jan 2013 22:36:21 +0200 Subject: [PATCH] Enhance flight configuration UI --- core/resources/l10n/messages.properties | 24 ++- core/resources/l10n/messages_cs.properties | 8 +- core/resources/l10n/messages_de.properties | 8 +- core/resources/l10n/messages_es.properties | 8 +- core/resources/l10n/messages_fr.properties | 8 +- core/resources/l10n/messages_it.properties | 8 +- core/resources/l10n/messages_pl.properties | 8 +- core/resources/l10n/messages_ru.properties | 8 +- .../FlightConfigurationDialog.java | 110 +++++------ .../MotorConfigurationPanel.java | 173 ++++++++++-------- .../rocketcomponent/FlightConfigurable.java | 56 +++++- .../sf/openrocket/util/enums/EnumName.java | 2 +- 12 files changed, 254 insertions(+), 167 deletions(-) diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index a43d03cd2..336291665 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -172,21 +172,16 @@ debuglogdlg.lbl.Stacktrace = Stack trace: MotorChooserDialog.title = Select a rocket motor ! Edit Motor configuration dialog -edtmotorconfdlg.but.removemotor = Remove motor -edtmotorconfdlg.but.Selectmotor = Select motor edtmotorconfdlg.but.Removeconfiguration = Remove edtmotorconfdlg.but.Renameconfiguration = Rename edtmotorconfdlg.but.Newconfiguration = New edtmotorconfdlg.but.Copyconfiguration = Copy -edtmotorconfdlg.but.Selectignition = Select ignition -edtmotorconfdlg.lbl.Motormounts = Motor mounts: edtmotorconfdlg.title.Editmotorconf = Edit Flight configurations edtmotorconfdlg.title.Renameconf = Rename Flight Configuration edtmotorconfdlg.title.Selectdeploymentconf = Select Deployment Configuration edtmotorconfdlg.title.Selectignitionconf = Select Ignition Configuration edtmotorconfdlg.title.Selectseparationconf = Select Separation Configuration edtmotorconfdlg.selectcomp = Select which components function as motor mounts: -edtmotorconfdlg.lbl.Motorconfig = Motor configurations: edtmotorconfdlg.lbl.Configname = Configuration name: edtmotorconfdlg.lbl.Motortab = Motors edtmotorconfdlg.lbl.Recoverytab = Recovery @@ -1326,6 +1321,13 @@ MotorMount.IgnitionEvent.EJECTION_CHARGE = First ejection charge of previous sta MotorMount.IgnitionEvent.BURNOUT = First burnout of previous stage MotorMount.IgnitionEvent.NEVER = Never +MotorMount.IgnitionEvent.short.AUTOMATIC = Automatic +MotorMount.IgnitionEvent.short.LAUNCH = Launch +MotorMount.IgnitionEvent.short.EJECTION_CHARGE = Ejection charge +MotorMount.IgnitionEvent.short.BURNOUT = Burnout +MotorMount.IgnitionEvent.short.NEVER = Never + + !ComponentIcons ComponentIcons.Nosecone = Nose cone ComponentIcons.Bodytube = Body tube @@ -1816,3 +1818,15 @@ EditDecalDialog.lbl.always = Always use these settings EditDecalDialog.btn.chooser = Select Graphics Editor Program +MotorConfigurationPanel.lbl.motorMounts = Motor mounts: +MotorConfigurationPanel.lbl.motorConfiguration = Motor configurations: +MotorConfigurationPanel.btn.removeMotor = Remove motor +MotorConfigurationPanel.btn.selectMotor = Select motor +MotorConfigurationPanel.btn.selectIgnition = Select ignition +MotorConfigurationPanel.btn.resetIgnition = Reset ignition + +MotorConfigurationPanel.table.ignition.default = Default ({0}) + + +MotorConfigurationPanel.description = Select the motors and motor ignition events of your rocket.
Motor mounts: Select which components function as motor mounts.
Motor configurations: Select the motor and ignition event for each motor mount. + diff --git a/core/resources/l10n/messages_cs.properties b/core/resources/l10n/messages_cs.properties index c8a913dbd..45bd31b98 100644 --- a/core/resources/l10n/messages_cs.properties +++ b/core/resources/l10n/messages_cs.properties @@ -170,14 +170,14 @@ debuglogdlg.lbl.Stacktrace = Tracov ! Edit Motor configuration dialog -edtmotorconfdlg.but.removemotor = Odeber motor -edtmotorconfdlg.but.Selectmotor = Vyber motor +MotorConfigurationPanel.btn.removeMotor = Odeber motor +MotorConfigurationPanel.btn.selectMotor = Vyber motor edtmotorconfdlg.but.Removeconfiguration = Odeber nastavení edtmotorconfdlg.but.Newconfiguration = Nové nastavení -edtmotorconfdlg.lbl.Motormounts = Pripojení motoru: +MotorConfigurationPanel.lbl.motorMounts = Pripojení motoru: edtmotorconfdlg.title.Editmotorconf = Úprava nastavení motoru edtmotorconfdlg.selectcomp = Vyber ke kterým komponentám se má motor pripojit: -edtmotorconfdlg.lbl.Motorconfig = Nastavení motoru: +MotorConfigurationPanel.lbl.motorConfiguration = Nastavení motoru: edtmotorconfdlg.lbl.Configname = Jméno nastavení: edtmotorconfdlg.lbl.Leavenamedefault = Nechej prázdné polícko jako výchozí hodnotu. diff --git a/core/resources/l10n/messages_de.properties b/core/resources/l10n/messages_de.properties index 38133ab98..ace5b8c43 100644 --- a/core/resources/l10n/messages_de.properties +++ b/core/resources/l10n/messages_de.properties @@ -171,14 +171,14 @@ debuglogdlg.lbl.Stacktrace = Stacktrace: ! Edit Motor configuration dialog -edtmotorconfdlg.but.removemotor = Motor entfernen -edtmotorconfdlg.but.Selectmotor = Motor auswählen +MotorConfigurationPanel.btn.removeMotor = Motor entfernen +MotorConfigurationPanel.btn.selectMotor = Motor auswählen edtmotorconfdlg.but.Removeconfiguration = Konfiguration entfernen edtmotorconfdlg.but.Newconfiguration = Neue Konfiguration -edtmotorconfdlg.lbl.Motormounts = Motorhalterungen: +MotorConfigurationPanel.lbl.motorMounts = Motorhalterungen: edtmotorconfdlg.title.Editmotorconf = Motorkonfiguration bearbeiten edtmotorconfdlg.selectcomp = Auswählen, welche Komponenten Motorhalterungen sind: -edtmotorconfdlg.lbl.Motorconfig = Motorkonfigurationen: +MotorConfigurationPanel.lbl.motorConfiguration = Motorkonfigurationen: edtmotorconfdlg.lbl.Configname = Name der Konfiguration: edtmotorconfdlg.lbl.Leavenamedefault = Leer lassen für Standardwert. diff --git a/core/resources/l10n/messages_es.properties b/core/resources/l10n/messages_es.properties index 36ea24e56..d1d5ade52 100644 --- a/core/resources/l10n/messages_es.properties +++ b/core/resources/l10n/messages_es.properties @@ -179,14 +179,14 @@ debuglogdlg.lbl.Stacktrace = Trazabilidad de la pila: ! Edit Motor configuration dialog -edtmotorconfdlg.but.removemotor = Quitar motor -edtmotorconfdlg.but.Selectmotor = Seleccionar motor +MotorConfigurationPanel.btn.removeMotor = Quitar motor +MotorConfigurationPanel.btn.selectMotor = Seleccionar motor edtmotorconfdlg.but.Removeconfiguration = Quitar configuración edtmotorconfdlg.but.Newconfiguration = Nueva configuración -edtmotorconfdlg.lbl.Motormounts = Porta motor: +MotorConfigurationPanel.lbl.motorMounts = Porta motor: edtmotorconfdlg.title.Editmotorconf = Mostrar las configuraciones de motor edtmotorconfdlg.selectcomp = Seleccionar qué componentes tienen la función de porta motor: -edtmotorconfdlg.lbl.Motorconfig = Configuraciones del motor: +MotorConfigurationPanel.lbl.motorConfiguration = Configuraciones del motor: edtmotorconfdlg.lbl.Configname = Nombre de la configuración: edtmotorconfdlg.lbl.Leavenamedefault = Dejar el nombre por defecto. diff --git a/core/resources/l10n/messages_fr.properties b/core/resources/l10n/messages_fr.properties index ead57a82e..675d7971b 100644 --- a/core/resources/l10n/messages_fr.properties +++ b/core/resources/l10n/messages_fr.properties @@ -173,14 +173,14 @@ debuglogdlg.lbl.Stacktrace = Stack trace: MotorChooserDialog.title = Selectionnez un moteur fusée ! Edit Motor configuration dialog -edtmotorconfdlg.but.removemotor = Enlever le moteur -edtmotorconfdlg.but.Selectmotor = Choisir le moteur +MotorConfigurationPanel.btn.removeMotor = Enlever le moteur +MotorConfigurationPanel.btn.selectMotor = Choisir le moteur edtmotorconfdlg.but.Removeconfiguration = Supprimer la configuration edtmotorconfdlg.but.Newconfiguration = Nouvelle configuration -edtmotorconfdlg.lbl.Motormounts = Portes moteur: +MotorConfigurationPanel.lbl.motorMounts = Portes moteur: edtmotorconfdlg.title.Editmotorconf = Changer la configuration moteur edtmotorconfdlg.selectcomp = Choisir les pièces utilisées par le porte moteur: -edtmotorconfdlg.lbl.Motorconfig = Configurations moteur: +MotorConfigurationPanel.lbl.motorConfiguration = Configurations moteur: edtmotorconfdlg.lbl.Configname = Nom de la configuration: edtmotorconfdlg.lbl.Leavenamedefault = Laisser le champ vide par défaut. diff --git a/core/resources/l10n/messages_it.properties b/core/resources/l10n/messages_it.properties index 1d2c03661..a4ccecaad 100644 --- a/core/resources/l10n/messages_it.properties +++ b/core/resources/l10n/messages_it.properties @@ -173,14 +173,14 @@ debuglogdlg.lbl.Stacktrace = traccia della memoria: ! Edit Motor configuration dialog -edtmotorconfdlg.but.removemotor = Rimuovi il motore -edtmotorconfdlg.but.Selectmotor = Seleziona il motore +MotorConfigurationPanel.btn.removeMotor = Rimuovi il motore +MotorConfigurationPanel.btn.selectMotor = Seleziona il motore edtmotorconfdlg.but.Removeconfiguration = Rimuovi la configurazione edtmotorconfdlg.but.Newconfiguration = Nuova configurazione -edtmotorconfdlg.lbl.Motormounts = Alloggiamenti motore: +MotorConfigurationPanel.lbl.motorMounts = Alloggiamenti motore: edtmotorconfdlg.title.Editmotorconf = Modifica la configurazione del motore edtmotorconfdlg.selectcomp = Seleziona quali componenti fungono da alloggiamenti per il motore: -edtmotorconfdlg.lbl.Motorconfig = Configurazione dei motori: +MotorConfigurationPanel.lbl.motorConfiguration = Configurazione dei motori: edtmotorconfdlg.lbl.Configname = Nome della configurazione: edtmotorconfdlg.lbl.Leavenamedefault = Lascia il campo vuoto per il nome prestabilito. diff --git a/core/resources/l10n/messages_pl.properties b/core/resources/l10n/messages_pl.properties index a25fecd6a..2c6b77364 100644 --- a/core/resources/l10n/messages_pl.properties +++ b/core/resources/l10n/messages_pl.properties @@ -171,14 +171,14 @@ ! Edit Motor configuration dialog - edtmotorconfdlg.but.removemotor = Usu\u0144 silnik - edtmotorconfdlg.but.Selectmotor = Wybierz silnik + MotorConfigurationPanel.btn.removeMotor = Usu\u0144 silnik + MotorConfigurationPanel.btn.selectMotor = Wybierz silnik edtmotorconfdlg.but.Removeconfiguration = Usu\u0144 konfiguracj\u0119 edtmotorconfdlg.but.Newconfiguration = Nowa konfiguracja - edtmotorconfdlg.lbl.Motormounts = Gniazda silnikowe: + MotorConfigurationPanel.lbl.motorMounts = Gniazda silnikowe: edtmotorconfdlg.title.Editmotorconf = Edytuj konfiguracje silnika edtmotorconfdlg.selectcomp = Wybierz cz\u0119\u015Bci, które pe\u0142ni\u0105 funkcj\u0119 gniazd silnikowych: - edtmotorconfdlg.lbl.Motorconfig = Konfiguracje silników: + MotorConfigurationPanel.lbl.motorConfiguration = Konfiguracje silników: edtmotorconfdlg.lbl.Configname = Nazwa konfiguracji: edtmotorconfdlg.lbl.Leavenamedefault = Pozostaw bez nazwy w celu u\u017Cycia nazwy domy\u015Blnej. diff --git a/core/resources/l10n/messages_ru.properties b/core/resources/l10n/messages_ru.properties index 419f679a6..ef1d97f37 100644 --- a/core/resources/l10n/messages_ru.properties +++ b/core/resources/l10n/messages_ru.properties @@ -173,14 +173,14 @@ debuglogdlg.lbl.Stacktrace = \u0421\u0442\u0435\u043a \u0432\u044b\u0437\u043e\u MotorChooserDialog.title = \u0412\u044b\u0431\u043e\u0440 \u0440\u0430\u043a\u0435\u0442\u043d\u043e\u0433\u043e \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044f ! Edit Motor configuration dialog -edtmotorconfdlg.but.removemotor = \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044c -edtmotorconfdlg.but.Selectmotor = \u0412\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044c +MotorConfigurationPanel.btn.removeMotor = \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044c +MotorConfigurationPanel.btn.selectMotor = \u0412\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044c edtmotorconfdlg.but.Removeconfiguration = \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e edtmotorconfdlg.but.Newconfiguration = \u041d\u043e\u0432\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f -edtmotorconfdlg.lbl.Motormounts = \u041a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u0435\u0439: +MotorConfigurationPanel.lbl.motorMounts = \u041a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u0435\u0439: edtmotorconfdlg.title.Editmotorconf = \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u0435\u0439 edtmotorconfdlg.selectcomp = \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u044f\u0432\u043b\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u0435\u0439: -edtmotorconfdlg.lbl.Motorconfig = \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u0435\u0439: +MotorConfigurationPanel.lbl.motorConfiguration = \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u0435\u0439: edtmotorconfdlg.lbl.Configname = \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438: edtmotorconfdlg.lbl.Leavenamedefault = \u041e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0443\u0441\u0442\u044b\u043c \u0434\u043b\u044f \u0438\u043c\u0435\u043d\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. diff --git a/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/FlightConfigurationDialog.java b/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/FlightConfigurationDialog.java index 9a768ebd2..41191f070 100644 --- a/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/FlightConfigurationDialog.java +++ b/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/FlightConfigurationDialog.java @@ -20,69 +20,69 @@ import net.sf.openrocket.gui.main.BasicFrame; import net.sf.openrocket.gui.util.GUIUtil; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.rocketcomponent.Rocket; -import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration; import net.sf.openrocket.rocketvisitors.CopyFlightConfigurationVisitor; import net.sf.openrocket.startup.Application; public class FlightConfigurationDialog extends JDialog { - + static final Translator trans = Application.getTranslator(); - + private final Rocket rocket; - + private FlightConfigurationModel flightConfigurationModel; - + private final JButton renameConfButton, removeConfButton, copyConfButton; - + private final MotorConfigurationPanel motorConfigurationPanel; private final RecoveryConfigurationPanel recoveryConfigurationPanel; private final SeparationConfigurationPanel separationConfigurationPanel; - + private String currentID = null; - + public FlightConfigurationDialog(final Rocket rocket, Window parent) { //// Edit motor configurations super(parent, trans.get("edtmotorconfdlg.title.Editmotorconf"), Dialog.ModalityType.APPLICATION_MODAL); - + currentID = rocket.getDefaultConfiguration().getFlightConfigurationID(); - + if (parent != null) this.setModalityType(ModalityType.DOCUMENT_MODAL); else this.setModalityType(ModalityType.APPLICATION_MODAL); - + this.rocket = rocket; - + JPanel panel = new JPanel(new MigLayout("fill")); - - JLabel label = new JLabel("Selected Configuration: "); + + // FIXME: Localize + JLabel label = new JLabel("Selected Configuration:"); panel.add(label); - + flightConfigurationModel = new FlightConfigurationModel(this, rocket.getDefaultConfiguration()); JComboBox configSelector = new JComboBox(flightConfigurationModel); - - panel.add(configSelector,"gapright para"); - + + panel.add(configSelector, "gapright para"); + JButton newConfButton = new JButton(trans.get("edtmotorconfdlg.but.Newconfiguration")); - newConfButton.addActionListener( new ActionListener() { + newConfButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addConfiguration(); } - + }); - + panel.add(newConfButton); - + renameConfButton = new JButton(trans.get("edtmotorconfdlg.but.Renameconfiguration")); - renameConfButton.addActionListener( new ActionListener() { + renameConfButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - new RenameConfigDialog( rocket, FlightConfigurationDialog.this).setVisible(true); + new RenameConfigDialog(rocket, FlightConfigurationDialog.this).setVisible(true); } }); panel.add(renameConfButton); - + //// Remove configuration removeConfButton = new JButton(trans.get("edtmotorconfdlg.but.Removeconfiguration")); removeConfButton.addActionListener(new ActionListener() { @@ -92,7 +92,7 @@ public class FlightConfigurationDialog extends JDialog { } }); panel.add(removeConfButton); - + //// Copy configuration copyConfButton = new JButton(trans.get("edtmotorconfdlg.but.Copyconfiguration")); copyConfButton.addActionListener(new ActionListener() { @@ -101,27 +101,27 @@ public class FlightConfigurationDialog extends JDialog { copyConfiguration(); } }); - panel.add(copyConfButton,"wrap"); - - + panel.add(copyConfButton, "wrap"); + + //// Tabs for advanced view. JTabbedPane tabs = new JTabbedPane(); - panel.add( tabs, "grow, spanx, w 700lp, h 500lp, wrap"); - + panel.add(tabs, "grow, spanx, w 700lp, h 500lp, wrap"); + //// Motor tabs - motorConfigurationPanel = new MotorConfigurationPanel(this,rocket); + motorConfigurationPanel = new MotorConfigurationPanel(this, rocket); tabs.add(trans.get("edtmotorconfdlg.lbl.Motortab"), motorConfigurationPanel); - + //// Recovery tab - recoveryConfigurationPanel = new RecoveryConfigurationPanel(this,rocket); - tabs.add(trans.get("edtmotorconfdlg.lbl.Recoverytab"), recoveryConfigurationPanel ); - + recoveryConfigurationPanel = new RecoveryConfigurationPanel(this, rocket); + tabs.add(trans.get("edtmotorconfdlg.lbl.Recoverytab"), recoveryConfigurationPanel); + //// Stage tab - separationConfigurationPanel = new SeparationConfigurationPanel(this,rocket); - if ( rocket.getStageCount() > 1 ) { - tabs.add(trans.get("edtmotorconfdlg.lbl.Stagetab"), separationConfigurationPanel ); + separationConfigurationPanel = new SeparationConfigurationPanel(this, rocket); + if (rocket.getStageCount() > 1) { + tabs.add(trans.get("edtmotorconfdlg.lbl.Stagetab"), separationConfigurationPanel); } - + //// Close button JButton close = new JButton(trans.get("dlg.but.close")); close.addActionListener(new ActionListener() { @@ -131,16 +131,16 @@ public class FlightConfigurationDialog extends JDialog { } }); panel.add(close, "spanx, right"); - + this.add(panel); this.validate(); this.pack(); - + updateButtonState(); - + this.setLocationByPlatform(true); GUIUtil.setDisposableDialogOptions(this, close); - + // Undo description final OpenRocketDocument document = BasicFrame.findDocument(rocket); if (document != null) { @@ -154,8 +154,8 @@ public class FlightConfigurationDialog extends JDialog { }); } } - - public void selectConfiguration( String id ) { + + public void selectConfiguration(String id) { currentID = id; rocket.getDefaultConfiguration().setFlightConfigurationID(currentID); motorConfigurationPanel.fireTableDataChanged(); @@ -163,7 +163,7 @@ public class FlightConfigurationDialog extends JDialog { separationConfigurationPanel.fireTableDataChanged(); updateButtonState(); } - + public void addConfiguration() { currentID = rocket.newFlightConfigurationID(); rocket.getDefaultConfiguration().setFlightConfigurationID(currentID); @@ -173,7 +173,7 @@ public class FlightConfigurationDialog extends JDialog { separationConfigurationPanel.fireTableDataChanged(); updateButtonState(); } - + public void copyConfiguration() { // currentID is the currently selected configuration. String newConfigId = rocket.newFlightConfigurationID(); @@ -190,12 +190,12 @@ public class FlightConfigurationDialog extends JDialog { separationConfigurationPanel.fireTableDataChanged(); updateButtonState(); } - - public void changeConfigurationName( String newName ) { + + public void changeConfigurationName(String newName) { rocket.setFlightConfigurationName(currentID, newName); flightConfigurationModel.fireContentsUpdated(); } - + public void removeConfiguration() { if (currentID == null) return; @@ -207,14 +207,14 @@ public class FlightConfigurationDialog extends JDialog { separationConfigurationPanel.fireTableDataChanged(); updateButtonState(); } - + /** * Call this from other panels when a change might cause the names of the configurations to change. */ public void fireContentsUpdated() { flightConfigurationModel.fireContentsUpdated(); } - + private void updateButtonState() { removeConfButton.setEnabled(currentID != null); renameConfButton.setEnabled(currentID != null); @@ -222,6 +222,6 @@ public class FlightConfigurationDialog extends JDialog { recoveryConfigurationPanel.updateButtonState(); separationConfigurationPanel.updateButtonState(); } - - + + } diff --git a/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/MotorConfigurationPanel.java b/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/MotorConfigurationPanel.java index 723bb1bcb..62f6e54c0 100644 --- a/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/MotorConfigurationPanel.java +++ b/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/MotorConfigurationPanel.java @@ -17,23 +17,31 @@ import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import net.miginfocom.swing.MigLayout; +import net.sf.openrocket.gui.components.DescriptionArea; +import net.sf.openrocket.gui.components.StyledLabel; +import net.sf.openrocket.gui.components.StyledLabel.Style; import net.sf.openrocket.gui.dialogs.motor.MotorChooserDialog; import net.sf.openrocket.gui.util.GUIUtil; +import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.motor.Motor; 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; +import net.sf.openrocket.startup.Application; import net.sf.openrocket.util.Chars; public class MotorConfigurationPanel extends JPanel { - + + private static final Translator trans = Application.getTranslator(); + private final FlightConfigurationDialog flightConfigurationDialog; private final Rocket rocket; - + private final MotorConfigurationTableModel configurationTableModel; - private final JButton selectMotorButton, removeMotorButton, selectIgnitionButton; - + private final JButton selectMotorButton, removeMotorButton, selectIgnitionButton, resetIgnitionButton; + private MotorMount currentMount = null; final MotorMount[] mounts; @@ -42,77 +50,76 @@ public class MotorConfigurationPanel extends JPanel { this.flightConfigurationDialog = flightConfigurationDialog; this.rocket = rocket; + DescriptionArea desc = new DescriptionArea(trans.get("description"), 3, -1); + this.add(desc, "spanx, growx, wrap para"); + mounts = getPotentialMotorMounts(); - + //// Motor mount selection - //// Motor mounts: - JLabel label = new JLabel(FlightConfigurationDialog.trans.get("edtmotorconfdlg.lbl.Motormounts")); - this.add(label, "gapbottom para"); - + JLabel label = new StyledLabel(trans.get("lbl.motorMounts"), Style.BOLD); + this.add(label, ""); + //// Motor selection - //// Motor configurations: - label = new JLabel(FlightConfigurationDialog.trans.get("edtmotorconfdlg.lbl.Motorconfig")); - this.add(label, "gapbottom para, wrap"); - - //// Select which components function as motor mounts: - label = new JLabel(FlightConfigurationDialog.trans.get("edtmotorconfdlg.selectcomp")); - this.add(label, "ay 100%, w 1px, growx, wrap"); - + label = new StyledLabel(trans.get("lbl.motorConfiguration"), Style.BOLD); + this.add(label, "wrap rel"); + + //// Motor Mount selection JTable table = new JTable(new MotorMountTableModel(this)); table.setTableHeader(null); table.setShowVerticalLines(false); table.setRowSelectionAllowed(false); table.setColumnSelectionAllowed(false); - + TableColumnModel columnModel = table.getColumnModel(); TableColumn col0 = columnModel.getColumn(0); int w = table.getRowHeight() + 2; col0.setMinWidth(w); col0.setPreferredWidth(w); col0.setMaxWidth(w); - + table.addMouseListener(new GUIUtil.BooleanTableClickListener(table)); JScrollPane scroll = new JScrollPane(table); this.add(scroll, "w 200lp, h 150lp, grow"); - + + //// Motor selection table. configurationTableModel = new MotorConfigurationTableModel(this, true); final JTable configurationTable = new JTable(configurationTableModel); configurationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); configurationTable.setRowSelectionAllowed(true); - + configurationTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int row = configurationTable.getSelectedRow(); - - if ( row >= 0 ) { + + if (row >= 0) { currentMount = findMount(row); - } else { + } else { currentMount = null; } - + if (e.getClickCount() == 1) { - + // Single click updates selection updateButtonState(); - + } else if (e.getClickCount() == 2) { - + // Double-click edits motor selectMotor(); - + } - + } }); - + scroll = new JScrollPane(configurationTable); this.add(scroll, "w 500lp, h 150lp, grow, wrap"); - + //// Select motor - selectMotorButton = new JButton(FlightConfigurationDialog.trans.get("edtmotorconfdlg.but.Selectmotor")); + selectMotorButton = new JButton(trans.get("MotorConfigurationPanel.btn.selectMotor")); selectMotorButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -120,27 +127,38 @@ public class MotorConfigurationPanel extends JPanel { } }); this.add(selectMotorButton, "skip, split, sizegroup button"); - + //// Remove motor button - removeMotorButton = new JButton(FlightConfigurationDialog.trans.get("edtmotorconfdlg.but.removemotor")); + removeMotorButton = new JButton(trans.get("MotorConfigurationPanel.btn.removeMotor")); removeMotorButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeMotor(); } }); - this.add(removeMotorButton,"sizegroup button"); - + this.add(removeMotorButton, "sizegroup button"); + //// Select Ignition button - selectIgnitionButton = new JButton(FlightConfigurationDialog.trans.get("edtmotorconfdlg.but.Selectignition")); + selectIgnitionButton = new JButton(trans.get("MotorConfigurationPanel.btn.selectIgnition")); selectIgnitionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectIgnition(); } }); - this.add(selectIgnitionButton,"sizegroup button, wrap"); - + this.add(selectIgnitionButton, "sizegroup button"); + + //// Reset Ignition button + resetIgnitionButton = new JButton(trans.get("MotorConfigurationPanel.btn.resetIgnition")); + resetIgnitionButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // FIXME + selectIgnition(); + } + }); + this.add(resetIgnitionButton, "sizegroup button, wrap"); + } public void fireTableDataChanged() { @@ -154,14 +172,15 @@ public class MotorConfigurationPanel extends JPanel { selectMotorButton.setEnabled(currentMount != null && currentID != null); removeMotorButton.setEnabled(currentMount != null && currentID != null); selectIgnitionButton.setEnabled(currentMount != null && currentID != null); + resetIgnitionButton.setEnabled(currentMount != null && currentID != null); } - + private void selectMotor() { String currentID = rocket.getDefaultConfiguration().getFlightConfigurationID(); if (currentID == null || currentMount == null) return; - + MotorChooserDialog dialog = new MotorChooserDialog( currentMount.getMotor(currentID), currentMount.getMotorDelay(currentID), @@ -170,24 +189,24 @@ public class MotorConfigurationPanel extends JPanel { dialog.setVisible(true); Motor m = dialog.getSelectedMotor(); double d = dialog.getSelectedDelay(); - + if (m != null) { currentMount.setMotor(currentID, m); currentMount.setMotorDelay(currentID, d); } - + flightConfigurationDialog.fireContentsUpdated(); configurationTableModel.fireTableDataChanged(); updateButtonState(); } - + private void removeMotor() { String currentID = rocket.getDefaultConfiguration().getFlightConfigurationID(); if (currentID == null || currentMount == null) return; - + currentMount.setMotor(currentID, null); - + flightConfigurationDialog.fireContentsUpdated(); configurationTableModel.fireTableDataChanged(); updateButtonState(); @@ -197,24 +216,24 @@ public class MotorConfigurationPanel extends JPanel { String currentID = rocket.getDefaultConfiguration().getFlightConfigurationID(); if (currentID == null || currentMount == null) return; - + SelectIgnitionConfigDialog dialog = new SelectIgnitionConfigDialog( this.flightConfigurationDialog, rocket, - currentMount ); + currentMount); dialog.setVisible(true); - + flightConfigurationDialog.fireContentsUpdated(); configurationTableModel.fireTableDataChanged(); updateButtonState(); } - - public void makeMotorMount( MotorMount mount, boolean isMotorMount ) { - mount.setMotorMount( isMotorMount ); + + public void makeMotorMount(MotorMount mount, boolean isMotorMount) { + mount.setMotorMount(isMotorMount); configurationTableModel.fireTableStructureChanged(); updateButtonState(); } - + private MotorMount[] getPotentialMotorMounts() { List list = new ArrayList(); for (RocketComponent c : rocket) { @@ -224,10 +243,10 @@ public class MotorConfigurationPanel extends JPanel { } return list.toArray(new MotorMount[0]); } - + public MotorMount findMount(int row) { MotorMount mount = null; - + int count = row; for (MotorMount m : mounts) { if (m.isMotorMount()) @@ -237,20 +256,20 @@ public class MotorConfigurationPanel extends JPanel { break; } } - + if (mount == null) { throw new IndexOutOfBoundsException("motor mount not found, row=" + row); } return mount; } - - public String findMotorForDisplay( int row ) { + + public String findMotorForDisplay(int row) { String currentID = rocket.getDefaultConfiguration().getFlightConfigurationID(); MotorMount mount = findMount(row); Motor motor = mount.getMotor(currentID); if (motor == null) return null; - + String str = motor.getDesignation(mount.getMotorDelay(currentID)); int count = mount.getMotorCount(); if (count > 1) { @@ -258,25 +277,33 @@ public class MotorConfigurationPanel extends JPanel { } return str; } - - public String findIgnitionForDisplay( int row ) { + + public String findIgnitionForDisplay(int row) { String currentID = rocket.getDefaultConfiguration().getFlightConfigurationID(); MotorMount mount = findMount(row); MotorConfiguration motorConfig = mount.getFlightConfiguration(currentID); - if (motorConfig == null) - //// None + if (motorConfig == null) { + // No motor exists return null; + } + StringBuilder sb = new StringBuilder(); MotorConfiguration.IgnitionEvent ignition = motorConfig.getIgnitionEvent(); - if ( ignition == null ) { - sb.append("[").append(ellipsizeString(mount.getDefaultIgnitionEvent().toString(),15)).append("]"); + if (ignition == null) { + + // Default ignition event + IgnitionEvent event = mount.getDefaultIgnitionEvent(); + String def = trans.get("table.ignition.default"); + String value = trans.get("MotorMount.IgnitionEvent.short." + event.name()); + return def.replace("{0}", value); + } else { - sb.append(ellipsizeString(ignition.toString(),15)); + sb.append(ellipsizeString(ignition.toString(), 15)); } Double ignitionDelay = motorConfig.getIgnitionDelay(); - if ( ignitionDelay == null ) { + if (ignitionDelay == null) { double defaultdelay = mount.getDefaultIgnitionDelay(); - if ( defaultdelay > 0 ) { + if (defaultdelay > 0) { sb.append(" + [").append(defaultdelay).append("s]"); } } else { @@ -284,14 +311,14 @@ public class MotorConfigurationPanel extends JPanel { } return sb.toString(); } - - private static String ellipsizeString( String s, int length ) { - if ( s.length() < length ) { + + private static String ellipsizeString(String s, int length) { + if (s.length() < length) { return s; } String newString = s.substring(0, length) + "..."; return newString; } - + } diff --git a/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurable.java b/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurable.java index b2df915da..baf600e3f 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurable.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurable.java @@ -1,15 +1,61 @@ package net.sf.openrocket.rocketcomponent; +/** + * An interface defining that specific parameters of a component are + * configurable on a per-flight-configuration basis. + * + * TODO: This should be refactored and redesigned. In the current + * implementation there can be only one object that is overridable, + * while it should be possible to have independent variables being + * overridden. For example: + * - motor selection and ignition selection + * - parachute diameter and parachute deployment + * + * @param The configuration variable type + */ public interface FlightConfigurable { - - public T getFlightConfiguration( String configId ); - public void setFlightConfiguration( String configId, T config ); + /** + * Return the parameters for the provided flight configuration, or + * null if they are not overridden. + * + * @param configId the flight configuration ID + * @return the overridden parameters or null + */ + public T getFlightConfiguration(String configId); - public void cloneFlightConfiguration( String oldConfigId, String newConfigId ); + /** + * Set or removing the overriding parameters for a specific flight configuration. + * If the configuration is null the overriding parameters are removed. + * + * @param configId the flight configuration ID. + * @param config the configuration which will override the default values. + */ + public void setFlightConfiguration(String configId, T config); + /** + * Clone a flight configuration to a new flight configuration ID. + * This functions also in case there is no overridden values for the + * configuration ID. + * + * @param oldConfigId the old configuration ID + * @param newConfigId the new configuration ID + */ + public void cloneFlightConfiguration(String oldConfigId, String newConfigId); + + /** + * Return the default flight configuration to use if the values are not + * overridden. + * + * @return the default configuration (never null) + */ public T getDefaultFlightConfiguration(); - public void setDefaultFlightConfiguration( T config ); + /** + * Set the default flight configuration to use if the values are not overridden. + * + * @param config the default configuration (must not be null) + */ + public void setDefaultFlightConfiguration(T config); } diff --git a/core/src/net/sf/openrocket/util/enums/EnumName.java b/core/src/net/sf/openrocket/util/enums/EnumName.java index 78210612f..e6dfa8476 100644 --- a/core/src/net/sf/openrocket/util/enums/EnumName.java +++ b/core/src/net/sf/openrocket/util/enums/EnumName.java @@ -8,7 +8,7 @@ import net.sf.openrocket.util.BugException; public class EnumName> { - public static final EnumConversion NAME = new EnumConversion() { + private static final EnumConversion NAME = new EnumConversion() { @Override public String convert(Enum e) { return e.name();