From f936d734f9f24d44dc6e9705bd040ed3a9993492 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Thu, 3 Sep 2009 16:54:19 +0400 Subject: [PATCH] better Ctrl release handling (IDEA-24436) --- .../intellij/ide/actions/ToolWindowSwitcher.java | 28 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ToolWindowSwitcher.java b/platform/platform-impl/src/com/intellij/ide/actions/ToolWindowSwitcher.java index 6309bbc1a6..d8ab5e00b3 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ToolWindowSwitcher.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ToolWindowSwitcher.java @@ -48,17 +48,35 @@ public class ToolWindowSwitcher extends AnAction implements DumbAware { private static final Color SEPARATOR_COLOR = BORDER_COLOR.brighter(); @NonNls private static final String SWITCHER_FEATURE_ID = "switcher"; + private static final KeyListener performanceProblemsSolver = new KeyAdapter() { //IDEA-24436 + @Override + public void keyReleased(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_CONTROL) { + synchronized (ToolWindowSwitcher.class) { + if (ToolWindowSwitcher.SWITCHER != null) { + ToolWindowSwitcher.SWITCHER.navigate(); + } + } + } + } + }; + + private static Component focusComponent = null; + @NonNls private static final String SWITCHER_TITLE = "Switcher"; + public void actionPerformed(AnActionEvent e) { final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); if (project == null) return; if (SWITCHER == null) { SWITCHER = new ToolWindowSwitcherPanel(project); + focusComponent = FocusManager.getCurrentManager().getFocusOwner(); + focusComponent.addKeyListener(performanceProblemsSolver); FeatureUsageTracker.getInstance().triggerFeatureUsed(SWITCHER_FEATURE_ID); } + if (e.getInputEvent().isShiftDown()) { SWITCHER.goBack(); - } - else { + } else { SWITCHER.goForward(); } } @@ -231,11 +249,15 @@ public class ToolWindowSwitcher extends AnAction implements DumbAware { .setModalContext(false) .setFocusable(true) .setRequestFocus(true) - .setTitle("Switcher") + .setTitle(SWITCHER_TITLE) .setMovable(false) .setCancelCallback(new Computable() { public Boolean compute() { SWITCHER = null; + if (focusComponent != null) { + focusComponent.removeKeyListener(performanceProblemsSolver); + focusComponent = null; + } return true; } }).createPopup(); -- 2.11.4.GIT