diff --git a/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java b/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java index b8de9a93159f..5aa0122b5b1f 100644 --- a/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java +++ b/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java @@ -58,6 +58,18 @@ public class MasterDetailPopupBuilder { private ActionToolbar myActionToolbar; private boolean myAddDetailViewToEast = true; private Dimension myMinSize; + private boolean myCancelOnWindowDeactivation = true; + + + public String getDimensionServiceKey() { + return myDimensionServiceKey; + } + + public void setDimensionServiceKey(String dimensionServiceKey) { + myDimensionServiceKey = dimensionServiceKey; + } + + private String myDimensionServiceKey; public MasterDetailPopupBuilder setDetailView(DetailView detailView) { @@ -176,7 +188,9 @@ public class MasterDetailPopupBuilder { setResizable(true). setAutoselectOnMouseMove(false). setSettingButton(toolBar). - setSouthComponent(footerPanel); + setSouthComponent(footerPanel). + setCancelOnWindowDeactivation(myCancelOnWindowDeactivation); + if (myAddDetailViewToEast) { builder. @@ -193,6 +207,7 @@ public class MasterDetailPopupBuilder { setItemChoosenCallback(runnable). setCloseOnEnter(myCloseOnEnter). setMayBeParent(true). + setDimensionServiceKey(myDimensionServiceKey). setFilteringEnabled(new Function() { public String fun(Object o) { return ((ItemWrapper)o).speedSearchText(); @@ -271,6 +286,11 @@ public class MasterDetailPopupBuilder { return this; } + public MasterDetailPopupBuilder setCancelOnWindowDeactivation(boolean cancelOnWindowDeactivation) { + myCancelOnWindowDeactivation = cancelOnWindowDeactivation; + return this; + } + public static boolean allowedToRemoveItems(Object[] values) { for (Object value : values) { ItemWrapper item = (ItemWrapper)value; diff --git a/platform/platform-api/src/com/intellij/openapi/ui/popup/ComponentPopupBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/popup/ComponentPopupBuilder.java index 0a59a774b294..e0e8be88245b 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/popup/ComponentPopupBuilder.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/popup/ComponentPopupBuilder.java @@ -138,4 +138,6 @@ public interface ComponentPopupBuilder { @NotNull ComponentPopupBuilder setMayBeParent(boolean mayBeParent); + + ComponentPopupBuilder setCancelOnWindowDeactivation(boolean cancelOnWindowDeactivation); } diff --git a/platform/platform-api/src/com/intellij/openapi/ui/popup/PopupChooserBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/popup/PopupChooserBuilder.java index 6c1aea206ed0..ce7875b43316 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/popup/PopupChooserBuilder.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/popup/PopupChooserBuilder.java @@ -82,6 +82,8 @@ public class PopupChooserBuilder { private int myAdAlignment = SwingUtilities.LEFT; private boolean myModalContext; private boolean myCloseOnEnter = true; + private boolean myCancelOnWindowDeactivation = true; + public JScrollPane getScrollPane() { return myScrollPane; @@ -289,7 +291,8 @@ public class PopupChooserBuilder { .setMayBeParent(myMayBeParent) .setLocateWithinScreenBounds(true) .setCancelOnOtherWindowOpen(true) - .setModalContext(myModalContext); + .setModalContext(myModalContext) + .setCancelOnWindowDeactivation(myCancelOnWindowDeactivation); if (myCommandButton != null) { builder.setCommandButton(myCommandButton); @@ -550,4 +553,8 @@ public class PopupChooserBuilder { return this; } + public PopupChooserBuilder setCancelOnWindowDeactivation(boolean cancelOnWindowDeactivation) { + myCancelOnWindowDeactivation = cancelOnWindowDeactivation; + return this; + } } diff --git a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java index 505f4c4bab15..b2e4a8e5fed1 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java @@ -86,6 +86,7 @@ public class AbstractPopup implements JBPopup { private MouseChecker myCancelOnMouseOutCallback; private Canceller myMouseOutCanceller; private boolean myCancelOnWindow; + private boolean myCancelOnWindowDeactivation = true; private Dimension myForcedSize; private Point myForcedLocation; private ChildFocusWatcher myFocusWatcher; @@ -194,7 +195,8 @@ public class AbstractPopup implements JBPopup { Component settingsButtons, @Nullable final Processor pinCallback, boolean mayBeParent, - boolean showShadow) { + boolean showShadow, + boolean cancelOnWindowDeactivation) { if (requestFocus && !focusable) { assert false : "Incorrect argument combination: requestFocus=" + requestFocus + " focusable=" + focusable; } @@ -207,6 +209,7 @@ public class AbstractPopup implements JBPopup { myPaintShadow = showShadow && !SystemInfo.isMac && !movable && !resizable && Registry.is("ide.popup.dropShadow"); myContent = createContentPanel(resizable, myPopupBorder, isToDrawMacCorner() && resizable); myMayBeParent = mayBeParent; + myCancelOnWindowDeactivation = cancelOnWindowDeactivation; myContent.add(component, BorderLayout.CENTER); if (adText != null) { @@ -1246,6 +1249,14 @@ public class AbstractPopup implements JBPopup { return myCancelOnClickOutside; } + public boolean isCancelOnWindowDeactivation() { + return myCancelOnWindowDeactivation; + } + + public void setCancelOnWindowDeactivation(boolean cancelOnWindowDeactivation) { + myCancelOnWindowDeactivation = cancelOnWindowDeactivation; + } + private class Canceller implements AWTEventListener { private boolean myEverEntered = false; diff --git a/platform/platform-impl/src/com/intellij/ui/popup/ComponentPopupBuilderImpl.java b/platform/platform-impl/src/com/intellij/ui/popup/ComponentPopupBuilderImpl.java index 3c446b62fabd..7fef8e16c13f 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/ComponentPopupBuilderImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/ComponentPopupBuilderImpl.java @@ -51,6 +51,7 @@ public class ComponentPopupBuilderImpl implements ComponentPopupBuilder { private Computable myCallback = null; private Project myProject; private boolean myCancelOnClickOutside = true; + private boolean myCancelOnWindowDeactivation = true; private final Set myListeners = new LinkedHashSet(); private boolean myUseDimServiceForXYLocation; @@ -196,6 +197,12 @@ public class ComponentPopupBuilderImpl implements ComponentPopupBuilder { return this; } + @Override + public ComponentPopupBuilder setCancelOnWindowDeactivation(boolean cancelOnWindowDeactivation) { + myCancelOnWindowDeactivation = cancelOnWindowDeactivation; + return this; + } + @NotNull public ComponentPopupBuilder setProject(Project project) { myProject = project; @@ -211,7 +218,7 @@ public class ComponentPopupBuilderImpl implements ComponentPopupBuilder { myCancelOnMouseOutCallback, myCancelOnWindow, myTitleIcon, myCancelKeyEnabled, myLocateByContent, myPlacewithinScreen, myMinSize, myAlpha, myMaskProvider, myInStack, myModalContext, myFocusOwners, myAd, myAdAlignment, myHeaderAlwaysFocusable, myKeyboardActions, mySettingsButtons, myPinCallback, myMayBeParent, - myShowShadow); + myShowShadow, myCancelOnWindowDeactivation); if (myUserData != null) { popup.setUserData(myUserData); } diff --git a/platform/platform-impl/src/com/intellij/ui/popup/StackingPopupDispatcherImpl.java b/platform/platform-impl/src/com/intellij/ui/popup/StackingPopupDispatcherImpl.java index 948dacbc8fe5..c2d3e78dcc40 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/StackingPopupDispatcherImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/StackingPopupDispatcherImpl.java @@ -210,7 +210,7 @@ public class StackingPopupDispatcherImpl extends StackingPopupDispatcher impleme if (myStack.isEmpty()) return false; final AbstractPopup popup = (AbstractPopup)myStack.pop(); - if (popup != null && popup.isVisible()){ + if (popup != null && popup.isVisible() && popup.isCancelOnWindowDeactivation()) { popup.cancel(); return true; } diff --git a/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java b/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java index cd844ed4cd80..7c0469ce6d0a 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/WizardPopup.java @@ -90,7 +90,8 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene final Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext()); init(project, scrollPane, getPreferredFocusableComponent(), true, true, true, true, null, false, aStep.getTitle(), null, true, null, false, null, null, null, false, null, true, false, true, null, 0f, - null, true, false, new Component[0], null, SwingUtilities.LEFT, true, Collections.>emptyList(), null, null, false, true); + null, true, false, new Component[0], null, SwingUtilities.LEFT, true, Collections.>emptyList(), null, null, false, true, + true); registerAction("disposeAll", KeyEvent.VK_ESCAPE, InputEvent.SHIFT_MASK, new AbstractAction() { public void actionPerformed(ActionEvent e) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java index 36856522e40b..3ef17d63b20e 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java @@ -114,6 +114,8 @@ public class BreakpointMasterDetailPopupBuilder { public JBPopup createPopup() { myPopupBuilder = new MasterDetailPopupBuilder(myProject); + myPopupBuilder.setDimensionServiceKey(getClass().getName()); + myPopupBuilder.setCancelOnWindowDeactivation(false); if (myDetailView != null) { myPopupBuilder.setDetailView(myDetailView);