Merge pull request #1097 from SiboVG/issue-1088
[fixes #1088] Select new motor config + others
This commit is contained in:
commit
86260cc7c8
@ -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++ ) {
|
||||
|
@ -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;
|
||||
@ -74,13 +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);
|
||||
newOrCopyConfigAction(false);
|
||||
}
|
||||
|
||||
});
|
||||
@ -111,17 +107,56 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
||||
copyConfButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
addOrCopyConfiguration(true);
|
||||
configurationChanged(ComponentChangeEvent.MOTOR_CHANGE);
|
||||
newOrCopyConfigAction(true);
|
||||
}
|
||||
});
|
||||
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");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -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;
|
||||
@ -29,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;
|
||||
|
||||
@ -56,7 +57,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
||||
protected FlightConfigurableTableModel<MotorMount> configurationTableModel;
|
||||
|
||||
MotorConfigurationPanel(final FlightConfigurationPanel flightConfigurationPanel, Rocket rocket) {
|
||||
super(flightConfigurationPanel,rocket);
|
||||
super(flightConfigurationPanel, rocket);
|
||||
|
||||
motorChooserDialog = new MotorChooserDialog(SwingUtilities.getWindowAncestor(flightConfigurationPanel));
|
||||
|
||||
@ -66,20 +67,20 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
||||
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 +123,16 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
||||
});
|
||||
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();
|
||||
|
||||
}
|
||||
@ -204,7 +215,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
||||
}
|
||||
}
|
||||
|
||||
private void selectMotor() {
|
||||
public void selectMotor() {
|
||||
MotorMount curMount = getSelectedComponent();
|
||||
FlightConfigurationId fcid= getSelectedConfigurationId();
|
||||
if ( (null == fcid )||( null == curMount )){
|
||||
|
@ -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,16 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel<Recovery
|
||||
}
|
||||
});
|
||||
this.add(resetDeploymentButton, "sizegroup button, wrap");
|
||||
|
||||
// Set 'Enter' key action to open the recovery 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) {
|
||||
selectDeployment();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -97,7 +111,7 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel<Recovery
|
||||
return recoveryTable;
|
||||
}
|
||||
|
||||
private void selectDeployment() {
|
||||
public void selectDeployment() {
|
||||
RecoveryDevice c = getSelectedComponent();
|
||||
FlightConfigurationId fcid = getSelectedConfigurationId();
|
||||
if ((c == null) || (fcid == null)) {
|
||||
|
@ -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;
|
||||
|
||||
@ -62,7 +66,16 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel<AxialS
|
||||
}
|
||||
});
|
||||
this.add(resetDeploymentButton, "sizegroup button, wrap");
|
||||
|
||||
|
||||
// Set 'Enter' key action to open the separation 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) {
|
||||
selectSeparation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -104,7 +117,7 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel<AxialS
|
||||
return separationTable;
|
||||
}
|
||||
|
||||
private void selectSeparation() {
|
||||
public void selectSeparation() {
|
||||
AxialStage stage = getSelectedComponent();
|
||||
FlightConfigurationId fcid = getSelectedConfigurationId();
|
||||
if ((stage == null) || (fcid == null)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user