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(overrideButton);
|
||||
|
||||
// Select the button based on current configuration. If the configuration is overridden
|
||||
// The the overrideButton is selected.
|
||||
// Select the button based on current configuration. If the configuration is overridden, the overrideButton is selected.
|
||||
boolean isOverridden = !component.getDeploymentConfigurations().isDefault(id);
|
||||
if (isOverridden) {
|
||||
overrideButton.setSelected(true);
|
||||
@ -77,7 +76,7 @@ public class DeploymentSelectionDialog extends JDialog {
|
||||
//// Deploys at:
|
||||
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() ){
|
||||
// This is the bottom stage: Restrict deployment options.
|
||||
deployEvent.removeItem( DeployEvent.LOWER_STAGE_SEPARATION );
|
||||
@ -147,7 +146,7 @@ public class DeploymentSelectionDialog extends JDialog {
|
||||
|
||||
this.setContentPane(panel);
|
||||
GUIUtil.setDisposableDialogOptions(this, okButton);
|
||||
// TODO: closes wrong, doesn't use okButton action
|
||||
GUIUtil.installEscapeCloseButtonOperation(this, okButton);
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
|
@ -165,6 +165,25 @@ public class GUIUtil {
|
||||
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.
|
||||
* The dialog is closed by sending it a WINDOW_CLOSING event.
|
||||
|
Loading…
x
Reference in New Issue
Block a user