Add traversal policy for rail button config

This commit is contained in:
Remington Holder 2022-08-15 15:30:08 -04:00
parent 430b448db3
commit 6198eaa8fd
2 changed files with 16 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import javax.swing.JSpinner;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.document.OpenRocketDocument; import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.gui.SpinnerEditor; import net.sf.openrocket.gui.SpinnerEditor;
import net.sf.openrocket.gui.adaptors.CustomFocusTraversalPolicy;
import net.sf.openrocket.gui.adaptors.DoubleModel; import net.sf.openrocket.gui.adaptors.DoubleModel;
import net.sf.openrocket.gui.adaptors.EnumModel; import net.sf.openrocket.gui.adaptors.EnumModel;
import net.sf.openrocket.gui.components.BasicSlider; import net.sf.openrocket.gui.components.BasicSlider;
@ -48,6 +49,7 @@ public class RailButtonConfig extends RocketComponentConfig {
JSpinner ODSpinner = new JSpinner( ODModel.getSpinnerModel()); JSpinner ODSpinner = new JSpinner( ODModel.getSpinnerModel());
ODSpinner.setEditor(new SpinnerEditor(ODSpinner)); ODSpinner.setEditor(new SpinnerEditor(ODSpinner));
panel.add(ODSpinner, "growx"); panel.add(ODSpinner, "growx");
order.add(((SpinnerEditor) ODSpinner.getEditor()).getTextField());
panel.add(new UnitSelector(ODModel), "growx"); panel.add(new UnitSelector(ODModel), "growx");
panel.add(new BasicSlider(ODModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap"); panel.add(new BasicSlider(ODModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap");
} }
@ -57,6 +59,7 @@ public class RailButtonConfig extends RocketComponentConfig {
JSpinner IDSpinner = new JSpinner(IDModel.getSpinnerModel()); JSpinner IDSpinner = new JSpinner(IDModel.getSpinnerModel());
IDSpinner.setEditor(new SpinnerEditor(IDSpinner)); IDSpinner.setEditor(new SpinnerEditor(IDSpinner));
panel.add(IDSpinner, "growx"); panel.add(IDSpinner, "growx");
order.add(((SpinnerEditor) IDSpinner.getEditor()).getTextField());
panel.add(new UnitSelector(IDModel), "growx"); panel.add(new UnitSelector(IDModel), "growx");
panel.add(new BasicSlider(IDModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap para"); panel.add(new BasicSlider(IDModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap para");
} }
@ -66,6 +69,7 @@ public class RailButtonConfig extends RocketComponentConfig {
JSpinner heightSpinner = new JSpinner(heightModel.getSpinnerModel()); JSpinner heightSpinner = new JSpinner(heightModel.getSpinnerModel());
heightSpinner.setEditor(new SpinnerEditor(heightSpinner)); heightSpinner.setEditor(new SpinnerEditor(heightSpinner));
panel.add(heightSpinner, "growx"); panel.add(heightSpinner, "growx");
order.add(((SpinnerEditor) heightSpinner.getEditor()).getTextField());
panel.add(new UnitSelector(heightModel), "growx"); panel.add(new UnitSelector(heightModel), "growx");
panel.add(new BasicSlider(heightModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap"); panel.add(new BasicSlider(heightModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap");
} }
@ -75,6 +79,7 @@ public class RailButtonConfig extends RocketComponentConfig {
JSpinner heightSpinner = new JSpinner(heightModel.getSpinnerModel()); JSpinner heightSpinner = new JSpinner(heightModel.getSpinnerModel());
heightSpinner.setEditor(new SpinnerEditor(heightSpinner)); heightSpinner.setEditor(new SpinnerEditor(heightSpinner));
panel.add(heightSpinner, "growx"); panel.add(heightSpinner, "growx");
order.add(((SpinnerEditor) heightSpinner.getEditor()).getTextField());
panel.add(new UnitSelector(heightModel), "growx"); panel.add(new UnitSelector(heightModel), "growx");
panel.add(new BasicSlider(heightModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap"); panel.add(new BasicSlider(heightModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap");
} }
@ -84,6 +89,7 @@ public class RailButtonConfig extends RocketComponentConfig {
JSpinner heightSpinner = new JSpinner(heightModel.getSpinnerModel()); JSpinner heightSpinner = new JSpinner(heightModel.getSpinnerModel());
heightSpinner.setEditor(new SpinnerEditor(heightSpinner)); heightSpinner.setEditor(new SpinnerEditor(heightSpinner));
panel.add(heightSpinner, "growx"); panel.add(heightSpinner, "growx");
order.add(((SpinnerEditor) heightSpinner.getEditor()).getTextField());
panel.add(new UnitSelector(heightModel), "growx"); panel.add(new UnitSelector(heightModel), "growx");
panel.add(new BasicSlider(heightModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap para"); panel.add(new BasicSlider(heightModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap para");
} }
@ -94,6 +100,7 @@ public class RailButtonConfig extends RocketComponentConfig {
JSpinner angleSpinner = new JSpinner( angleModel.getSpinnerModel()); JSpinner angleSpinner = new JSpinner( angleModel.getSpinnerModel());
angleSpinner.setEditor(new SpinnerEditor(angleSpinner)); angleSpinner.setEditor(new SpinnerEditor(angleSpinner));
panel.add(angleSpinner, "growx"); panel.add(angleSpinner, "growx");
order.add(((SpinnerEditor) angleSpinner.getEditor()).getTextField());
panel.add(new UnitSelector( angleModel), "growx"); panel.add(new UnitSelector( angleModel), "growx");
panel.add(new BasicSlider( angleModel.getSliderModel(-Math.PI, Math.PI)), "w 100lp, wrap"); panel.add(new BasicSlider( angleModel.getSliderModel(-Math.PI, Math.PI)), "w 100lp, wrap");
} }
@ -107,6 +114,7 @@ public class RailButtonConfig extends RocketComponentConfig {
final EnumModel<AxialMethod> methodModel = new EnumModel<AxialMethod>(component, "AxialMethod", AxialMethod.axialOffsetMethods ); final EnumModel<AxialMethod> methodModel = new EnumModel<AxialMethod>(component, "AxialMethod", AxialMethod.axialOffsetMethods );
JComboBox<AxialMethod> relToCombo = new JComboBox<AxialMethod>( methodModel ); JComboBox<AxialMethod> relToCombo = new JComboBox<AxialMethod>( methodModel );
panel.add( relToCombo, "spanx, growx, wrap"); panel.add( relToCombo, "spanx, growx, wrap");
order.add(relToCombo);
} }
{ //// plus { //// plus
@ -116,6 +124,7 @@ public class RailButtonConfig extends RocketComponentConfig {
offsetSpinner.setEditor(new SpinnerEditor(offsetSpinner)); offsetSpinner.setEditor(new SpinnerEditor(offsetSpinner));
focusElement = offsetSpinner; focusElement = offsetSpinner;
panel.add(offsetSpinner, "growx"); panel.add(offsetSpinner, "growx");
order.add(((SpinnerEditor) offsetSpinner.getEditor()).getTextField());
panel.add(new UnitSelector(offsetModel), "growx"); panel.add(new UnitSelector(offsetModel), "growx");
panel.add(new BasicSlider(offsetModel.getSliderModel( panel.add(new BasicSlider(offsetModel.getSliderModel(
new DoubleModel(component.getParent(), "Length", -1.0, UnitGroup.UNITS_NONE), new DoubleModel(component.getParent(), "Length", -1.0, UnitGroup.UNITS_NONE),
@ -132,6 +141,10 @@ public class RailButtonConfig extends RocketComponentConfig {
primary.add(panel, "grow"); primary.add(panel, "grow");
// Apply the custom focus travel policy to this panel
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
return primary; return primary;
} }

View File

@ -318,6 +318,7 @@ public class RocketComponentConfig extends JPanel {
JSpinner countSpinner = new JSpinner( countModel.getSpinnerModel()); JSpinner countSpinner = new JSpinner( countModel.getSpinnerModel());
countSpinner.setEditor(new SpinnerEditor(countSpinner)); countSpinner.setEditor(new SpinnerEditor(countSpinner));
panel.add(countSpinner, "w 100lp, wrap rel"); panel.add(countSpinner, "w 100lp, wrap rel");
order.add(((SpinnerEditor) countSpinner.getEditor()).getTextField());
} }
{ // Instance separation { // Instance separation
@ -326,6 +327,7 @@ public class RocketComponentConfig extends JPanel {
JSpinner separationSpinner = new JSpinner( separationModel.getSpinnerModel()); JSpinner separationSpinner = new JSpinner( separationModel.getSpinnerModel());
separationSpinner.setEditor(new SpinnerEditor(separationSpinner)); separationSpinner.setEditor(new SpinnerEditor(separationSpinner));
panel.add(separationSpinner, "growx"); panel.add(separationSpinner, "growx");
order.add(((SpinnerEditor) separationSpinner.getEditor()).getTextField());
panel.add(new UnitSelector(separationModel), "growx"); panel.add(new UnitSelector(separationModel), "growx");
double maxSeparationDistance = 0.1; double maxSeparationDistance = 0.1;
if (component.getParent() != null && component.getParent().getLength() > 0) { if (component.getParent() != null && component.getParent().getLength() > 0) {