IDEA-142012 Evaluate Code Fragment - mouse click on autocomplete puts it behind the dialog

This commit is contained in:
Sergey Malenkov
2015-07-07 11:51:49 +03:00
parent ea0f4ac193
commit 076e67a586
2 changed files with 19 additions and 16 deletions
@@ -527,20 +527,6 @@ public class IdeFrameImpl extends JFrame implements IdeFrameEx, DataProvider {
return b;
}
@Nullable
public static Component findNearestModalComponent(@NotNull Component c) {
Component eachParent = c;
while (eachParent != null) {
if (eachParent instanceof IdeFrame) return eachParent;
if (eachParent instanceof JDialog) {
if (((JDialog)eachParent).isModal()) return eachParent;
}
eachParent = eachParent.getParent();
}
return null;
}
public final BalloonLayout getBalloonLayout() {
return myBalloonLayout;
}
@@ -37,7 +37,6 @@ import com.intellij.openapi.util.*;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.wm.*;
import com.intellij.openapi.wm.ex.WindowManagerEx;
import com.intellij.openapi.wm.impl.IdeFrameImpl;
import com.intellij.openapi.wm.impl.IdeGlassPaneImpl;
import com.intellij.ui.*;
import com.intellij.ui.awt.RelativePoint;
@@ -782,7 +781,7 @@ public class AbstractPopup implements JBPopup {
myMouseOutCanceller.myEverEntered = targetBounds.equals(original);
}
myOwner = IdeFrameImpl.findNearestModalComponent(owner);
myOwner = getFrameOrDialog(owner); // use correct popup owner for non-modal dialogs too
if (myOwner == null) {
myOwner = owner;
}
@@ -1862,4 +1861,22 @@ public class AbstractPopup implements JBPopup {
private boolean isBusy() {
return myResizeListener != null && myResizeListener.isBusy() || myMoveListener != null && myMoveListener.isBusy();
}
/**
* Returns the first frame (or dialog) ancestor of the component.
* Note that this method returns the component itself if it is a frame (or dialog).
*
* @param component the component used to find corresponding frame (or dialog)
* @return the first frame (or dialog) ancestor of the component; or {@code null}
* if the component is not a frame (or dialog) and is not contained inside a frame (or dialog)
*
* @see UIUtil#getWindow
*/
private static Component getFrameOrDialog(Component component) {
while (component != null) {
if (component instanceof Frame || component instanceof Dialog) return component;
component = component.getParent();
}
return null;
}
}