From b03d51f1eabe3c0d83a3bf62bccdef4780e902bf Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 24 Jan 2012 22:46:55 +0100 Subject: [PATCH] remember location on screen + IDEA-74486 Allow Alt+F7 (find usages) from within Ctrl+F12 (file structure popup) --- .../intellij/ide/util/FileStructurePopup.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java index 1f860c6c1280..5b290af55fc4 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java @@ -305,11 +305,20 @@ public class FileStructurePopup implements Disposable { myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, null) .setTitle(myTitle) .setResizable(true) + .setModalContext(false) .setFocusable(true) .setMovable(true) + .setBelongsToGlobalPopupStack(true) //.setCancelOnClickOutside(false) //for debug and snapshots .setCancelKeyEnabled(false) .setDimensionServiceKey(null, getDimensionServiceKey(), false) + .setCancelCallback(new Computable() { + @Override + public Boolean compute() { + DimensionService.getInstance().setLocation(getDimensionServiceKey(), myPopup.getLocationOnScreen(), myProject); + return true; + } + }) .createPopup(); Disposer.register(myPopup, this); Disposer.register(myPopup, new Disposable() { @@ -320,7 +329,12 @@ public class FileStructurePopup implements Disposable { } } }); - myPopup.showCenteredInCurrentWindow(myProject); + final Point location = DimensionService.getInstance().getLocation(getDimensionServiceKey(), myProject); + if (location != null) { + myPopup.showInScreenCoordinates(myEditor.getContentComponent(), location); + } else { + myPopup.showCenteredInCurrentWindow(myProject); + } ((AbstractPopup)myPopup).setShowHints(true); if (shouldSetWidth) { @@ -345,11 +359,12 @@ public class FileStructurePopup implements Disposable { final Alarm alarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD, myPopup); alarm.addRequest(new Runnable() { String filter = ""; + @Override public void run() { alarm.cancelAllRequests(); String prefix = mySpeedSearch.getEnteredPrefix(); - myTree.getEmptyText().setText(StringUtil.isEmpty(prefix) ? "Nothing to show" : "Can't find '" + prefix + "'"); + myTree.getEmptyText().setText(StringUtil.isEmpty(prefix) ? "Nothing to show" : "Can't find '" + prefix + "'"); if (prefix == null) prefix = ""; if (!filter.equals(prefix)) { @@ -362,7 +377,7 @@ public class FileStructurePopup implements Disposable { // mySpeedSearch.refreshSelection(); //} } - }); + }); } alarm.addRequest(this, 300); }