diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java index 0144cf4fb58b..188618e2f319 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java @@ -1569,33 +1569,17 @@ public abstract class DialogWrapper { } private void registerKeyboardShortcuts() { - ActionListener cancelKeyboardAction = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager(); - MenuElement[] selectedPath = menuSelectionManager.getSelectedPath(); - if (selectedPath.length > 0) { // hide popup menu if any - menuSelectionManager.clearSelectedPath(); - } - else { - if (ApplicationManager.getApplication() == null) { - doCancelAction(e); - return; - } - final StackingPopupDispatcher popupDispatcher = StackingPopupDispatcher.getInstance(); - if (popupDispatcher != null && !popupDispatcher.isPopupFocused()) { - doCancelAction(e); - } - } - } - }; final JRootPane rootPane = getRootPane(); if (rootPane == null) return; - rootPane.registerKeyboardAction(cancelKeyboardAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); - registerForEveryKeyboardShortcut(cancelKeyboardAction, CommonShortcuts.getCloseActiveWindow()); + ActionListener cancelKeyboardAction = createCancelAction(); + if (cancelKeyboardAction != null) { + rootPane + .registerKeyboardAction(cancelKeyboardAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); + registerForEveryKeyboardShortcut(cancelKeyboardAction, CommonShortcuts.getCloseActiveWindow()); + } if (ApplicationInfo.contextHelpAvailable()) { ActionListener helpAction = new ActionListener() { @@ -1633,6 +1617,34 @@ public abstract class DialogWrapper { } } + /** + * + * @return null if we should ignore for window closing + */ + @Nullable + protected ActionListener createCancelAction() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager(); + MenuElement[] selectedPath = menuSelectionManager.getSelectedPath(); + if (selectedPath.length > 0) { // hide popup menu if any + menuSelectionManager.clearSelectedPath(); + } + else { + if (ApplicationManager.getApplication() == null) { + doCancelAction(e); + return; + } + final StackingPopupDispatcher popupDispatcher = StackingPopupDispatcher.getInstance(); + if (popupDispatcher != null && !popupDispatcher.isPopupFocused()) { + doCancelAction(e); + } + } + } + }; + } + private void registerForEveryKeyboardShortcut(ActionListener action, @NotNull ShortcutSet shortcuts) { for (Shortcut shortcut : shortcuts.getShortcuts()) { if (shortcut instanceof KeyboardShortcut) { diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java index 0d62d30fa511..1b0644a3a20f 100644 --- a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java +++ b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java @@ -21,6 +21,7 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.SystemInfo; import com.intellij.ui.JBCardLayout; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; @@ -148,9 +149,10 @@ public class CustomizeIDEWizardDialog extends DialogWrapper implements ActionLis } } + @Nullable @Override - public void doCancelAction() { - // lets pretend it is the wind.. + protected ActionListener createCancelAction() { + return null;//Prevent closing by } @Override