From 0c8048f4de9077b458a48dcb2d21ddb7cfaec652 Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Wed, 15 Mar 2017 22:50:10 +0300 Subject: [PATCH] IDEA-144857 1) Add F4 to navigate from code preview to 'big' editor 2) Don't close popup when application is not active --- .../src/com/intellij/find/impl/FindPopupPanel.java | 12 +++++++++++- .../src/com/intellij/ide/IdePopupManager.java | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java b/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java index 534358ebe434..8d4ce3ffa1eb 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java @@ -86,7 +86,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -public class FindPopupPanel extends JBPanel implements FindUI { +public class FindPopupPanel extends JBPanel implements FindUI, DataProvider { private static final Logger LOG = Logger.getInstance(FindPopupPanel.class); private static final KeyStroke NEW_LINE = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); @@ -151,6 +151,7 @@ public class FindPopupPanel extends JBPanel implements FindUI { .setRequestFocus(true) .setCancelCallback(() -> { if (!myCanClose.get()) return false; + if (!ApplicationManager.getApplication().isActive()) return false; List popups = JBPopupFactory.getInstance().getChildPopups(this); if (!popups.isEmpty()) { for (JBPopup popup : popups) { @@ -1029,6 +1030,15 @@ public class FindPopupPanel extends JBPanel implements FindUI { } } + @Nullable + @Override + public Object getData(String dataId) { + if (CommonDataKeys.NAVIGATABLE_ARRAY.is(dataId)) { + return getSelectedUsages(); + } + return null; + } + @Nullable private Usage[] getSelectedUsages() { int[] rows = myResultsPreviewTable.getSelectedRows(); diff --git a/platform/platform-impl/src/com/intellij/ide/IdePopupManager.java b/platform/platform-impl/src/com/intellij/ide/IdePopupManager.java index 203da3358675..9914733ba6fc 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdePopupManager.java +++ b/platform/platform-impl/src/com/intellij/ide/IdePopupManager.java @@ -66,7 +66,8 @@ public final class IdePopupManager implements IdeEventQueue.EventDispatcher { } Component ultimateParentForFocusedComponent = UIUtil.findUltimateParent(focused); - Component ultimateParentForEventWindow = UIUtil.findUltimateParent(((WindowEvent)e).getWindow()); + Window sourceWindow = ((WindowEvent)e).getWindow(); + Component ultimateParentForEventWindow = UIUtil.findUltimateParent(sourceWindow); if (!shouldCloseAllPopup && ultimateParentForEventWindow == null || ultimateParentForFocusedComponent == null) { shouldCloseAllPopup = true; @@ -79,6 +80,9 @@ public final class IdePopupManager implements IdeEventQueue.EventDispatcher { shouldCloseAllPopup = true; } } + if (!shouldCloseAllPopup && isPopupWindow(sourceWindow) && sourceWindow.getParent() == ultimateParentForFocusedComponent) { + shouldCloseAllPopup = true; + } if (shouldCloseAllPopup) { closeAllPopups();