From 4332d16d1197eff9e2265868b8d2fc02f2a9ab17 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 6 Dec 2011 20:55:32 +0100 Subject: [PATCH] request focus from edt only --- .../src/com/intellij/ide/actions/Switcher.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java index 8ed9a2bb01fc..2d93b1d2981c 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java @@ -48,6 +48,7 @@ import com.intellij.ui.Gray; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.SimpleTextAttributes; import com.intellij.ui.components.JBList; +import com.intellij.util.Alarm; import com.intellij.util.ArrayUtil; import com.intellij.util.IconUtil; import com.intellij.util.containers.ContainerUtil; @@ -159,6 +160,7 @@ public class Switcher extends AnAction implements DumbAware { final JPanel descriptions; final Project project; final Map twShortcuts; + final Alarm myAlarm; @SuppressWarnings({"ManualArrayToCollectionCopy"}) SwitcherPanel(Project project) { @@ -378,7 +380,7 @@ public class Switcher extends AnAction implements DumbAware { if (comp == null) { comp = ideFrame.getContentPane(); } - + myAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, myPopup); myPopup.showInCenterOf(comp); } @@ -466,17 +468,12 @@ public class Switcher extends AnAction implements DumbAware { } final int selectedIndex = jList.getSelectedIndex(); final IdeFocusManager focusManager = IdeFocusManager.getInstance(project); - new Thread() { //TODO[kb]: think how to do it better. Need to remove all hacks & work correctly with activateEditorComponentImpl method + myAlarm.addRequest(new Runnable() { @Override public void run() { - try { - sleep(300); - } - catch (InterruptedException e) {// - } focusManager.requestFocus(SwitcherPanel.this, true); } - }.start(); + }, 300); if (jList.getModel().getSize() == 1) { goLeft(); ((DefaultListModel)jList.getModel()).removeElementAt(selectedIndex);