From d08eeca088e2ea65e87f070ddb0539f63148dcef Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 13 Mar 2012 10:29:35 +0100 Subject: [PATCH] disable typeahead in dialogs --- .../src/com/intellij/openapi/ui/DialogWrapper.java | 4 ++++ .../options/newEditor/OptionsEditorDialog.java | 5 +++++ .../openapi/ui/impl/DialogWrapperPeerImpl.java | 11 ++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) 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 d354f7c1bb09..987e41765ecc 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java @@ -491,6 +491,10 @@ public abstract class DialogWrapper { return !myCheckBoxDoNotShowDialog.isSelected(); } + public boolean isTypeAheadEnabled() { + return false; + } + public static JPanel addDoNotShowCheckBox(JComponent southPanel, JCheckBox checkBox) { final JPanel panel = new JPanel(new BorderLayout()); diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditorDialog.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditorDialog.java index 2cb0f8d23d0d..2bd280e05ebe 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditorDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditorDialog.java @@ -79,6 +79,11 @@ public class OptionsEditorDialog extends DialogWrapper implements DataProvider{ return result == null ? findLastSavedConfigurable(groups, project) : result; } + @Override + public boolean isTypeAheadEnabled() { + return true; + } + protected JComponent createCenterPanel() { myEditor = new OptionsEditor(myProject, myGroups, myPreselected); myEditor.getContext().addColleague(new OptionsEditorColleague.Adapter() { diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java b/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java index 10b9cf1baeff..6f0aa3ad25ff 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java @@ -82,7 +82,7 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra private final ActionCallback myWindowFocusedCallback = new ActionCallback("DialogFocusedCallback"); private final ActionCallback myTypeAheadDone = new ActionCallback("DialogTypeAheadDone"); - private final ActionCallback myTypeAheadCallback = new ActionCallback(); + private ActionCallback myTypeAheadCallback; /** * Creates modal DialogWrapper. The currently active window will be the dialog's parent. @@ -95,6 +95,7 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra */ protected DialogWrapperPeerImpl(DialogWrapper wrapper, Project project, boolean canBeParent) { myWrapper = wrapper; + myTypeAheadCallback = myWrapper.isTypeAheadEnabled() ? new ActionCallback() : (ActionCallback)null; myWindowManager = null; Application application = ApplicationManager.getApplication(); if (application != null && application.hasComponent(WindowManager.class)) { @@ -378,7 +379,9 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra } public ActionCallback show() { - IdeFocusManager.getInstance(myProject).typeAheadUntil(myTypeAheadCallback); + if (myTypeAheadCallback != null) { + IdeFocusManager.getInstance(myProject).typeAheadUntil(myTypeAheadCallback); + } final ActionCallback result = new ActionCallback(); LOG.assertTrue(EventQueue.isDispatchThread(), "Access is allowed from event dispatch thread only"); @@ -953,7 +956,9 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra notifyFocused(wrapper); } } - myTypeAheadCallback.setDone(); + if (myTypeAheadCallback != null) { + myTypeAheadCallback.setDone(); + } } }); }