Merge pull request #1008 from SiboVG/issue-1001
[fixes #1001 + others] Change default tab + separation event when adding new stage
This commit is contained in:
commit
a2987cf8ba
@ -496,10 +496,24 @@ public class Rocket extends ComponentAssembly {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
|
updateStageNumbers();
|
||||||
updateStageMap();
|
updateStageMap();
|
||||||
updateConfigurations();
|
updateConfigurations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update all the stage numbers based on their position in the component tree
|
||||||
|
*/
|
||||||
|
private void updateStageNumbers() {
|
||||||
|
for (RocketComponent component : getChildren()) {
|
||||||
|
if (component instanceof AxialStage) {
|
||||||
|
AxialStage stage = (AxialStage) component;
|
||||||
|
forgetStage(stage);
|
||||||
|
stage.setStageNumber(getChildPosition(stage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateStageMap(){
|
private void updateStageMap(){
|
||||||
for( RocketComponent component : getChildren() ){
|
for( RocketComponent component : getChildren() ){
|
||||||
if (component instanceof AxialStage) {
|
if (component instanceof AxialStage) {
|
||||||
|
@ -96,7 +96,7 @@ public class StageSeparationConfiguration implements FlightConfigurableParameter
|
|||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
|
|
||||||
private SeparationEvent separationEvent = SeparationEvent.NEVER;
|
private SeparationEvent separationEvent = SeparationEvent.UPPER_IGNITION;
|
||||||
private double separationDelay = 0;
|
private double separationDelay = 0;
|
||||||
|
|
||||||
public SeparationEvent getSeparationEvent() {
|
public SeparationEvent getSeparationEvent() {
|
||||||
|
@ -31,7 +31,8 @@ public class AxialStageConfig extends ComponentAssemblyConfig {
|
|||||||
if (component.getStageNumber() > 0) {
|
if (component.getStageNumber() > 0) {
|
||||||
JPanel tab = separationTab((AxialStage) component);
|
JPanel tab = separationTab((AxialStage) component);
|
||||||
tabbedPane.insertTab(trans.get("StageConfig.tab.Separation"), null, tab,
|
tabbedPane.insertTab(trans.get("StageConfig.tab.Separation"), null, tab,
|
||||||
trans.get("StageConfig.tab.Separation.ttip"), 2);
|
trans.get("StageConfig.tab.Separation.ttip"), 0);
|
||||||
|
tabbedPane.setSelectedIndex(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,9 +29,12 @@ import net.sf.openrocket.gui.widgets.SelectColorButton;
|
|||||||
import net.sf.openrocket.motor.IgnitionEvent;
|
import net.sf.openrocket.motor.IgnitionEvent;
|
||||||
import net.sf.openrocket.motor.Motor;
|
import net.sf.openrocket.motor.Motor;
|
||||||
import net.sf.openrocket.motor.MotorConfiguration;
|
import net.sf.openrocket.motor.MotorConfiguration;
|
||||||
|
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||||
|
import net.sf.openrocket.rocketcomponent.BodyTube;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||||
|
import net.sf.openrocket.rocketcomponent.InnerTube;
|
||||||
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.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
@ -139,6 +142,15 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
|||||||
protected boolean includeComponent(MotorMount component) {
|
protected boolean includeComponent(MotorMount component) {
|
||||||
return component.isMotorMount();
|
return component.isMotorMount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentChanged(ComponentChangeEvent cce) {
|
||||||
|
super.componentChanged(cce);
|
||||||
|
// This will catch a name change to cause a change in the header of the table
|
||||||
|
if ((cce.getSource() instanceof BodyTube || cce.getSource() instanceof InnerTube) && cce.isNonFunctionalChange()) {
|
||||||
|
fireTableStructureChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Listen to changes to the table so we can disable the help text when a
|
// Listen to changes to the table so we can disable the help text when a
|
||||||
|
@ -76,6 +76,14 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel<AxialS
|
|||||||
return component.getStageNumber() > 0;
|
return component.getStageNumber() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentChanged(ComponentChangeEvent cce) {
|
||||||
|
super.componentChanged(cce);
|
||||||
|
// This will catch a name change of the stage to cause a change in the header of the table
|
||||||
|
if (cce.getSource() instanceof AxialStage && cce.isNonFunctionalChange()) {
|
||||||
|
fireTableStructureChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
JTable separationTable = new JTable(separationTableModel);
|
JTable separationTable = new JTable(separationTableModel);
|
||||||
separationTable.getTableHeader().setReorderingAllowed(false);
|
separationTable.getTableHeader().setReorderingAllowed(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user