1 package com
.intellij
.openapi
.ui
.popup
.util
;
3 import com
.intellij
.openapi
.ui
.popup
.JBPopup
;
4 import org
.jetbrains
.annotations
.Nullable
;
9 public class PopupUtil
{
15 public static Component
getOwner(@Nullable Component c
) {
16 if (c
== null) return null;
18 final Window wnd
= SwingUtilities
.getWindowAncestor(c
);
19 if (wnd
instanceof JWindow
) {
20 final JRootPane root
= ((JWindow
)wnd
).getRootPane();
21 final JBPopup popup
= (JBPopup
)root
.getClientProperty(JBPopup
.KEY
);
22 if (popup
== null) return c
;
24 final Component owner
= popup
.getOwner();
25 if (owner
== null) return c
;
27 return getOwner(owner
);