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:
parent
25c5dfec49
commit
d00dc2ff34
@ -175,15 +175,17 @@ MotorChooserDialog.title = Select a rocket motor
|
|||||||
! Edit Motor configuration dialog
|
! Edit Motor configuration dialog
|
||||||
edtmotorconfdlg.but.removemotor = Remove motor
|
edtmotorconfdlg.but.removemotor = Remove motor
|
||||||
edtmotorconfdlg.but.Selectmotor = Select motor
|
edtmotorconfdlg.but.Selectmotor = Select motor
|
||||||
edtmotorconfdlg.but.Removeconfiguration = Remove configuration
|
edtmotorconfdlg.but.Removeconfiguration = Remove
|
||||||
edtmotorconfdlg.but.Newconfiguration = New configuration
|
edtmotorconfdlg.but.Renameconfiguration = Rename
|
||||||
|
edtmotorconfdlg.but.Newconfiguration = New
|
||||||
|
edtmotorconfdlg.but.Copyconfiguration = Copy
|
||||||
edtmotorconfdlg.lbl.Motormounts = <html><b>Motor mounts:</b>
|
edtmotorconfdlg.lbl.Motormounts = <html><b>Motor mounts:</b>
|
||||||
edtmotorconfdlg.title.Editmotorconf = Edit motor configurations
|
edtmotorconfdlg.title.Editmotorconf = Edit motor configurations
|
||||||
edtmotorconfdlg.selectcomp = <html>Select which components function as motor mounts:
|
edtmotorconfdlg.selectcomp = <html>Select which components function as motor mounts:
|
||||||
edtmotorconfdlg.lbl.Motorconfig = <html><b>Motor configurations:</b>
|
edtmotorconfdlg.lbl.Motorconfig = <html><b>Motor configurations:</b>
|
||||||
edtmotorconfdlg.lbl.Configname = Configuration name:
|
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
|
! Example design dialog
|
||||||
exdesigndlg.but.open = Open
|
exdesigndlg.but.open = Open
|
||||||
exdesigndlg.lbl.Selectexample = Select example designs to open:
|
exdesigndlg.lbl.Selectexample = Select example designs to open:
|
||||||
|
@ -12,13 +12,14 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
import javax.swing.event.ListDataEvent;
|
|
||||||
import javax.swing.table.TableColumn;
|
import javax.swing.table.TableColumn;
|
||||||
import javax.swing.table.TableColumnModel;
|
import javax.swing.table.TableColumnModel;
|
||||||
|
|
||||||
@ -40,12 +41,11 @@ public class FlightConfigurationDialog extends JDialog {
|
|||||||
|
|
||||||
final MotorMount[] mounts;
|
final MotorMount[] mounts;
|
||||||
|
|
||||||
private final JTable configurationTable;
|
MotorConfigurationTableModel configurationTableModel;
|
||||||
final MotorConfigurationTableModel configurationTableModel;
|
FlightConfigurationModel flightConfigurationModel;
|
||||||
final FlightConfigurationModel flightConfigurationModel;
|
|
||||||
|
|
||||||
private final JButton renameConfButton, removeConfButton;
|
private final JButton renameConfButton, removeConfButton, copyConfButton;
|
||||||
private final JButton selectMotorButton, removeMotorButton;
|
private JButton selectMotorButton, removeMotorButton;
|
||||||
|
|
||||||
String currentID = null;
|
String currentID = null;
|
||||||
private MotorMount currentMount = null;
|
private MotorMount currentMount = null;
|
||||||
@ -67,10 +67,10 @@ public class FlightConfigurationDialog extends JDialog {
|
|||||||
|
|
||||||
mounts = getPotentialMotorMounts();
|
mounts = getPotentialMotorMounts();
|
||||||
|
|
||||||
JPanel panel = new JPanel(new MigLayout("fill, wrap 5"));
|
JPanel panel = new JPanel(new MigLayout("fill"));
|
||||||
|
|
||||||
JLabel label = new JLabel("Selected Configuration: ");
|
JLabel label = new JLabel("Selected Configuration: ");
|
||||||
panel.add(label,"gapbottom para");
|
panel.add(label);
|
||||||
|
|
||||||
flightConfigurationModel = new FlightConfigurationModel(rocket.getDefaultConfiguration());
|
flightConfigurationModel = new FlightConfigurationModel(rocket.getDefaultConfiguration());
|
||||||
JComboBox configSelector = new JComboBox(flightConfigurationModel);
|
JComboBox configSelector = new JComboBox(flightConfigurationModel);
|
||||||
@ -88,7 +88,7 @@ public class FlightConfigurationDialog extends JDialog {
|
|||||||
|
|
||||||
panel.add(newConfButton);
|
panel.add(newConfButton);
|
||||||
|
|
||||||
renameConfButton = new JButton("Rename Configuration");
|
renameConfButton = new JButton(trans.get("edtmotorconfdlg.but.Renameconfiguration"));
|
||||||
renameConfButton.addActionListener( new ActionListener() {
|
renameConfButton.addActionListener( new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
@ -105,87 +105,26 @@ public class FlightConfigurationDialog extends JDialog {
|
|||||||
removeConfiguration();
|
removeConfiguration();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
panel.add(removeConfButton,"wrap");
|
panel.add(removeConfButton);
|
||||||
|
|
||||||
//// Motor mount selection
|
//// Copy configuration
|
||||||
//// <html><b>Motor mounts:</b>
|
copyConfButton = new JButton(trans.get("edtmotorconfdlg.but.Copyconfiguration"));
|
||||||
label = new JLabel(trans.get("edtmotorconfdlg.lbl.Motormounts"));
|
copyConfButton.addActionListener(new ActionListener() {
|
||||||
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() {
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
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"));
|
//// Tabs for advanced view.
|
||||||
removeMotorButton.addActionListener(new ActionListener() {
|
JTabbedPane tabs = new JTabbedPane();
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
//// Motor tabs
|
||||||
removeMotor();
|
JComponent motorTab = makeMotorTab();
|
||||||
}
|
tabs.add(trans.get("edtmotorconfdlg.lbl.Motortab"), motorTab);
|
||||||
});
|
panel.add( tabs, "spanx, w 700lp, h 500lp, wrap");
|
||||||
panel.add(removeMotorButton,"sizegroup button, wrap");
|
|
||||||
|
|
||||||
//// Close button
|
//// Close button
|
||||||
JButton close = new JButton(trans.get("dlg.but.close"));
|
JButton close = new JButton(trans.get("dlg.but.close"));
|
||||||
@ -220,7 +159,6 @@ public class FlightConfigurationDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private MotorMount[] getPotentialMotorMounts() {
|
private MotorMount[] getPotentialMotorMounts() {
|
||||||
List<MotorMount> list = new ArrayList<MotorMount>();
|
List<MotorMount> list = new ArrayList<MotorMount>();
|
||||||
for (RocketComponent c : rocket) {
|
for (RocketComponent c : rocket) {
|
||||||
@ -284,8 +222,7 @@ public class FlightConfigurationDialog extends JDialog {
|
|||||||
currentMount.setMotorDelay(currentID, d);
|
currentMount.setMotorDelay(currentID, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
int row = configurationTable.getSelectedRow();
|
configurationTableModel.fireTableDataChanged();
|
||||||
configurationTableModel.fireTableRowsUpdated(row, row);
|
|
||||||
updateButtonState();
|
updateButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,8 +233,7 @@ public class FlightConfigurationDialog extends JDialog {
|
|||||||
|
|
||||||
currentMount.setMotor(currentID, null);
|
currentMount.setMotor(currentID, null);
|
||||||
|
|
||||||
int row = configurationTable.getSelectedRow();
|
configurationTableModel.fireTableDataChanged();
|
||||||
configurationTableModel.fireTableRowsUpdated(row, row);
|
|
||||||
updateButtonState();
|
updateButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,4 +262,101 @@ public class FlightConfigurationDialog extends JDialog {
|
|||||||
return mount;
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import javax.swing.table.AbstractTableModel;
|
|||||||
|
|
||||||
import net.sf.openrocket.motor.Motor;
|
import net.sf.openrocket.motor.Motor;
|
||||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||||
|
import net.sf.openrocket.rocketcomponent.MotorMount.IgnitionEvent;
|
||||||
import net.sf.openrocket.util.Chars;
|
import net.sf.openrocket.util.Chars;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,17 +17,19 @@ class MotorConfigurationTableModel extends AbstractTableModel {
|
|||||||
*/
|
*/
|
||||||
private final FlightConfigurationDialog flightConfigurationDialog;
|
private final FlightConfigurationDialog flightConfigurationDialog;
|
||||||
|
|
||||||
|
private final boolean advanced;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param flightConfigurationDialog
|
* @param flightConfigurationDialog
|
||||||
*/
|
*/
|
||||||
MotorConfigurationTableModel( FlightConfigurationDialog flightConfigurationDialog) {
|
MotorConfigurationTableModel( FlightConfigurationDialog flightConfigurationDialog, boolean advanced) {
|
||||||
this.flightConfigurationDialog = flightConfigurationDialog;
|
this.flightConfigurationDialog = flightConfigurationDialog;
|
||||||
|
this.advanced = advanced;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnCount() {
|
public int getColumnCount() {
|
||||||
int count = 2;
|
int count = (advanced)? 3: 2;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +48,9 @@ class MotorConfigurationTableModel extends AbstractTableModel {
|
|||||||
|
|
||||||
String id = this.flightConfigurationDialog.currentID;
|
String id = this.flightConfigurationDialog.currentID;
|
||||||
|
|
||||||
if (column == 0) {
|
switch( column ) {
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
MotorMount mount = this.flightConfigurationDialog.findMount(row);
|
MotorMount mount = this.flightConfigurationDialog.findMount(row);
|
||||||
String name = mount.toString();
|
String name = mount.toString();
|
||||||
int count = mount.getMotorCount();
|
int count = mount.getMotorCount();
|
||||||
@ -53,31 +58,50 @@ class MotorConfigurationTableModel extends AbstractTableModel {
|
|||||||
name = name + " (" + Chars.TIMES + count + ")";
|
name = name + " (" + Chars.TIMES + count + ")";
|
||||||
}
|
}
|
||||||
return name;
|
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
|
@Override
|
||||||
public String getColumnName(int column) {
|
public String getColumnName(int column) {
|
||||||
if (column == 0) {
|
switch (column ) {
|
||||||
|
case 0:
|
||||||
return "Motor Mount";
|
return "Motor Mount";
|
||||||
} else {
|
case 1:
|
||||||
return "Motor";
|
return "Motor";
|
||||||
|
case 2:
|
||||||
|
return "Ignition";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -63,6 +63,8 @@ public class RenameConfigDialog extends JDialog {
|
|||||||
panel.add( cancel );
|
panel.add( cancel );
|
||||||
|
|
||||||
this.setContentPane(panel);
|
this.setContentPane(panel);
|
||||||
|
this.validate();
|
||||||
|
this.pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user