Added MassComponentType enum to allow categorizing mass components

This is only the data model. MassComponentType added as an Enum.  MassComponentConfig dialog updated to combobox to select.
This commit is contained in:
Craig Earls 2014-12-12 23:32:22 -07:00
parent 279420dd46
commit f7f3b737d4
3 changed files with 59 additions and 0 deletions

View File

@ -921,6 +921,7 @@ MassComponentCfg.tab.ttip.Radialpos = Radial position configuration
MassComponentCfg.lbl.Radialdistance = Radial distance:
MassComponentCfg.lbl.Radialdirection = Radial direction:
MassComponentCfg.but.Reset = Reset
MassComponentCfg.lbl.type = Object type
! MotorConfig
MotorCfg.checkbox.compmotormount = This component is a motor mount
@ -1328,6 +1329,12 @@ TrapezoidFinSet.TrapezoidFinSet = Trapezoidal fin set
FreeformFinSet.FreeformFinSet = Freeform fin set
!MassComponent
MassComponent.MassComponent = Mass component
MassComponent.Altimeter = Altimeter
MassComponent.FlightComputer = Flight computer
MassComponent.DeploymentCharge = Deployment charge
MassComponent.Tracker = Tracker
MassComponent.Payload = Payload
MassComponent.RecoveryHardware = Recovery hardware
! Parachute
Parachute.Parachute = Parachute
! ShockCord

View File

@ -15,6 +15,28 @@ public class MassComponent extends MassObject {
private double mass = 0;
public enum MassComponentType {
MASSCOMPONENT(Application.getTranslator().get("MassComponent.MassComponent")),
ALTIMETER(Application.getTranslator().get("MassComponent.Altimeter")),
FLIGHTCOMPUTER(Application.getTranslator().get("MassComponent.FlightComputer")),
DEPLOYMENTCHARGE(Application.getTranslator().get("MassComponent.DeploymentCharge")),
TRACKER(Application.getTranslator().get("MassComponent.Tracker")),
PAYLOAD(Application.getTranslator().get("MassComponent.Payload")),
RECOVERYHARDWARE(Application.getTranslator().get("MassComponent.RecoveryHardware"));
private String title;
MassComponentType(String title) {
this.title = title;
}
@Override
public String toString() {
return title;
}
}
private MassComponentType massComponentType = MassComponentType.MASSCOMPONENT;
public MassComponent() {
super();
@ -67,6 +89,21 @@ public class MassComponent extends MassObject {
return trans.get("MassComponent.MassComponent");
}
public final MassComponent.MassComponentType getMassComponentType() {
mutex.verify();
return this.massComponentType;
}
public void setMassComponentType(MassComponent.MassComponentType compType) {
mutex.verify();
if (this.massComponentType == compType) {
return;
}
checkState();
this.massComponentType = compType;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@Override
public boolean allowsChildren() {
return false;

View File

@ -32,7 +32,21 @@ public class MassComponentConfig extends RocketComponentConfig {
JPanel panel = new JPanel(new MigLayout("gap rel unrel", "[][65lp::][30lp::]", ""));
//// Mass component type
panel.add(new JLabel(trans.get("MassComponentCfg.lbl.type")));
@SuppressWarnings("unchecked")
JComboBox typecombo = new JComboBox(
new EnumModel<MassComponent.MassComponentType>(component, "MassComponentType",
new MassComponent.MassComponentType[] {
MassComponent.MassComponentType.MASSCOMPONENT,
MassComponent.MassComponentType.ALTIMETER,
MassComponent.MassComponentType.FLIGHTCOMPUTER,
MassComponent.MassComponentType.DEPLOYMENTCHARGE,
MassComponent.MassComponentType.TRACKER,
MassComponent.MassComponentType.PAYLOAD,
MassComponent.MassComponentType.RECOVERYHARDWARE}));
panel.add(typecombo, "spanx, growx, wrap");
//// Mass
panel.add(new JLabel(trans.get("MassComponentCfg.lbl.Mass")));
@ -116,6 +130,7 @@ public class MassComponentConfig extends RocketComponentConfig {
new DoubleModel(component.getParent(), "Length"))),
"w 100lp, wrap");
//// General and General properties
tabbedPane.insertTab(trans.get("MassComponentCfg.tab.General"), null, panel,
trans.get("MassComponentCfg.tab.ttip.General"), 0);