/**
  * @param component component
  * @return whether the component in Swing tree or not. This method is more weak then {@link
  *     Component#isShowing() }
  */
 private boolean isInTree(final Component component) {
   if (component instanceof Window) {
     return component.isShowing();
   } else {
     Window windowAncestor = SwingUtilities.getWindowAncestor(component);
     return windowAncestor != null && windowAncestor.isShowing();
   }
 }
Exemplo n.º 2
0
  /**
   * @param parent parent component which is used to calculate heavy weight window ancestor. <code>
   *     parent</code> cannot be <code>null</code> and must be showing.
   */
  protected DialogWrapperPeerImpl(
      @NotNull DialogWrapper wrapper, @NotNull Component parent, boolean canBeParent) {
    myWrapper = wrapper;
    if (!parent.isShowing() && parent != JOptionPane.getRootFrame()) {
      throw new IllegalArgumentException("parent must be showing: " + parent);
    }
    myWindowManager = null;
    Application application = ApplicationManager.getApplication();
    if (application != null && application.hasComponent(WindowManager.class)) {
      myWindowManager = (WindowManagerEx) WindowManager.getInstance();
    }

    Window owner =
        parent instanceof Window
            ? (Window) parent
            : (Window) SwingUtilities.getAncestorOfClass(Window.class, parent);
    if (!(owner instanceof Dialog) && !(owner instanceof Frame)) {
      owner = JOptionPane.getRootFrame();
    }
    createDialog(owner, canBeParent);
  }