UI improvements for flight configurations. Ellipsize the ignition

delay.  Change to using row selection instead of cell selection.  Change
the copy configuration to select the new configuration and copy the
name.
This commit is contained in:
kruland2607 2013-01-02 10:42:51 -06:00
parent 177d40104e
commit 98db1885c2
4 changed files with 19 additions and 7 deletions

View File

@ -177,8 +177,13 @@ public class FlightConfigurationDialog extends JDialog {
public void copyConfiguration() {
// currentID is the currently selected configuration.
String newConfigId = rocket.newFlightConfigurationID();
String oldName = rocket.getFlightConfigurationName(currentID);
CopyFlightConfigurationVisitor v = new CopyFlightConfigurationVisitor(currentID, newConfigId);
v.visit(rocket);
// Select the new configuration
this.selectConfiguration(newConfigId);
// Copy the name.
this.changeConfigurationName(oldName);
motorConfigurationPanel.fireTableDataChanged();
flightConfigurationModel.fireContentsUpdated();
recoveryConfigurationPanel.fireTableDataChanged();

View File

@ -80,7 +80,7 @@ public class MotorConfigurationPanel extends JPanel {
configurationTableModel = new MotorConfigurationTableModel(this, true);
final JTable configurationTable = new JTable(configurationTableModel);
configurationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
configurationTable.setCellSelectionEnabled(true);
configurationTable.setRowSelectionAllowed(true);
configurationTable.addMouseListener(new MouseAdapter() {
@Override
@ -269,9 +269,9 @@ public class MotorConfigurationPanel extends JPanel {
StringBuilder sb = new StringBuilder();
MotorConfiguration.IgnitionEvent ignition = motorConfig.getIgnitionEvent();
if ( ignition == null ) {
sb.append("[").append(mount.getDefaultIgnitionEvent().toString()).append("]");
sb.append("[").append(ellipsizeString(mount.getDefaultIgnitionEvent().toString(),15)).append("]");
} else {
sb.append(ignition.toString());
sb.append(ellipsizeString(ignition.toString(),15));
}
Double ignitionDelay = motorConfig.getIgnitionDelay();
if ( ignitionDelay == null ) {
@ -284,6 +284,14 @@ public class MotorConfigurationPanel extends JPanel {
}
return sb.toString();
}
private static String ellipsizeString( String s, int length ) {
if ( s.length() < length ) {
return s;
}
String newString = s.substring(0, length) + "...";
return newString;
}
}

View File

@ -40,15 +40,14 @@ public class RecoveryConfigurationPanel extends JPanel {
recoveryTableModel = new RecoveryTableModel();
JTable table = new JTable( recoveryTableModel );
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setCellSelectionEnabled(true);
table.setRowSelectionAllowed(true);
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
JTable table = (JTable) e.getComponent();
int row = table.getSelectedRow();
int column = table.getSelectedColumn();
if ( row >= 0 & column == 1) {
if ( row >= 0 ) {
selectedComponent = findRecoveryDevice(row);
} else {
selectedComponent = null;

View File

@ -57,7 +57,7 @@ public class SeparationConfigurationPanel extends JPanel {
separationTableModel = new SeparationTableModel();
JTable table = new JTable( separationTableModel );
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setCellSelectionEnabled(true);
table.setRowSelectionAllowed(true);
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {