[fixes #1088] Select booster motor first

This commit is contained in:
Sibo Van Gool 2022-01-30 20:06:13 +01:00
parent ba973961cd
commit b3399f2d35
2 changed files with 26 additions and 35 deletions

View File

@ -84,7 +84,7 @@ public abstract class FlightConfigurablePanel<T extends FlightConfigurableCompon
private final JTable doTableInitialization() {
JTable table = this.initializeTable();
FlightConfigurationId current = this.rocket.getSelectedConfiguration().getFlightConfigurationID();
int col = (table.getColumnCount() > 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<T extends FlightConfigurableCompon
// We'll select the correct row, in the currently selected column.
int col = table.getSelectedColumn();
if ( col < 0 ) {
col = (table.getColumnCount() > 1) ? 1 : 0;
col = (table.getColumnCount() > 1) ? table.getColumnCount() - 1 : 0;
}
for( int rowNum = 0; rowNum < table.getRowCount(); rowNum++ ) {

View File

@ -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