예제 #1
0
  /** Close me */
  public void close() {
    if (dialog != null) {
      dialog.setVisible(false);
      if (dialog.isModal()) {
        dialog.setModal(false);
      }
    }

    if (frame != null) {
      frame.setVisible(false);
    }
  }
예제 #2
0
  /**
   * @return <code>true</code> if and only if the <code>component</code> represents modal context.
   * @throws IllegalArgumentException if <code>component</code> is <code>null</code>.
   */
  public static boolean isModalContext(@NotNull Component component) {
    Window window;
    if (component instanceof Window) {
      window = (Window) component;
    } else {
      window = SwingUtilities.getWindowAncestor(component);
    }

    if (window instanceof IdeFrameImpl) {
      final Component pane = ((IdeFrameImpl) window).getGlassPane();
      if (pane instanceof IdeGlassPaneEx) {
        return ((IdeGlassPaneEx) pane).isInModalContext();
      }
    }

    if (window instanceof JDialog) {
      final JDialog dialog = (JDialog) window;
      if (!dialog.isModal()) {
        final Window owner = dialog.getOwner();
        return owner != null && isModalContext(owner);
      }
    }

    if (window instanceof JFrame) {
      return false;
    }

    boolean isMainFrame = window instanceof IdeFrameImpl;
    boolean isFloatingDecorator = window instanceof FloatingDecorator;

    boolean isPopup = !(component instanceof JFrame) && !(component instanceof JDialog);
    if (isPopup) {
      if (component instanceof JWindow) {
        JBPopup popup =
            (JBPopup) ((JWindow) component).getRootPane().getClientProperty(JBPopup.KEY);
        if (popup != null) {
          return popup.isModalContext();
        }
      }
    }

    return !isMainFrame && !isFloatingDecorator;
  }