From b3399f2d356d8891fbd1c902e593ddf45055a3ba Mon Sep 17 00:00:00 2001 From: Sibo Van Gool Date: Sun, 30 Jan 2022 20:06:13 +0100 Subject: [PATCH] [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