Correct for escape operation
This commit is contained in:
parent
ea0a6aefca
commit
c026441a47
@ -66,8 +66,7 @@ public class DeploymentSelectionDialog extends JDialog {
|
|||||||
buttonGroup.add(defaultButton);
|
buttonGroup.add(defaultButton);
|
||||||
buttonGroup.add(overrideButton);
|
buttonGroup.add(overrideButton);
|
||||||
|
|
||||||
// Select the button based on current configuration. If the configuration is overridden
|
// Select the button based on current configuration. If the configuration is overridden, the overrideButton is selected.
|
||||||
// The the overrideButton is selected.
|
|
||||||
boolean isOverridden = !component.getDeploymentConfigurations().isDefault(id);
|
boolean isOverridden = !component.getDeploymentConfigurations().isDefault(id);
|
||||||
if (isOverridden) {
|
if (isOverridden) {
|
||||||
overrideButton.setSelected(true);
|
overrideButton.setSelected(true);
|
||||||
@ -77,7 +76,7 @@ public class DeploymentSelectionDialog extends JDialog {
|
|||||||
//// Deploys at:
|
//// Deploys at:
|
||||||
panel.add(new JLabel(trans.get("ParachuteCfg.lbl.Deploysat")), "");
|
panel.add(new JLabel(trans.get("ParachuteCfg.lbl.Deploysat")), "");
|
||||||
|
|
||||||
final JComboBox<DeployEvent> deployEvent = new JComboBox<DeployEvent>(new EnumModel<DeployEvent>(newConfiguration, "DeployEvent"));
|
final JComboBox<DeployEvent> deployEvent = new JComboBox<DeployEvent>(new EnumModel<>(newConfiguration, "DeployEvent"));
|
||||||
if( (component.getStageNumber() + 1 ) == rocket.getStageCount() ){
|
if( (component.getStageNumber() + 1 ) == rocket.getStageCount() ){
|
||||||
// This is the bottom stage: Restrict deployment options.
|
// This is the bottom stage: Restrict deployment options.
|
||||||
deployEvent.removeItem( DeployEvent.LOWER_STAGE_SEPARATION );
|
deployEvent.removeItem( DeployEvent.LOWER_STAGE_SEPARATION );
|
||||||
@ -147,7 +146,7 @@ public class DeploymentSelectionDialog extends JDialog {
|
|||||||
|
|
||||||
this.setContentPane(panel);
|
this.setContentPane(panel);
|
||||||
GUIUtil.setDisposableDialogOptions(this, okButton);
|
GUIUtil.setDisposableDialogOptions(this, okButton);
|
||||||
// TODO: closes wrong, doesn't use okButton action
|
GUIUtil.installEscapeCloseButtonOperation(this, okButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateState() {
|
private void updateState() {
|
||||||
|
@ -165,6 +165,25 @@ public class GUIUtil {
|
|||||||
installEscapeCloseOperation(dialog, null);
|
installEscapeCloseOperation(dialog, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void installEscapeCloseButtonOperation(final JDialog dialog, final JButton buttonToClick) {
|
||||||
|
Action triggerButtonAndClose = new AbstractAction() {
|
||||||
|
private static final long serialVersionUID = 9196153713666242274L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
log.info(Markers.USER_MARKER, "Closing dialog " + dialog);
|
||||||
|
|
||||||
|
if (buttonToClick != null) {
|
||||||
|
buttonToClick.doClick(); // Programmatically "press" the button
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
installEscapeCloseOperation(dialog, triggerButtonAndClose);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the correct action to close a JDialog when the ESC key is pressed.
|
* Add the correct action to close a JDialog when the ESC key is pressed.
|
||||||
* The dialog is closed by sending it a WINDOW_CLOSING event.
|
* The dialog is closed by sending it a WINDOW_CLOSING event.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user