Added some l10n strings to the motor table. Tightened up access to
package scope member variables.
This commit is contained in:
parent
d00dc2ff34
commit
e18b081273
@ -185,7 +185,11 @@ edtmotorconfdlg.selectcomp = <html>Select which components function as motor mou
|
||||
edtmotorconfdlg.lbl.Motorconfig = <html><b>Motor configurations:</b>
|
||||
edtmotorconfdlg.lbl.Configname = Configuration name:
|
||||
edtmotorconfdlg.lbl.Motortab = Motors
|
||||
edtmotorconfdlg.lbl.Advancemode = Advanced mode
|
||||
edtmotorconfdlg.tbl.None = None
|
||||
edtmotorconfdlg.tbl.Motorheader = Motor
|
||||
edtmotorconfdlg.tbl.Mountheader = Motor Mount
|
||||
edtmotorconfdlg.tbl.Ignitionheader = Ignition
|
||||
|
||||
! Example design dialog
|
||||
exdesigndlg.but.open = Open
|
||||
exdesigndlg.lbl.Selectexample = Select example designs to open:
|
||||
|
@ -33,21 +33,23 @@ import net.sf.openrocket.motor.Motor;
|
||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.MotorMount.IgnitionEvent;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.Chars;
|
||||
|
||||
public class FlightConfigurationDialog extends JDialog {
|
||||
|
||||
final Rocket rocket;
|
||||
private final Rocket rocket;
|
||||
|
||||
final MotorMount[] mounts;
|
||||
|
||||
MotorConfigurationTableModel configurationTableModel;
|
||||
FlightConfigurationModel flightConfigurationModel;
|
||||
private MotorConfigurationTableModel configurationTableModel;
|
||||
private FlightConfigurationModel flightConfigurationModel;
|
||||
|
||||
private final JButton renameConfButton, removeConfButton, copyConfButton;
|
||||
private JButton selectMotorButton, removeMotorButton;
|
||||
|
||||
String currentID = null;
|
||||
private String currentID = null;
|
||||
private MotorMount currentMount = null;
|
||||
|
||||
static final Translator trans = Application.getTranslator();
|
||||
@ -72,7 +74,7 @@ public class FlightConfigurationDialog extends JDialog {
|
||||
JLabel label = new JLabel("Selected Configuration: ");
|
||||
panel.add(label);
|
||||
|
||||
flightConfigurationModel = new FlightConfigurationModel(rocket.getDefaultConfiguration());
|
||||
flightConfigurationModel = new FlightConfigurationModel(this, rocket.getDefaultConfiguration());
|
||||
JComboBox configSelector = new JComboBox(flightConfigurationModel);
|
||||
|
||||
panel.add(configSelector,"gapright para");
|
||||
@ -200,7 +202,7 @@ public class FlightConfigurationDialog extends JDialog {
|
||||
updateButtonState();
|
||||
}
|
||||
|
||||
void updateButtonState() {
|
||||
private void updateButtonState() {
|
||||
removeConfButton.setEnabled(currentID != null);
|
||||
renameConfButton.setEnabled(currentID != null);
|
||||
selectMotorButton.setEnabled(currentMount != null && currentID != null);
|
||||
@ -237,12 +239,12 @@ public class FlightConfigurationDialog extends JDialog {
|
||||
updateButtonState();
|
||||
}
|
||||
|
||||
|
||||
String findID(int row) {
|
||||
return rocket.getMotorConfigurationIDs()[row + 1];
|
||||
void makeMotorMount( MotorMount mount, boolean isMotorMount ) {
|
||||
mount.setMotorMount( isMotorMount );
|
||||
configurationTableModel.fireTableStructureChanged();
|
||||
updateButtonState();
|
||||
}
|
||||
|
||||
|
||||
|
||||
MotorMount findMount(int column) {
|
||||
MotorMount mount = null;
|
||||
|
||||
@ -262,6 +264,32 @@ public class FlightConfigurationDialog extends JDialog {
|
||||
return mount;
|
||||
}
|
||||
|
||||
String findMotorForDisplay( int column ) {
|
||||
String id = currentID;
|
||||
MotorMount mount = findMount(column);
|
||||
Motor motor = mount.getMotor(id);
|
||||
if (motor == null)
|
||||
return null;
|
||||
|
||||
String str = motor.getDesignation(mount.getMotorDelay(id));
|
||||
int count = mount.getMotorCount();
|
||||
if (count > 1) {
|
||||
str = "" + count + Chars.TIMES + " " + str;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
String findIgnitionForDisplay( int column ) {
|
||||
String id = currentID;
|
||||
MotorMount mount = findMount(column);
|
||||
Motor motor = mount.getMotor(id);
|
||||
if (motor == null)
|
||||
//// None
|
||||
return null;
|
||||
IgnitionEvent ignition = mount.getIgnitionEvent();
|
||||
return ignition.toString();
|
||||
}
|
||||
|
||||
private JComponent makeMotorTab( ) {
|
||||
|
||||
JPanel panel = new JPanel(new MigLayout("fill"));
|
||||
|
@ -15,7 +15,10 @@ public class FlightConfigurationModel extends DefaultComboBoxModel {
|
||||
|
||||
private Map<String, ID> map = new HashMap<String, ID>();
|
||||
|
||||
public FlightConfigurationModel(Configuration config) {
|
||||
private final FlightConfigurationDialog flightConfigurationDialog;
|
||||
|
||||
public FlightConfigurationModel(FlightConfigurationDialog flightConfigurationDialog, Configuration config) {
|
||||
this.flightConfigurationDialog = flightConfigurationDialog;
|
||||
this.config = config;
|
||||
this.rocket = config.getRocket();
|
||||
}
|
||||
@ -54,7 +57,7 @@ public class FlightConfigurationModel extends DefaultComboBoxModel {
|
||||
}
|
||||
|
||||
ID idObject = (ID) item;
|
||||
config.setMotorConfigurationID(idObject.getID());
|
||||
flightConfigurationDialog.selectConfiguration(idObject.getID());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2,9 +2,7 @@ package net.sf.openrocket.gui.dialogs.flightconfiguration;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -12,6 +10,11 @@ import net.sf.openrocket.util.Chars;
|
||||
*/
|
||||
class MotorConfigurationTableModel extends AbstractTableModel {
|
||||
|
||||
private final static String NONE = FlightConfigurationDialog.trans.get("edtmotorconfdlg.tbl.None");
|
||||
private final static String MOTOR_MOUNT = FlightConfigurationDialog.trans.get("edtmotorconfdlg.tbl.Mountheader");
|
||||
private final static String MOTOR = FlightConfigurationDialog.trans.get("edtmotorconfdlg.tbl.Motorheader");
|
||||
private final static String IGNITION = FlightConfigurationDialog.trans.get("edtmotorconfdlg.tbl.Ignitionheader");
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -46,8 +49,6 @@ class MotorConfigurationTableModel extends AbstractTableModel {
|
||||
@Override
|
||||
public Object getValueAt(int row, int column) {
|
||||
|
||||
String id = this.flightConfigurationDialog.currentID;
|
||||
|
||||
switch( column ) {
|
||||
case 0:
|
||||
{
|
||||
@ -61,28 +62,21 @@ class MotorConfigurationTableModel extends AbstractTableModel {
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
MotorMount mount = this.flightConfigurationDialog.findMount(row);
|
||||
Motor motor = mount.getMotor(id);
|
||||
if (motor == null)
|
||||
String str = this.flightConfigurationDialog.findMotorForDisplay(row);
|
||||
if (str == null)
|
||||
//// None
|
||||
return "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)
|
||||
String str = this.flightConfigurationDialog.findIgnitionForDisplay(row);
|
||||
if (str == null)
|
||||
//// None
|
||||
return "None";
|
||||
IgnitionEvent ignition = mount.getIgnitionEvent();
|
||||
return ignition.toString();
|
||||
return NONE;
|
||||
|
||||
return str;
|
||||
}
|
||||
default:
|
||||
return "";
|
||||
@ -94,11 +88,11 @@ class MotorConfigurationTableModel extends AbstractTableModel {
|
||||
public String getColumnName(int column) {
|
||||
switch (column ) {
|
||||
case 0:
|
||||
return "Motor Mount";
|
||||
return MOTOR_MOUNT;
|
||||
case 1:
|
||||
return "Motor";
|
||||
return MOTOR;
|
||||
case 2:
|
||||
return "Ignition";
|
||||
return IGNITION;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
@ -68,8 +68,6 @@ class MotorMountTableModel extends AbstractTableModel {
|
||||
throw new IllegalArgumentException("column=" + column + ", value=" + value);
|
||||
}
|
||||
|
||||
this.flightConfigurationDialog.mounts[row].setMotorMount((Boolean) value);
|
||||
this.flightConfigurationDialog.configurationTableModel.fireTableStructureChanged();
|
||||
this.flightConfigurationDialog.updateButtonState();
|
||||
this.flightConfigurationDialog.makeMotorMount( this.flightConfigurationDialog.mounts[row], (Boolean) value);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user