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.Motorconfig = <html><b>Motor configurations:</b>
|
||||||
edtmotorconfdlg.lbl.Configname = Configuration name:
|
edtmotorconfdlg.lbl.Configname = Configuration name:
|
||||||
edtmotorconfdlg.lbl.Motortab = Motors
|
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
|
! 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:
|
||||||
|
@ -33,21 +33,23 @@ import net.sf.openrocket.motor.Motor;
|
|||||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
|
import net.sf.openrocket.rocketcomponent.MotorMount.IgnitionEvent;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
|
import net.sf.openrocket.util.Chars;
|
||||||
|
|
||||||
public class FlightConfigurationDialog extends JDialog {
|
public class FlightConfigurationDialog extends JDialog {
|
||||||
|
|
||||||
final Rocket rocket;
|
private final Rocket rocket;
|
||||||
|
|
||||||
final MotorMount[] mounts;
|
final MotorMount[] mounts;
|
||||||
|
|
||||||
MotorConfigurationTableModel configurationTableModel;
|
private MotorConfigurationTableModel configurationTableModel;
|
||||||
FlightConfigurationModel flightConfigurationModel;
|
private FlightConfigurationModel flightConfigurationModel;
|
||||||
|
|
||||||
private final JButton renameConfButton, removeConfButton, copyConfButton;
|
private final JButton renameConfButton, removeConfButton, copyConfButton;
|
||||||
private JButton selectMotorButton, removeMotorButton;
|
private JButton selectMotorButton, removeMotorButton;
|
||||||
|
|
||||||
String currentID = null;
|
private String currentID = null;
|
||||||
private MotorMount currentMount = null;
|
private MotorMount currentMount = null;
|
||||||
|
|
||||||
static final Translator trans = Application.getTranslator();
|
static final Translator trans = Application.getTranslator();
|
||||||
@ -72,7 +74,7 @@ public class FlightConfigurationDialog extends JDialog {
|
|||||||
JLabel label = new JLabel("Selected Configuration: ");
|
JLabel label = new JLabel("Selected Configuration: ");
|
||||||
panel.add(label);
|
panel.add(label);
|
||||||
|
|
||||||
flightConfigurationModel = new FlightConfigurationModel(rocket.getDefaultConfiguration());
|
flightConfigurationModel = new FlightConfigurationModel(this, rocket.getDefaultConfiguration());
|
||||||
JComboBox configSelector = new JComboBox(flightConfigurationModel);
|
JComboBox configSelector = new JComboBox(flightConfigurationModel);
|
||||||
|
|
||||||
panel.add(configSelector,"gapright para");
|
panel.add(configSelector,"gapright para");
|
||||||
@ -200,7 +202,7 @@ public class FlightConfigurationDialog extends JDialog {
|
|||||||
updateButtonState();
|
updateButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateButtonState() {
|
private void updateButtonState() {
|
||||||
removeConfButton.setEnabled(currentID != null);
|
removeConfButton.setEnabled(currentID != null);
|
||||||
renameConfButton.setEnabled(currentID != null);
|
renameConfButton.setEnabled(currentID != null);
|
||||||
selectMotorButton.setEnabled(currentMount != null && currentID != null);
|
selectMotorButton.setEnabled(currentMount != null && currentID != null);
|
||||||
@ -237,12 +239,12 @@ public class FlightConfigurationDialog extends JDialog {
|
|||||||
updateButtonState();
|
updateButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void makeMotorMount( MotorMount mount, boolean isMotorMount ) {
|
||||||
String findID(int row) {
|
mount.setMotorMount( isMotorMount );
|
||||||
return rocket.getMotorConfigurationIDs()[row + 1];
|
configurationTableModel.fireTableStructureChanged();
|
||||||
|
updateButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MotorMount findMount(int column) {
|
MotorMount findMount(int column) {
|
||||||
MotorMount mount = null;
|
MotorMount mount = null;
|
||||||
|
|
||||||
@ -262,6 +264,32 @@ public class FlightConfigurationDialog extends JDialog {
|
|||||||
return mount;
|
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( ) {
|
private JComponent makeMotorTab( ) {
|
||||||
|
|
||||||
JPanel panel = new JPanel(new MigLayout("fill"));
|
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>();
|
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.config = config;
|
||||||
this.rocket = config.getRocket();
|
this.rocket = config.getRocket();
|
||||||
}
|
}
|
||||||
@ -54,7 +57,7 @@ public class FlightConfigurationModel extends DefaultComboBoxModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ID idObject = (ID) item;
|
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 javax.swing.table.AbstractTableModel;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,6 +10,11 @@ import net.sf.openrocket.util.Chars;
|
|||||||
*/
|
*/
|
||||||
class MotorConfigurationTableModel extends AbstractTableModel {
|
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
|
@Override
|
||||||
public Object getValueAt(int row, int column) {
|
public Object getValueAt(int row, int column) {
|
||||||
|
|
||||||
String id = this.flightConfigurationDialog.currentID;
|
|
||||||
|
|
||||||
switch( column ) {
|
switch( column ) {
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
@ -61,28 +62,21 @@ class MotorConfigurationTableModel extends AbstractTableModel {
|
|||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
MotorMount mount = this.flightConfigurationDialog.findMount(row);
|
String str = this.flightConfigurationDialog.findMotorForDisplay(row);
|
||||||
Motor motor = mount.getMotor(id);
|
if (str == null)
|
||||||
if (motor == null)
|
|
||||||
//// None
|
//// 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;
|
return str;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
MotorMount mount = this.flightConfigurationDialog.findMount(row);
|
String str = this.flightConfigurationDialog.findIgnitionForDisplay(row);
|
||||||
Motor motor = mount.getMotor(id);
|
if (str == null)
|
||||||
if (motor == null)
|
|
||||||
//// None
|
//// None
|
||||||
return "None";
|
return NONE;
|
||||||
IgnitionEvent ignition = mount.getIgnitionEvent();
|
|
||||||
return ignition.toString();
|
return str;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
@ -94,11 +88,11 @@ class MotorConfigurationTableModel extends AbstractTableModel {
|
|||||||
public String getColumnName(int column) {
|
public String getColumnName(int column) {
|
||||||
switch (column ) {
|
switch (column ) {
|
||||||
case 0:
|
case 0:
|
||||||
return "Motor Mount";
|
return MOTOR_MOUNT;
|
||||||
case 1:
|
case 1:
|
||||||
return "Motor";
|
return MOTOR;
|
||||||
case 2:
|
case 2:
|
||||||
return "Ignition";
|
return IGNITION;
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,6 @@ class MotorMountTableModel extends AbstractTableModel {
|
|||||||
throw new IllegalArgumentException("column=" + column + ", value=" + value);
|
throw new IllegalArgumentException("column=" + column + ", value=" + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.flightConfigurationDialog.mounts[row].setMotorMount((Boolean) value);
|
this.flightConfigurationDialog.makeMotorMount( this.flightConfigurationDialog.mounts[row], (Boolean) value);
|
||||||
this.flightConfigurationDialog.configurationTableModel.fireTableStructureChanged();
|
|
||||||
this.flightConfigurationDialog.updateButtonState();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user