From 42a0e4b3898c3995fa425d8df9896cedec5105e1 Mon Sep 17 00:00:00 2001 From: Sibo Van Gool Date: Sun, 30 Jan 2022 01:19:09 +0100 Subject: [PATCH 1/9] [fixes #1088] Trigger select after new/copy motor config --- .../gui/main/flightconfigpanel/FlightConfigurationPanel.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java index 6956ab0b4..20bd8f5c7 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java @@ -81,6 +81,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe motorConfigurationPanel.table.setRowSelectionInterval(lastRow, lastRow); motorConfigurationPanel.table.setColumnSelectionInterval(lastCol, lastCol); configurationChanged(ComponentChangeEvent.MOTOR_CHANGE); + configurationChanged(ComponentChangeEvent.NONFUNCTIONAL_CHANGE); // Trigger select } }); @@ -113,6 +114,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe public void actionPerformed(ActionEvent e) { addOrCopyConfiguration(true); configurationChanged(ComponentChangeEvent.MOTOR_CHANGE); + configurationChanged(ComponentChangeEvent.NONFUNCTIONAL_CHANGE); // Trigger select } }); this.add(copyConfButton, "wrap"); From ce8be058650076a791e0364edd0280b2af44effd Mon Sep 17 00:00:00 2001 From: Sibo Van Gool Date: Sun, 30 Jan 2022 01:27:06 +0100 Subject: [PATCH 2/9] [fixes #1088] Open motor selection upon new/copy config --- .../gui/main/flightconfigpanel/FlightConfigurationPanel.java | 2 ++ .../gui/main/flightconfigpanel/MotorConfigurationPanel.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java index 20bd8f5c7..969086d28 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java @@ -82,6 +82,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe motorConfigurationPanel.table.setColumnSelectionInterval(lastCol, lastCol); configurationChanged(ComponentChangeEvent.MOTOR_CHANGE); configurationChanged(ComponentChangeEvent.NONFUNCTIONAL_CHANGE); // Trigger select + motorConfigurationPanel.selectMotor(); } }); @@ -115,6 +116,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe addOrCopyConfiguration(true); configurationChanged(ComponentChangeEvent.MOTOR_CHANGE); configurationChanged(ComponentChangeEvent.NONFUNCTIONAL_CHANGE); // Trigger select + motorConfigurationPanel.selectMotor(); } }); this.add(copyConfButton, "wrap"); diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java index 1a86911db..774b01277 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java @@ -204,7 +204,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel } } - private void selectMotor() { + public void selectMotor() { MotorMount curMount = getSelectedComponent(); FlightConfigurationId fcid= getSelectedConfigurationId(); if ( (null == fcid )||( null == curMount )){ From d916fdc64af8557d2db7686b80fb0ceb6f116d2a Mon Sep 17 00:00:00 2001 From: Sibo Van Gool Date: Sun, 30 Jan 2022 01:32:57 +0100 Subject: [PATCH 3/9] [fixes #1088] Set 'Enter' as hotkey for select motor --- .../MotorConfigurationPanel.java | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java index 774b01277..7b3252fd4 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java @@ -4,16 +4,20 @@ import java.awt.CardLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import javax.swing.AbstractAction; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; +import javax.swing.KeyStroke; import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; import javax.swing.event.TableModelEvent; @@ -56,7 +60,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel protected FlightConfigurableTableModel configurationTableModel; MotorConfigurationPanel(final FlightConfigurationPanel flightConfigurationPanel, Rocket rocket) { - super(flightConfigurationPanel,rocket); + super(flightConfigurationPanel, rocket); motorChooserDialog = new MotorChooserDialog(SwingUtilities.getWindowAncestor(flightConfigurationPanel)); @@ -66,20 +70,20 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel JLabel label = new StyledLabel(trans.get("lbl.motorMounts"), Style.BOLD); subpanel.add(label, "wrap"); - MotorMountConfigurationPanel mountConfigPanel = new MotorMountConfigurationPanel(this,rocket); + MotorMountConfigurationPanel mountConfigPanel = new MotorMountConfigurationPanel(this, rocket); subpanel.add(mountConfigPanel, "grow"); this.add(subpanel, "split, w 200lp, growy"); } cards = new JPanel(new CardLayout()); - this.add( cards ); - + this.add(cards); + JLabel helpText = new JLabel(trans.get("MotorConfigurationPanel.lbl.nomotors")); - cards.add(helpText, HELP_LABEL ); - + cards.add(helpText, HELP_LABEL); + JScrollPane scroll = new JScrollPane(table); - cards.add(scroll, TABLE_LABEL ); - + cards.add(scroll, TABLE_LABEL); + this.add(cards, "grow, wrap"); //// Select motor @@ -122,6 +126,15 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel }); this.add(resetIgnitionButton, "sizegroup button, wrap"); + // Set 'Enter' key action to open the motor selection dialog + table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter"); + table.getActionMap().put("Enter", new AbstractAction() { + @Override + public void actionPerformed(ActionEvent ae) { + selectMotor(); + } + }); + updateButtonState(); } From d0a1025f6d77be2064ecf43fcbecdbbc0c0c52d4 Mon Sep 17 00:00:00 2001 From: Sibo Van Gool Date: Sun, 30 Jan 2022 13:57:59 +0100 Subject: [PATCH 4/9] Remove redundant imports --- .../gui/main/flightconfigpanel/MotorConfigurationPanel.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java index 7b3252fd4..d775c7ca0 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java @@ -33,15 +33,12 @@ import net.sf.openrocket.gui.widgets.SelectColorButton; import net.sf.openrocket.motor.IgnitionEvent; import net.sf.openrocket.motor.Motor; import net.sf.openrocket.motor.MotorConfiguration; -import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.BodyTube; import net.sf.openrocket.rocketcomponent.ComponentChangeEvent; -import net.sf.openrocket.rocketcomponent.FlightConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfigurationId; import net.sf.openrocket.rocketcomponent.InnerTube; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.Rocket; -import net.sf.openrocket.startup.Application; import net.sf.openrocket.unit.UnitGroup; import net.sf.openrocket.util.Chars; From b26ae9e541070d2518c17be3f49e1924d5959e8d Mon Sep 17 00:00:00 2001 From: Sibo Van Gool Date: Sun, 30 Jan 2022 14:03:29 +0100 Subject: [PATCH 5/9] Adapt new/copy config windows popup based on current tab This will make sure that e.g. when you are in the recovery tab and add a new configuration, that the deployment window opens instead of the motor selection window --- .../FlightConfigurationPanel.java | 24 +++++++++++++++++-- .../RecoveryConfigurationPanel.java | 2 +- .../SeparationConfigurationPanel.java | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java index 969086d28..132ad0472 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java @@ -82,7 +82,17 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe motorConfigurationPanel.table.setColumnSelectionInterval(lastCol, lastCol); configurationChanged(ComponentChangeEvent.MOTOR_CHANGE); configurationChanged(ComponentChangeEvent.NONFUNCTIONAL_CHANGE); // Trigger select - motorConfigurationPanel.selectMotor(); + switch (tabs.getSelectedIndex()) { + case MOTOR_TAB_INDEX: + motorConfigurationPanel.selectMotor(); + break; + case RECOVERY_TAB_INDEX: + recoveryConfigurationPanel.selectDeployment(); + break; + case SEPARATION_TAB_INDEX: + separationConfigurationPanel.selectSeparation(); + break; + } } }); @@ -116,7 +126,17 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe addOrCopyConfiguration(true); configurationChanged(ComponentChangeEvent.MOTOR_CHANGE); configurationChanged(ComponentChangeEvent.NONFUNCTIONAL_CHANGE); // Trigger select - motorConfigurationPanel.selectMotor(); + switch (tabs.getSelectedIndex()) { + case MOTOR_TAB_INDEX: + motorConfigurationPanel.selectMotor(); + break; + case RECOVERY_TAB_INDEX: + recoveryConfigurationPanel.selectDeployment(); + break; + case SEPARATION_TAB_INDEX: + separationConfigurationPanel.selectSeparation(); + break; + } } }); this.add(copyConfButton, "wrap"); diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/RecoveryConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/RecoveryConfigurationPanel.java index 9fd246ec2..46575bc5f 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/RecoveryConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/RecoveryConfigurationPanel.java @@ -97,7 +97,7 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel Date: Sun, 30 Jan 2022 14:05:53 +0100 Subject: [PATCH 6/9] [fixes #1088] Set 'Enter' hotkey for recovery and separation tables --- .../RecoveryConfigurationPanel.java | 13 +++++++++++++ .../SeparationConfigurationPanel.java | 14 +++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/RecoveryConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/RecoveryConfigurationPanel.java index 46575bc5f..4a6299eb9 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/RecoveryConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/RecoveryConfigurationPanel.java @@ -2,14 +2,18 @@ package net.sf.openrocket.gui.main.flightconfigpanel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import javax.swing.AbstractAction; import javax.swing.JButton; +import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.JTable; +import javax.swing.KeyStroke; import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; @@ -59,6 +63,15 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel Date: Sun, 30 Jan 2022 14:12:26 +0100 Subject: [PATCH 7/9] [fixes #1088] Fix recovery and separation not selected upon tab change --- .../FlightConfigurationPanel.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java index 132ad0472..75c7dbc2a 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java @@ -8,6 +8,8 @@ import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import net.miginfocom.swing.MigLayout; import net.sf.openrocket.document.OpenRocketDocument; @@ -141,6 +143,24 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe }); this.add(copyConfButton, "wrap"); + tabs.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + // Trigger a selection of the motor/recovery/configuration item + switch (tabs.getSelectedIndex()) { + case MOTOR_TAB_INDEX: + motorConfigurationPanel.updateButtonState(); + break; + case RECOVERY_TAB_INDEX: + recoveryConfigurationPanel.updateButtonState(); + break; + case SEPARATION_TAB_INDEX: + separationConfigurationPanel.updateButtonState(); + break; + } + } + }); + updateButtonState(); this.add(tabs, "spanx, grow, wrap rel"); From ba973961cd4b50a61d01978e05b048c973f3d9b1 Mon Sep 17 00:00:00 2001 From: Sibo Van Gool Date: Sun, 30 Jan 2022 20:05:16 +0100 Subject: [PATCH 8/9] Better code format --- .../gui/main/flightconfigpanel/MotorConfigurationPanel.java | 3 ++- .../gui/main/flightconfigpanel/RecoveryConfigurationPanel.java | 3 ++- .../main/flightconfigpanel/SeparationConfigurationPanel.java | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java index d775c7ca0..b72b58ff5 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java @@ -124,7 +124,8 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel this.add(resetIgnitionButton, "sizegroup button, wrap"); // Set 'Enter' key action to open the motor selection dialog - table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter"); + table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( + KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter"); table.getActionMap().put("Enter", new AbstractAction() { @Override public void actionPerformed(ActionEvent ae) { diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/RecoveryConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/RecoveryConfigurationPanel.java index 4a6299eb9..5cf62c634 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/RecoveryConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/RecoveryConfigurationPanel.java @@ -65,7 +65,8 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel Date: Sun, 30 Jan 2022 20:06:13 +0100 Subject: [PATCH 9/9] [fixes #1088] Select booster motor first --- .../FlightConfigurablePanel.java | 4 +- .../FlightConfigurationPanel.java | 57 ++++++++----------- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java index 54071c1f1..a0a0f4fc4 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java @@ -84,7 +84,7 @@ public abstract class FlightConfigurablePanel 1) ? 1 : 0; + int col = (table.getColumnCount() > 1) ? table.getColumnCount() - 1 : 0; for (int row = 0; row < table.getRowCount(); row++) { FlightConfigurationId rowFCID = rocket.getId(row); if (rowFCID.equals(current)) { @@ -107,7 +107,7 @@ public abstract class FlightConfigurablePanel 1) ? 1 : 0; + col = (table.getColumnCount() > 1) ? table.getColumnCount() - 1 : 0; } for( int rowNum = 0; rowNum < table.getRowCount(); rowNum++ ) { diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java index 75c7dbc2a..5ef22b8e2 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurationPanel.java @@ -76,25 +76,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe newConfButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - - addOrCopyConfiguration(false); - int lastRow = motorConfigurationPanel.table.getRowCount() - 1; - int lastCol = motorConfigurationPanel.table.getColumnCount() - 1; - motorConfigurationPanel.table.setRowSelectionInterval(lastRow, lastRow); - motorConfigurationPanel.table.setColumnSelectionInterval(lastCol, lastCol); - configurationChanged(ComponentChangeEvent.MOTOR_CHANGE); - configurationChanged(ComponentChangeEvent.NONFUNCTIONAL_CHANGE); // Trigger select - switch (tabs.getSelectedIndex()) { - case MOTOR_TAB_INDEX: - motorConfigurationPanel.selectMotor(); - break; - case RECOVERY_TAB_INDEX: - recoveryConfigurationPanel.selectDeployment(); - break; - case SEPARATION_TAB_INDEX: - separationConfigurationPanel.selectSeparation(); - break; - } + newOrCopyConfigAction(false); } }); @@ -125,20 +107,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe copyConfButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - addOrCopyConfiguration(true); - configurationChanged(ComponentChangeEvent.MOTOR_CHANGE); - configurationChanged(ComponentChangeEvent.NONFUNCTIONAL_CHANGE); // Trigger select - switch (tabs.getSelectedIndex()) { - case MOTOR_TAB_INDEX: - motorConfigurationPanel.selectMotor(); - break; - case RECOVERY_TAB_INDEX: - recoveryConfigurationPanel.selectDeployment(); - break; - case SEPARATION_TAB_INDEX: - separationConfigurationPanel.selectSeparation(); - break; - } + newOrCopyConfigAction(true); } }); this.add(copyConfButton, "wrap"); @@ -166,6 +135,28 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe this.add(tabs, "spanx, grow, wrap rel"); } + /** + * Action for when the new configuration or copy configuration button is pressed. + * @param copy if True, then copy configuration operation, if False then create a new configuration + */ + private void newOrCopyConfigAction(boolean copy) { + addOrCopyConfiguration(copy); + configurationChanged(ComponentChangeEvent.MOTOR_CHANGE); + stateChanged(null); + switch (tabs.getSelectedIndex()) { + case MOTOR_TAB_INDEX: + motorConfigurationPanel.selectMotor(); + break; + case RECOVERY_TAB_INDEX: + recoveryConfigurationPanel.selectDeployment(); + break; + case SEPARATION_TAB_INDEX: + separationConfigurationPanel.selectSeparation(); + break; + } + configurationChanged(ComponentChangeEvent.NONFUNCTIONAL_CHANGE); // Trigger select + } + /** * either create or copy configuration * set new configuration as current