diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties
index 492a90a83..175b90de8 100644
--- a/core/resources/l10n/messages.properties
+++ b/core/resources/l10n/messages.properties
@@ -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 = Motor mounts:
edtmotorconfdlg.title.Editmotorconf = Edit motor configurations
edtmotorconfdlg.selectcomp = Select which components function as motor mounts:
edtmotorconfdlg.lbl.Motorconfig = Motor configurations:
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:
diff --git a/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/FlightConfigurationDialog.java b/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/FlightConfigurationDialog.java
index 355705b21..5c879c240 100644
--- a/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/FlightConfigurationDialog.java
+++ b/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/FlightConfigurationDialog.java
@@ -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;
@@ -35,60 +36,59 @@ import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.startup.Application;
public class FlightConfigurationDialog extends JDialog {
-
+
final Rocket rocket;
-
+
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;
-
+
static final Translator trans = Application.getTranslator();
-
+
public FlightConfigurationDialog(final Rocket rocket, Window parent) {
//// Edit motor configurations
super(parent, trans.get("edtmotorconfdlg.title.Editmotorconf"));
-
+
currentID = rocket.getDefaultConfiguration().getMotorConfigurationID();
-
+
if (parent != null)
this.setModalityType(ModalityType.DOCUMENT_MODAL);
else
this.setModalityType(ModalityType.APPLICATION_MODAL);
-
+
this.rocket = rocket;
-
+
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);
-
+
panel.add(configSelector,"gapright para");
-
+
JButton newConfButton = new JButton(trans.get("edtmotorconfdlg.but.Newconfiguration"));
newConfButton.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FlightConfigurationDialog.this.addConfiguration();
}
-
+
});
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) {
@@ -96,7 +96,7 @@ public class FlightConfigurationDialog extends JDialog {
}
});
panel.add(renameConfButton);
-
+
//// Remove configuration
removeConfButton = new JButton(trans.get("edtmotorconfdlg.but.Removeconfiguration"));
removeConfButton.addActionListener(new ActionListener() {
@@ -105,87 +105,26 @@ public class FlightConfigurationDialog extends JDialog {
removeConfiguration();
}
});
- panel.add(removeConfButton,"wrap");
+ panel.add(removeConfButton);
- //// Motor mount selection
- //// Motor mounts:
- label = new JLabel(trans.get("edtmotorconfdlg.lbl.Motormounts"));
- panel.add(label, "gapbottom para");
-
- //// Motor selection
- //// Motor configurations:
- label = new JLabel(trans.get("edtmotorconfdlg.lbl.Motorconfig"));
- panel.add(label, "span 4, gapbottom para");
-
- //// 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");
-
- //// 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");
+ panel.add(copyConfButton,"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"));
@@ -196,16 +135,16 @@ public class FlightConfigurationDialog extends JDialog {
}
});
panel.add(close, "spanx, right");
-
+
this.add(panel);
this.validate();
this.pack();
-
+
updateButtonState();
-
+
this.setLocationByPlatform(true);
GUIUtil.setDisposableDialogOptions(this, close);
-
+
// Undo description
final OpenRocketDocument document = BasicFrame.findDocument(rocket);
if (document != null) {
@@ -219,8 +158,7 @@ public class FlightConfigurationDialog extends JDialog {
});
}
}
-
-
+
private MotorMount[] getPotentialMotorMounts() {
List list = new ArrayList();
for (RocketComponent c : rocket) {
@@ -237,7 +175,7 @@ public class FlightConfigurationDialog extends JDialog {
configurationTableModel.fireTableDataChanged();
updateButtonState();
}
-
+
public void addConfiguration() {
currentID = rocket.newMotorConfigurationID();
rocket.getDefaultConfiguration().setMotorConfigurationID(currentID);
@@ -245,13 +183,13 @@ public class FlightConfigurationDialog extends JDialog {
flightConfigurationModel.fireContentsUpdated();
updateButtonState();
}
-
+
public void changeConfigurationName( String newName ) {
rocket.setMotorConfigurationName(currentID, newName);
configurationTableModel.fireTableDataChanged();
flightConfigurationModel.fireContentsUpdated();
}
-
+
public void removeConfiguration() {
if (currentID == null)
return;
@@ -261,55 +199,53 @@ public class FlightConfigurationDialog extends JDialog {
flightConfigurationModel.fireContentsUpdated();
updateButtonState();
}
-
+
void updateButtonState() {
removeConfButton.setEnabled(currentID != null);
renameConfButton.setEnabled(currentID != null);
selectMotorButton.setEnabled(currentMount != null && currentID != null);
removeMotorButton.setEnabled(currentMount != null && currentID != null);
}
-
+
private void selectMotor() {
if (currentID == null || currentMount == null)
return;
-
+
MotorChooserDialog dialog = new MotorChooserDialog(currentMount.getMotor(currentID),
currentMount.getMotorDelay(currentID), currentMount.getMotorMountDiameter(), this);
dialog.setVisible(true);
Motor m = dialog.getSelectedMotor();
double d = dialog.getSelectedDelay();
-
+
if (m != null) {
currentMount.setMotor(currentID, m);
currentMount.setMotorDelay(currentID, d);
}
-
- int row = configurationTable.getSelectedRow();
- configurationTableModel.fireTableRowsUpdated(row, row);
+
+ configurationTableModel.fireTableDataChanged();
updateButtonState();
}
-
-
+
+
private void removeMotor() {
if (currentID == null || currentMount == null)
return;
-
+
currentMount.setMotor(currentID, null);
-
- int row = configurationTable.getSelectedRow();
- configurationTableModel.fireTableRowsUpdated(row, row);
+
+ configurationTableModel.fireTableDataChanged();
updateButtonState();
}
-
-
+
+
String findID(int row) {
return rocket.getMotorConfigurationIDs()[row + 1];
}
-
-
+
+
MotorMount findMount(int column) {
MotorMount mount = null;
-
+
int count = column;
for (MotorMount m : mounts) {
if (m.isMotorMount())
@@ -319,11 +255,108 @@ public class FlightConfigurationDialog extends JDialog {
break;
}
}
-
+
if (mount == null) {
throw new IndexOutOfBoundsException("motor mount not found, column=" + column);
}
return mount;
}
-
+
+ private JComponent makeMotorTab( ) {
+
+ JPanel panel = new JPanel(new MigLayout("fill"));
+
+ //// Motor mount selection
+ //// Motor mounts:
+ JLabel label = new JLabel(trans.get("edtmotorconfdlg.lbl.Motormounts"));
+ panel.add(label, "gapbottom para");
+
+ //// Motor selection
+ //// Motor configurations:
+ label = new JLabel(trans.get("edtmotorconfdlg.lbl.Motorconfig"));
+ panel.add(label, "gapbottom para, wrap");
+
+ //// 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;
+
+ }
+
}
diff --git a/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/MotorConfigurationTableModel.java b/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/MotorConfigurationTableModel.java
index 1f38d6093..ccfcf4e5e 100644
--- a/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/MotorConfigurationTableModel.java
+++ b/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/MotorConfigurationTableModel.java
@@ -4,32 +4,35 @@ 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;
/**
* The table model for selecting and editing the motor configurations.
*/
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;
}
-
+
@Override
public int getRowCount() {
int count = 0;
@@ -39,13 +42,15 @@ class MotorConfigurationTableModel extends AbstractTableModel {
}
return count;
}
-
+
@Override
public Object getValueAt(int row, int column) {
-
+
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 "";
}
-
}
-
+
}
\ No newline at end of file
diff --git a/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/RenameConfigDialog.java b/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/RenameConfigDialog.java
index 1d08652bf..0138ec836 100644
--- a/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/RenameConfigDialog.java
+++ b/core/src/net/sf/openrocket/gui/dialogs/flightconfiguration/RenameConfigDialog.java
@@ -63,6 +63,8 @@ public class RenameConfigDialog extends JDialog {
panel.add( cancel );
this.setContentPane(panel);
+ this.validate();
+ this.pack();
}
}