Fix some bugs in the custom focus traversal policy

Sorry, I don't want to split this all up in atomic commits...
This commit is contained in:
SiboVG 2022-08-28 15:00:02 +02:00
parent c217479a3c
commit 099ab09bcc
24 changed files with 73 additions and 74 deletions

View File

@ -287,6 +287,7 @@ public class AppearancePanel extends JPanel {
BooleanModel fDefault = new BooleanModel(c.getColor() == null);
final JButton saveAsDefault;
{// Style Header Row
final JCheckBox colorDefault = new JCheckBox(fDefault);
colorDefault.addActionListener(new ActionListener() {
@ -311,9 +312,9 @@ public class AppearancePanel extends JPanel {
add(colorDefault);
order.add(colorDefault);
JButton button = new SelectColorButton(
saveAsDefault = new SelectColorButton(
trans.get("RocketCompCfg.but.Saveasdefstyle"));
button.addActionListener(new ActionListener() {
saveAsDefault.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (c.getColor() != null) {
@ -328,8 +329,8 @@ public class AppearancePanel extends JPanel {
}
}
});
fDefault.addEnableComponent(button, false);
add(button, "span 2, align right, wrap");
fDefault.addEnableComponent(saveAsDefault, false);
add(saveAsDefault, "span 2, align right, wrap");
}
{// Figure Color
@ -339,6 +340,8 @@ public class AppearancePanel extends JPanel {
order.add(figureColorButton);
}
order.add(saveAsDefault);
{// Line Style
add(new JLabel(trans.get("RocketCompCfg.lbl.Complinestyle")));

View File

@ -36,6 +36,11 @@ public class AxialStageConfig extends ComponentAssemblyConfig {
trans.get("StageConfig.tab.Separation.ttip"), 0);
tabbedPane.setSelectedIndex(0);
}
// Apply the custom focus travel policy to this config dialog
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
@ -47,8 +52,7 @@ public class AxialStageConfig extends ComponentAssemblyConfig {
StageSeparationConfiguration sepConfig = stage.getSeparationConfiguration();
JComboBox<?> combo = new JComboBox<StageSeparationConfiguration.SeparationEvent>(
new EnumModel<StageSeparationConfiguration.SeparationEvent>( sepConfig, "SeparationEvent", SeparationEvent.values()));
JComboBox<?> combo = new JComboBox<>(new EnumModel<>( sepConfig, "SeparationEvent", SeparationEvent.values()));
//combo.setSelectedItem(sepConfig);
panel.add(combo, "");
@ -68,10 +72,6 @@ public class AxialStageConfig extends ComponentAssemblyConfig {
panel.add(new StyledLabel(CommonStrings.override_description, -1), "spanx, wrap para");
// Apply the custom focus travel policy to this config dialog
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
return panel;
}

View File

@ -120,9 +120,9 @@ public class BodyTubeConfig extends RocketComponentConfig {
trans.get("BodyTubecfg.tab.Motormountconf"), 1);
// Apply the custom focus travel policy to this config dialog
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
@Override

View File

@ -5,6 +5,7 @@ import javax.swing.JDialog;
import javax.swing.JPanel;
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.gui.adaptors.CustomFocusTraversalPolicy;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.startup.Application;
@ -26,6 +27,11 @@ public class BulkheadConfig extends RingComponentConfig {
tabbedPane.insertTab(trans.get("BulkheadCfg.tab.General"), null, tab,
trans.get("BulkheadCfg.tab.Generalproperties"), 0);
tabbedPane.setSelectedIndex(0);
// Apply the custom focus travel policy to this panel
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
}

View File

@ -5,6 +5,7 @@ import javax.swing.JDialog;
import javax.swing.JPanel;
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.gui.adaptors.CustomFocusTraversalPolicy;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.startup.Application;
@ -28,6 +29,11 @@ public class CenteringRingConfig extends RingComponentConfig {
tabbedPane.insertTab(trans.get("CenteringRingCfg.tab.General"), null, tab,
trans.get("CenteringRingCfg.tab.Generalproperties"), 0);
tabbedPane.setSelectedIndex(0);
// Apply the custom focus travel policy to this panel
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
}

View File

@ -58,6 +58,7 @@ public class ComponentAssemblyConfig extends RocketComponentConfig {
final ComboBoxModel<RadiusMethod> radiusMethodModel = new EnumModel<RadiusMethod>( boosters, "RadiusMethod", RadiusMethod.choices());
final JComboBox<RadiusMethod> radiusMethodCombo = new JComboBox<RadiusMethod>( radiusMethodModel );
motherPanel.add( radiusMethodCombo, "spanx 3, growx, wrap");
order.add(radiusMethodCombo);
// set radial distance
JLabel radiusLabel = new JLabel(trans.get("StageConfig.parallel.radius"));
@ -68,6 +69,7 @@ public class ComponentAssemblyConfig extends RocketComponentConfig {
JSpinner radiusSpinner = new JSpinner(radiusModel.getSpinnerModel());
radiusSpinner.setEditor(new SpinnerEditor(radiusSpinner));
motherPanel.add(radiusSpinner , "wmin 65lp, growx 1, align right");
order.add(((SpinnerEditor) radiusSpinner.getEditor()).getTextField());
// autoRadOffsModel.addEnableComponent(radiusSpinner, false);
UnitSelector radiusUnitSelector = new UnitSelector(radiusModel);
motherPanel.add(radiusUnitSelector, "growx 1");
@ -89,6 +91,7 @@ public class ComponentAssemblyConfig extends RocketComponentConfig {
JSpinner angleSpinner = new JSpinner(angleModel.getSpinnerModel());
angleSpinner.setEditor(new SpinnerEditor(angleSpinner));
motherPanel.add(angleSpinner, "wmin 65lp, growx 1");
order.add(((SpinnerEditor) angleSpinner.getEditor()).getTextField());
UnitSelector angleUnitSelector = new UnitSelector(angleModel);
motherPanel.add( angleUnitSelector, "growx 1");
motherPanel.add(new BasicSlider(angleModel.getSliderModel(-Math.PI, Math.PI)), "gapleft para, growx 2, wrap");
@ -101,6 +104,7 @@ public class ComponentAssemblyConfig extends RocketComponentConfig {
JSpinner countSpinner = new JSpinner(countModel.getSpinnerModel());
countSpinner.setEditor(new SpinnerEditor(countSpinner));
motherPanel.add(countSpinner, "wmin 65lp, growx 1, wrap");
order.add(((SpinnerEditor) countSpinner.getEditor()).getTextField());
// setPositions relative to parent component
JLabel positionLabel = new JLabel(trans.get("LaunchLugCfg.lbl.Posrelativeto"));
@ -109,6 +113,7 @@ public class ComponentAssemblyConfig extends RocketComponentConfig {
ComboBoxModel<AxialMethod> axialPositionMethodModel = new EnumModel<AxialMethod>(component, "AxialMethod", AxialMethod.axialOffsetMethods );
JComboBox<?> positionMethodCombo = new JComboBox<AxialMethod>( axialPositionMethodModel );
motherPanel.add(positionMethodCombo, "spanx 3, growx, wrap");
order.add(positionMethodCombo);
// plus
motherPanel.add(new JLabel(trans.get("StageConfig.parallel.plus")), "right");
@ -116,8 +121,8 @@ public class ComponentAssemblyConfig extends RocketComponentConfig {
final DoubleModel axialOffsetModel = new DoubleModel(component, "AxialOffset", UnitGroup.UNITS_LENGTH);
final JSpinner axialOffsetSpinner = new JSpinner(axialOffsetModel.getSpinnerModel());
axialOffsetSpinner.setEditor(new SpinnerEditor(axialOffsetSpinner));
motherPanel.add(axialOffsetSpinner, "wmin 65lp, growx 1");
order.add(((SpinnerEditor) axialOffsetSpinner.getEditor()).getTextField());
positionMethodCombo.addActionListener(new ActionListener() {
@Override

View File

@ -201,6 +201,7 @@ public class EllipticalFinSetConfig extends FinSetConfig {
tabbedPane.setSelectedIndex(0);
// Apply the custom focus travel policy to this config dialog
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}

View File

@ -145,10 +145,6 @@ public abstract class FinSetConfig extends RocketComponentConfig {
order.add(split);
order.add(convert);
}
// Apply the custom focus travel policy to these bottom buttons
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
private JPanel finTabPanel() {
@ -251,11 +247,7 @@ public abstract class FinSetConfig extends RocketComponentConfig {
}
});
panel.add(autoCalc, "skip 1, spanx");
order.add(autoCalc);
// Apply the custom focus travel policy to this panel
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
order.add(autoCalc);
return panel;
}
@ -585,10 +577,6 @@ public abstract class FinSetConfig extends RocketComponentConfig {
order.add(materialCombo);
filletPanel.setToolTipText(tip);
// Apply the custom focus travel policy to this panel
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
return filletPanel;
}
}

View File

@ -95,6 +95,11 @@ public class FreeformFinSetConfig extends FinSetConfig {
tabbedPane.setSelectedIndex(0);
addFinSetButtons();
// Apply the custom focus travel policy to this panel
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
@ -218,10 +223,6 @@ public class FreeformFinSetConfig extends FinSetConfig {
mainPanel.add(panel, "aligny 20%");
// Apply the custom focus travel policy to this panel
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
return mainPanel;
}

View File

@ -207,9 +207,9 @@ public class InnerTubeConfig extends RocketComponentConfig {
tabbedPane.setSelectedIndex(0);
// Apply the custom focus travel policy to this config dialog
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
protected JPanel positionTab() {
@ -280,10 +280,6 @@ public class InnerTubeConfig extends RocketComponentConfig {
note.setText(trans.get("ringcompcfg.note.desc"));
panel.add(note, "spanx, growx");
// Apply the custom focus travel policy to this config dialog
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
return panel;
}
@ -417,10 +413,6 @@ public class InnerTubeConfig extends RocketComponentConfig {
panel.add(subPanel, "grow");
// Apply the custom focus travel policy to this config dialog
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
return panel;
}

View File

@ -162,9 +162,9 @@ public class LaunchLugConfig extends RocketComponentConfig {
tabbedPane.setSelectedIndex(0);
// Apply the custom focus travel policy to this config dialog
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
@Override

View File

@ -165,9 +165,9 @@ public class MassComponentConfig extends RocketComponentConfig {
tabbedPane.setSelectedIndex(0);
// Apply the custom focus travel policy to this config dialog
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
@ -215,10 +215,6 @@ public class MassComponentConfig extends RocketComponentConfig {
panel.add(button, "spanx, right");
order.add(button);
// Apply the custom focus travel policy to this panel
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
return panel;
}
}

View File

@ -169,9 +169,9 @@ public class NoseConeConfig extends RocketComponentConfig {
tabbedPane.setSelectedIndex(0);
// Apply the custom focus travel policy to this config dialog
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}

View File

@ -288,9 +288,9 @@ public class ParachuteConfig extends RecoveryDeviceConfig {
tabbedPane.setSelectedIndex(0);
// Apply the custom focus travel policy to this config dialog
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
@ -338,10 +338,6 @@ public class ParachuteConfig extends RecoveryDeviceConfig {
panel.add(button, "spanx, right");
order.add(button);
// Apply the custom focus travel policy to this panel
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
return panel;
}
}

View File

@ -33,7 +33,11 @@ public class RailButtonConfig extends RocketComponentConfig {
//// General and General properties
tabbedPane.insertTab( trans.get("RailBtnCfg.tab.General"), null, buttonTab( (RailButton)component ), trans.get("RailBtnCfg.tab.GeneralProp"), 0);
tabbedPane.setSelectedIndex(0);
// Apply the custom focus travel policy to this panel
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
private JPanel buttonTab( final RailButton rbc ){
@ -141,10 +145,6 @@ public class RailButtonConfig extends RocketComponentConfig {
primary.add(panel, "grow");
// Apply the custom focus travel policy to this panel
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
return primary;
}

View File

@ -34,7 +34,7 @@ public class RingComponentConfig extends RocketComponentConfig {
super(d, component, parent);
}
protected JPanel generalTab(String outer, String inner, String thickness, String length) {
JPanel panel = new JPanel(new MigLayout("gap rel unrel", "[][65lp::][30lp::]", ""));
DoubleModel m;
@ -175,10 +175,6 @@ public class RingComponentConfig extends RocketComponentConfig {
}
panel.add(materialPanel, "cell 4 0, gapleft paragraph, aligny 0%, spany");
// Apply the custom focus travel policy to this config dialog
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
return panel;
}

View File

@ -23,6 +23,8 @@ import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.database.ComponentPresetDatabase;
@ -69,6 +71,7 @@ public class RocketComponentConfig extends JPanel {
private final TextFieldListener textFieldListener;
private JPanel buttonPanel;
protected JButton closeButton;
private AppearancePanel appearancePanel = null;
private JLabel infoLabel;
@ -189,7 +192,7 @@ public class RocketComponentConfig extends JPanel {
}
//// Close button
JButton closeButton = new SelectColorButton(trans.get("dlg.but.close"));
this.closeButton = new SelectColorButton(trans.get("dlg.but.close"));
closeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {

View File

@ -141,6 +141,7 @@ public class ShockCordConfig extends RocketComponentConfig {
tabbedPane.setSelectedIndex(0);
// Apply the custom focus travel policy to this config dialog
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
@ -190,10 +191,6 @@ public class ShockCordConfig extends RocketComponentConfig {
panel.add(button, "spanx, right");
order.add(button);
// Apply the custom focus travel policy to this panel
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
return panel;
}
}

View File

@ -5,6 +5,7 @@ import javax.swing.JDialog;
import javax.swing.JPanel;
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.gui.adaptors.CustomFocusTraversalPolicy;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.startup.Application;
@ -28,6 +29,11 @@ public class SleeveConfig extends RingComponentConfig {
tabbedPane.insertTab(trans.get("SleeveCfg.tab.General"), null, tab,
trans.get("SleeveCfg.tab.Generalproperties"), 0);
tabbedPane.setSelectedIndex(0);
// Apply the custom focus travel policy to this panel
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
}

View File

@ -275,9 +275,9 @@ public class StreamerConfig extends RecoveryDeviceConfig {
tabbedPane.setSelectedIndex(0);
// Apply the custom focus travel policy to this config dialog
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
@ -327,10 +327,6 @@ public class StreamerConfig extends RecoveryDeviceConfig {
panel.add(button, "spanx, right");
order.add(button);
// Apply the custom focus travel policy to this panel
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
return panel;
}
}

View File

@ -5,6 +5,7 @@ import javax.swing.JDialog;
import javax.swing.JPanel;
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.gui.adaptors.CustomFocusTraversalPolicy;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.startup.Application;
@ -30,6 +31,11 @@ public class ThicknessRingComponentConfig extends RingComponentConfig {
tabbedPane.insertTab(trans.get("ThicknessRingCompCfg.tab.General"), null, tab,
trans.get("ThicknessRingCompCfg.tab.Generalprop"), 0);
tabbedPane.setSelectedIndex(0);
// Apply the custom focus travel policy to this panel
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
}

View File

@ -202,9 +202,9 @@ public class TransitionConfig extends RocketComponentConfig {
tabbedPane.setSelectedIndex(0);
// Apply the custom focus travel policy to this config dialog
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}

View File

@ -249,10 +249,11 @@ public class TrapezoidFinSetConfig extends FinSetConfig {
trans.get("TrapezoidFinSetCfg.tab.Generalproperties"), 0);
tabbedPane.setSelectedIndex(0);
addFinSetButtons();
// Apply the custom focus travel policy to this config dialog
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
addFinSetButtons();
}
}

View File

@ -179,9 +179,9 @@ public class TubeFinSetConfig extends RocketComponentConfig {
tabbedPane.setSelectedIndex(0);
// Apply the custom focus travel policy to this config dialog
order.add(closeButton); // Make sure the close button is the last component
CustomFocusTraversalPolicy policy = new CustomFocusTraversalPolicy(order);
parent.setFocusTraversalPolicy(policy);
}
@Override