From 8bb23c3f16cf8cc1d74e1979737d1bd477c830e2 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 8 Apr 2014 12:33:57 +0200 Subject: [PATCH] =?UTF-8?q?IDEA-123444=20Item=20=E2=80=9Cmore=E2=80=A6?= =?UTF-8?q?=E2=80=9D=20on=20Search=20Everywhere=20does=20not=20work?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ide/actions/SearchEverywhereAction.java | 93 +++++++++++-------- 1 file changed, 56 insertions(+), 37 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java index 9dd6d343f14e..f54c4a472280 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java @@ -167,6 +167,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA private ArrayList myAlreadyAddedActions = new ArrayList(); private volatile ActionCallback myCurrentWorker = ActionCallback.DONE; private int myHistoryIndex = 0; + boolean mySkipFocusGain = false; static { IdeEventQueue.getInstance().addPostprocessor(new IdeEventQueue.EventDispatcher() { @@ -356,10 +357,19 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA myList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { + e.consume(); final int i = myList.locationToIndex(e.getPoint()); if (i != -1) { - myList.setSelectedIndex(i); - doNavigate(i); + mySkipFocusGain = true; + getField().requestFocus(); + //noinspection SSBasedInspection + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + myList.setSelectedIndex(i); + doNavigate(i); + } + }); } } }); @@ -431,12 +441,10 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA } }); editor.addFocusListener(new FocusAdapter() { - boolean skip = false; - @Override public void focusGained(FocusEvent e) { - if (skip) { - skip = false; + if (mySkipFocusGain) { + mySkipFocusGain = false; return; } search.setText(""); @@ -467,7 +475,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA return; } if (myNonProjectCheckBox == e.getOppositeComponent()) { - skip = true; + mySkipFocusGain = true; editor.requestFocus(); return; } @@ -545,9 +553,15 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA if (actionId != null) { final AnAction action = ActionManager.getInstance().getAction(actionId); GotoActionAction.openOptionOrPerformAction(action, getField().getText(), project, getField(), myActionEvent); - if (myPopup != null && myPopup.isVisible()) { - myPopup.cancel(); - } + //noinspection SSBasedInspection + ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override + public void run() { + if (myPopup != null && myPopup.isVisible()) { + myPopup.cancel(); + } + } + }); return; } } @@ -1755,33 +1769,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA @Override public void dispose() { callback.setDone(); - if (myBalloon!= null) { - myBalloon.cancel(); - myBalloon = null; - } - myFileModel = null; - if (myFileChooseByName != null) { - myFileChooseByName.close(false); - myFileChooseByName = null; - } - myClassModel = null; - myActionModel = null; - myActions = null; - myFiles = null; - myClasses = null; - mySymbolsModel = null; - mySymbols = null; - myConfigurables.clear(); - myFocusComponent = null; - myContextComponent = null; - myFocusOwner = null; - myRenderer.myProject = null; - myCalcThread = null; - myPopup = null; - myHistoryIndex = 0; - myPopupActualWidth = 0; - myCurrentWorker = ActionCallback.DONE; - showAll.set(false); + resetFields(); myNonProjectCheckBox.setSelected(false); ActionToolbarImpl.updateAllToolbarsImmediately(); if (myActionEvent != null && myActionEvent.getInputEvent() instanceof MouseEvent) { @@ -1883,6 +1871,37 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA } } + protected void resetFields() { + if (myBalloon!= null) { + myBalloon.cancel(); + myBalloon = null; + } + myFileModel = null; + if (myFileChooseByName != null) { + myFileChooseByName.close(false); + myFileChooseByName = null; + } + myClassModel = null; + myActionModel = null; + myActions = null; + myFiles = null; + myClasses = null; + mySymbolsModel = null; + mySymbols = null; + myConfigurables.clear(); + myFocusComponent = null; + myContextComponent = null; + myFocusOwner = null; + myRenderer.myProject = null; + myCalcThread = null; + myPopup = null; + myHistoryIndex = 0; + myPopupActualWidth = 0; + myCurrentWorker = ActionCallback.DONE; + showAll.set(false); + mySkipFocusGain = false; + } + private void updatePopupBounds() { if (myPopup == null || !myPopup.isVisible()) { return;