Added more buttons to configuration including broken copy button. Added

tab layout to pane.  Added ignition spec to motor config table but
haven't hooked it up.
This commit is contained in:
kruland2607 2012-10-16 11:04:01 -05:00
parent 25c5dfec49
commit d00dc2ff34
4 changed files with 220 additions and 159 deletions

View File

@ -175,15 +175,17 @@ MotorChooserDialog.title = Select a rocket motor
! Edit Motor configuration dialog
edtmotorconfdlg.but.removemotor = Remove motor
edtmotorconfdlg.but.Selectmotor = Select motor
edtmotorconfdlg.but.Removeconfiguration = Remove configuration
edtmotorconfdlg.but.Newconfiguration = New configuration
edtmotorconfdlg.but.Removeconfiguration = Remove
edtmotorconfdlg.but.Renameconfiguration = Rename
edtmotorconfdlg.but.Newconfiguration = New
edtmotorconfdlg.but.Copyconfiguration = Copy
edtmotorconfdlg.lbl.Motormounts = <html><b>Motor mounts:</b>
edtmotorconfdlg.title.Editmotorconf = Edit motor configurations
edtmotorconfdlg.selectcomp = <html>Select which components function as motor mounts:
edtmotorconfdlg.lbl.Motorconfig = <html><b>Motor configurations:</b>
edtmotorconfdlg.lbl.Configname = Configuration name:
edtmotorconfdlg.lbl.Leavenamedefault = Leave name empty for default.
edtmotorconfdlg.lbl.Motortab = Motors
edtmotorconfdlg.lbl.Advancemode = Advanced mode
! Example design dialog
exdesigndlg.but.open = Open
exdesigndlg.lbl.Selectexample = Select example designs to open:

View File

@ -12,13 +12,14 @@ import java.util.List;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListDataEvent;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
@ -40,12 +41,11 @@ public class FlightConfigurationDialog extends JDialog {
final MotorMount[] mounts;
private final JTable configurationTable;
final MotorConfigurationTableModel configurationTableModel;
final FlightConfigurationModel flightConfigurationModel;
MotorConfigurationTableModel configurationTableModel;
FlightConfigurationModel flightConfigurationModel;
private final JButton renameConfButton, removeConfButton;
private final JButton selectMotorButton, removeMotorButton;
private final JButton renameConfButton, removeConfButton, copyConfButton;
private JButton selectMotorButton, removeMotorButton;
String currentID = null;
private MotorMount currentMount = null;
@ -67,10 +67,10 @@ public class FlightConfigurationDialog extends JDialog {
mounts = getPotentialMotorMounts();
JPanel panel = new JPanel(new MigLayout("fill, wrap 5"));
JPanel panel = new JPanel(new MigLayout("fill"));
JLabel label = new JLabel("Selected Configuration: ");
panel.add(label,"gapbottom para");
panel.add(label);
flightConfigurationModel = new FlightConfigurationModel(rocket.getDefaultConfiguration());
JComboBox configSelector = new JComboBox(flightConfigurationModel);
@ -88,7 +88,7 @@ public class FlightConfigurationDialog extends JDialog {
panel.add(newConfButton);
renameConfButton = new JButton("Rename Configuration");
renameConfButton = new JButton(trans.get("edtmotorconfdlg.but.Renameconfiguration"));
renameConfButton.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@ -105,87 +105,26 @@ public class FlightConfigurationDialog extends JDialog {
removeConfiguration();
}
});
panel.add(removeConfButton,"wrap");
panel.add(removeConfButton);
//// Motor mount selection
//// <html><b>Motor mounts:</b>
label = new JLabel(trans.get("edtmotorconfdlg.lbl.Motormounts"));
panel.add(label, "gapbottom para");
//// Motor selection
//// <html><b>Motor configurations:</b>
label = new JLabel(trans.get("edtmotorconfdlg.lbl.Motorconfig"));
panel.add(label, "span 4, gapbottom para");
//// <html>Select which components function as motor mounts:
label = new JLabel(trans.get("edtmotorconfdlg.selectcomp"));
panel.add(label, "ay 100%, w 1px, growx, wrap");
//// Motor Mount selection
JTable table = new JTable(new MotorMountTableModel(this));
table.setTableHeader(null);
table.setShowVerticalLines(false);
table.setRowSelectionAllowed(false);
table.setColumnSelectionAllowed(false);
TableColumnModel columnModel = table.getColumnModel();
TableColumn col0 = columnModel.getColumn(0);
int w = table.getRowHeight() + 2;
col0.setMinWidth(w);
col0.setPreferredWidth(w);
col0.setMaxWidth(w);
table.addMouseListener(new GUIUtil.BooleanTableClickListener(table));
JScrollPane scroll = new JScrollPane(table);
panel.add(scroll, "w 200lp, h 150lp, grow");
//// Motor selection table.
configurationTableModel = new MotorConfigurationTableModel(this);
configurationTable = new JTable(configurationTableModel);
configurationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
configurationTable.setCellSelectionEnabled(true);
configurationTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 1) {
// Single click updates selection
updateButtonState();
} else if (e.getClickCount() == 2) {
// Double-click edits motor
selectMotor();
}
}
});
scroll = new JScrollPane(configurationTable);
panel.add(scroll, "span 4, w 500lp, h 150lp, grow");
//// Select motor
selectMotorButton = new JButton(trans.get("edtmotorconfdlg.but.Selectmotor"));
selectMotorButton.addActionListener(new ActionListener() {
//// Copy configuration
copyConfButton = new JButton(trans.get("edtmotorconfdlg.but.Copyconfiguration"));
copyConfButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectMotor();
// FIXME - !
}
});
panel.add(selectMotorButton, "sizegroup button");
panel.add(copyConfButton,"wrap");
//// Remove motor button
removeMotorButton = new JButton(trans.get("edtmotorconfdlg.but.removemotor"));
removeMotorButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
removeMotor();
}
});
panel.add(removeMotorButton,"sizegroup button, wrap");
//// Tabs for advanced view.
JTabbedPane tabs = new JTabbedPane();
//// Motor tabs
JComponent motorTab = makeMotorTab();
tabs.add(trans.get("edtmotorconfdlg.lbl.Motortab"), motorTab);
panel.add( tabs, "spanx, w 700lp, h 500lp, wrap");
//// Close button
JButton close = new JButton(trans.get("dlg.but.close"));
@ -220,7 +159,6 @@ public class FlightConfigurationDialog extends JDialog {
}
}
private MotorMount[] getPotentialMotorMounts() {
List<MotorMount> list = new ArrayList<MotorMount>();
for (RocketComponent c : rocket) {
@ -284,8 +222,7 @@ public class FlightConfigurationDialog extends JDialog {
currentMount.setMotorDelay(currentID, d);
}
int row = configurationTable.getSelectedRow();
configurationTableModel.fireTableRowsUpdated(row, row);
configurationTableModel.fireTableDataChanged();
updateButtonState();
}
@ -296,8 +233,7 @@ public class FlightConfigurationDialog extends JDialog {
currentMount.setMotor(currentID, null);
int row = configurationTable.getSelectedRow();
configurationTableModel.fireTableRowsUpdated(row, row);
configurationTableModel.fireTableDataChanged();
updateButtonState();
}
@ -326,4 +262,101 @@ public class FlightConfigurationDialog extends JDialog {
return mount;
}
private JComponent makeMotorTab( ) {
JPanel panel = new JPanel(new MigLayout("fill"));
//// Motor mount selection
//// <html><b>Motor mounts:</b>
JLabel label = new JLabel(trans.get("edtmotorconfdlg.lbl.Motormounts"));
panel.add(label, "gapbottom para");
//// Motor selection
//// <html><b>Motor configurations:</b>
label = new JLabel(trans.get("edtmotorconfdlg.lbl.Motorconfig"));
panel.add(label, "gapbottom para, wrap");
//// <html>Select which components function as motor mounts:
label = new JLabel(trans.get("edtmotorconfdlg.selectcomp"));
panel.add(label, "ay 100%, w 1px, growx, wrap");
//// Motor Mount selection
JTable table = new JTable(new MotorMountTableModel(this));
table.setTableHeader(null);
table.setShowVerticalLines(false);
table.setRowSelectionAllowed(false);
table.setColumnSelectionAllowed(false);
TableColumnModel columnModel = table.getColumnModel();
TableColumn col0 = columnModel.getColumn(0);
int w = table.getRowHeight() + 2;
col0.setMinWidth(w);
col0.setPreferredWidth(w);
col0.setMaxWidth(w);
table.addMouseListener(new GUIUtil.BooleanTableClickListener(table));
JScrollPane scroll = new JScrollPane(table);
panel.add(scroll, "w 200lp, h 150lp, grow");
//// Motor selection table.
configurationTableModel = new MotorConfigurationTableModel(this, true);
final JTable configurationTable = new JTable(configurationTableModel);
configurationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
configurationTable.setCellSelectionEnabled(true);
configurationTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
JTable table = (JTable) e.getComponent();
int row = configurationTable.getSelectedRow();
int column = configurationTable.getSelectedColumn();
if ( row >= 0 & column == 1) {
currentMount = findMount(row);
} else {
currentMount = null;
}
if (e.getClickCount() == 1) {
// Single click updates selection
updateButtonState();
} else if (e.getClickCount() == 2) {
// Double-click edits motor
selectMotor();
}
}
});
scroll = new JScrollPane(configurationTable);
panel.add(scroll, "w 500lp, h 150lp, grow, wrap");
//// Select motor
selectMotorButton = new JButton(trans.get("edtmotorconfdlg.but.Selectmotor"));
selectMotorButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectMotor();
}
});
panel.add(selectMotorButton, "skip, split, sizegroup button");
//// Remove motor button
removeMotorButton = new JButton(trans.get("edtmotorconfdlg.but.removemotor"));
removeMotorButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
removeMotor();
}
});
panel.add(removeMotorButton,"sizegroup button, wrap");
return panel;
}
}

View File

@ -4,6 +4,7 @@ import javax.swing.table.AbstractTableModel;
import net.sf.openrocket.motor.Motor;
import net.sf.openrocket.rocketcomponent.MotorMount;
import net.sf.openrocket.rocketcomponent.MotorMount.IgnitionEvent;
import net.sf.openrocket.util.Chars;
/**
@ -16,17 +17,19 @@ class MotorConfigurationTableModel extends AbstractTableModel {
*/
private final FlightConfigurationDialog flightConfigurationDialog;
private final boolean advanced;
/**
* @param flightConfigurationDialog
*/
MotorConfigurationTableModel( FlightConfigurationDialog flightConfigurationDialog) {
MotorConfigurationTableModel( FlightConfigurationDialog flightConfigurationDialog, boolean advanced) {
this.flightConfigurationDialog = flightConfigurationDialog;
this.advanced = advanced;
}
@Override
public int getColumnCount() {
int count = 2;
int count = (advanced)? 3: 2;
return count;
}
@ -45,7 +48,9 @@ class MotorConfigurationTableModel extends AbstractTableModel {
String id = this.flightConfigurationDialog.currentID;
if (column == 0) {
switch( column ) {
case 0:
{
MotorMount mount = this.flightConfigurationDialog.findMount(row);
String name = mount.toString();
int count = mount.getMotorCount();
@ -53,31 +58,50 @@ class MotorConfigurationTableModel extends AbstractTableModel {
name = name + " (" + Chars.TIMES + count + ")";
}
return name;
} else {
MotorMount mount = this.flightConfigurationDialog.findMount(row);
Motor motor = mount.getMotor(id);
if (motor == null)
//// None
return "None";
String str = motor.getDesignation(mount.getMotorDelay(id));
int count = mount.getMotorCount();
if (count > 1) {
str = "" + count + Chars.TIMES + " " + str;
}
return str;
case 1:
{
MotorMount mount = this.flightConfigurationDialog.findMount(row);
Motor motor = mount.getMotor(id);
if (motor == null)
//// None
return "None";
String str = motor.getDesignation(mount.getMotorDelay(id));
int count = mount.getMotorCount();
if (count > 1) {
str = "" + count + Chars.TIMES + " " + str;
}
return str;
}
case 2:
{
MotorMount mount = this.flightConfigurationDialog.findMount(row);
Motor motor = mount.getMotor(id);
if (motor == null)
//// None
return "None";
IgnitionEvent ignition = mount.getIgnitionEvent();
return ignition.toString();
}
default:
return "";
}
}
@Override
public String getColumnName(int column) {
if (column == 0) {
switch (column ) {
case 0:
return "Motor Mount";
} else {
case 1:
return "Motor";
case 2:
return "Ignition";
default:
return "";
}
}
}

View File

@ -63,6 +63,8 @@ public class RenameConfigDialog extends JDialog {
panel.add( cancel );
this.setContentPane(panel);
this.validate();
this.pack();
}
}