diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index b1719fd2f..4b1c2b4b8 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -64,6 +64,8 @@ RocketPanel.lbl.Stability = Stability: RocketPanel.checkbox.ShowCGCP = Show CG/CP RocketPanel.checkbox.ShowCGCP.ttip = Disabling this checkbox hides the CG and CP markings in the rocket view. RocketPanel.lbl.Stages = Stages: +RocketPanel.btn.Stages.Toggle.ttip = Toggle this button to activate or deactivate the corresponding stage in your design. +RocketPanel.btn.Stages.NoChildren.ttip = This stages does not have any child components and is therefore marked as inactive.
Add components to the stage to activate it. RocketPanel.ttip.Rotation = Change the rocket's roll rotation (only affects the rocket view) ! BasicFrame diff --git a/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java b/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java index 8e0f533c5..ff8d9820b 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java +++ b/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java @@ -1,8 +1,5 @@ package net.sf.openrocket.rocketcomponent; -import java.util.ArrayList; -import java.util.Collection; - import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.rocketcomponent.position.AxialMethod; import net.sf.openrocket.startup.Application; diff --git a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java index 72fdacac1..effe1da8c 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java @@ -241,8 +241,10 @@ public class FlightConfiguration implements FlightConfigurableParameter 0 && + stages.get(stageNumber) != null && stages.get(stageNumber).active; } public Collection getAllComponents() { @@ -379,12 +381,8 @@ public class FlightConfiguration implements FlightConfigurableParameter activeStages = new ArrayList<>(); for (StageFlags flags : this.stages.values()) { - if (flags.active) { - AxialStage stage = rocket.getStage(flags.stageNumber); - if (stage == null) { - continue; - } - activeStages.add(stage); + if (isStageActive(flags.stageNumber)) { + activeStages.add( rocket.getStage(flags.stageNumber)); } } @@ -392,13 +390,7 @@ public class FlightConfiguration implements FlightConfigurableParameter buttons = new ArrayList(); @@ -61,9 +64,16 @@ public class StageSelector extends JPanel implements StateChangeListener { private class StageAction extends AbstractAction { private final AxialStage stage; - + public StageAction(final AxialStage stage) { this.stage = stage; + if (this.stage.getChildCount() == 0) { + putValue(SHORT_DESCRIPTION, trans.get("RocketPanel.btn.Stages.NoChildren.ttip")); + setEnabled(false); + } else { + putValue(SHORT_DESCRIPTION, trans.get("RocketPanel.btn.Stages.Toggle.ttip")); + } + updateUI(); } @Override @@ -77,6 +87,15 @@ public class StageSelector extends JPanel implements StateChangeListener { @Override public void actionPerformed(ActionEvent e) { + // Don't toggle the state if the stage has no children (and is therefore inactive) + if (stage.getChildCount() == 0) { + putValue(SHORT_DESCRIPTION, trans.get("RocketPanel.btn.Stages.NoChildren.ttip")); + setEnabled(false); + return; + } else { + setEnabled(true); + putValue(SHORT_DESCRIPTION, trans.get("RocketPanel.btn.Stages.Toggle.ttip")); + } rocket.getSelectedConfiguration().toggleStage(stage.getStageNumber()); rocket.fireComponentChangeEvent(ComponentChangeEvent.AEROMASS_CHANGE | ComponentChangeEvent.MOTOR_CHANGE ); }