Ejemplo n.º 1
0
 private static boolean isWindowTextured(final Component c) {
   if (!(c instanceof JComponent)) {
     return false;
   }
   final JRootPane pane = ((JComponent) c).getRootPane();
   if (pane == null) {
     return false;
   }
   Object prop = pane.getClientProperty(CPlatformWindow.WINDOW_BRUSH_METAL_LOOK);
   if (prop != null) {
     return Boolean.parseBoolean(prop.toString());
   }
   prop = pane.getClientProperty(CPlatformWindow.WINDOW_STYLE);
   return prop != null && "textured".equals(prop);
 }
Ejemplo n.º 2
0
 private boolean couldBeInFullScreen() {
   if (myParent instanceof JFrame) {
     JRootPane rootPane = ((JFrame) myParent).getRootPane();
     return rootPane.getClientProperty(MacMainFrameDecorator.FULL_SCREEN) == null;
   }
   return false;
 }
 private static boolean isHintsAllowed(Window window) {
   if (window instanceof RootPaneContainer) {
     final JRootPane pane = ((RootPaneContainer) window).getRootPane();
     if (pane != null) {
       return Boolean.TRUE.equals(pane.getClientProperty(AbstractPopup.SHOW_HINTS));
     }
   }
   return false;
 }
 private static Window pop(Window owner) {
   JRootPane root = getRootPane(owner);
   if (root != null) {
     synchronized (CACHE) {
       @SuppressWarnings("unchecked")
       ArrayDeque<Window> cache = (ArrayDeque<Window>) root.getClientProperty(CACHE);
       if (cache != null && !cache.isEmpty()) {
         return cache.pop();
       }
     }
   }
   return null;
 }
 private static boolean push(Window owner, Window window) {
   JRootPane root = getRootPane(owner);
   if (root != null) {
     synchronized (CACHE) {
       @SuppressWarnings("unchecked")
       ArrayDeque<Window> cache = (ArrayDeque<Window>) root.getClientProperty(CACHE);
       if (cache == null) {
         cache = new ArrayDeque<Window>();
         root.putClientProperty(CACHE, cache);
       }
       cache.push(window);
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 6
0
  @Nullable
  public static Component getOwner(@Nullable Component c) {
    if (c == null) return null;

    final Window wnd = SwingUtilities.getWindowAncestor(c);
    if (wnd instanceof JWindow) {
      final JRootPane root = ((JWindow) wnd).getRootPane();
      final JBPopup popup = (JBPopup) root.getClientProperty(JBPopup.KEY);
      if (popup == null) return c;

      final Component owner = popup.getOwner();
      if (owner == null) return c;

      return getOwner(owner);
    } else {
      return c;
    }
  }
Ejemplo n.º 7
0
  protected int getInitialStyleBits() {
    // defaults style bits
    int styleBits = DECORATED | HAS_SHADOW | CLOSEABLE | MINIMIZABLE | ZOOMABLE | RESIZABLE;

    if (isNativelyFocusableWindow()) {
      styleBits = SET(styleBits, SHOULD_BECOME_KEY, true);
      styleBits = SET(styleBits, SHOULD_BECOME_MAIN, true);
    }

    final boolean isFrame = (target instanceof Frame);
    final boolean isDialog = (target instanceof Dialog);
    final boolean isPopup = (target.getType() == Window.Type.POPUP);
    if (isDialog) {
      styleBits = SET(styleBits, MINIMIZABLE, false);
    }

    // Either java.awt.Frame or java.awt.Dialog can be undecorated, however java.awt.Window always
    // is undecorated.
    {
      this.undecorated =
          isFrame
              ? ((Frame) target).isUndecorated()
              : (isDialog ? ((Dialog) target).isUndecorated() : true);
      if (this.undecorated) styleBits = SET(styleBits, DECORATED, false);
    }

    // Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never
    // resizable
    {
      final boolean resizable =
          isFrame
              ? ((Frame) target).isResizable()
              : (isDialog ? ((Dialog) target).isResizable() : false);
      styleBits = SET(styleBits, RESIZABLE, resizable);
      if (!resizable) {
        styleBits = SET(styleBits, ZOOMABLE, false);
      } else {
        setCanFullscreen(true);
      }
    }

    if (target.isAlwaysOnTop()) {
      styleBits = SET(styleBits, ALWAYS_ON_TOP, true);
    }

    if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
      styleBits = SET(styleBits, MODAL_EXCLUDED, true);
    }

    // If the target is a dialog, popup or tooltip we want it to ignore the brushed metal look.
    if (isPopup) {
      styleBits = SET(styleBits, TEXTURED, false);
      // Popups in applets don't activate applet's process
      styleBits = SET(styleBits, NONACTIVATING, true);
      styleBits = SET(styleBits, IS_POPUP, true);
    }

    if (Window.Type.UTILITY.equals(target.getType())) {
      styleBits = SET(styleBits, UTILITY, true);
    }

    if (target instanceof javax.swing.RootPaneContainer) {
      javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer) target).getRootPane();
      Object prop = null;

      prop = rootpane.getClientProperty(WINDOW_BRUSH_METAL_LOOK);
      if (prop != null) {
        styleBits = SET(styleBits, TEXTURED, Boolean.parseBoolean(prop.toString()));
      }

      if (isDialog && ((Dialog) target).getModalityType() == ModalityType.DOCUMENT_MODAL) {
        prop = rootpane.getClientProperty(WINDOW_DOC_MODAL_SHEET);
        if (prop != null) {
          styleBits = SET(styleBits, SHEET, Boolean.parseBoolean(prop.toString()));
        }
      }

      prop = rootpane.getClientProperty(WINDOW_STYLE);
      if (prop != null) {
        if ("small".equals(prop)) {
          styleBits = SET(styleBits, UTILITY, true);
          if (target.isAlwaysOnTop()
              && rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE) == null) {
            styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, true);
          }
        }
        if ("textured".equals(prop)) styleBits = SET(styleBits, TEXTURED, true);
        if ("unified".equals(prop)) styleBits = SET(styleBits, UNIFIED, true);
        if ("hud".equals(prop)) styleBits = SET(styleBits, HUD, true);
      }

      prop = rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE);
      if (prop != null) {
        styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_CLOSEABLE);
      if (prop != null) {
        styleBits = SET(styleBits, CLOSEABLE, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_MINIMIZABLE);
      if (prop != null) {
        styleBits = SET(styleBits, MINIMIZABLE, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_ZOOMABLE);
      if (prop != null) {
        styleBits = SET(styleBits, ZOOMABLE, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_FULLSCREENABLE);
      if (prop != null) {
        styleBits = SET(styleBits, FULLSCREENABLE, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_SHADOW);
      if (prop != null) {
        styleBits = SET(styleBits, HAS_SHADOW, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_DRAGGABLE_BACKGROUND);
      if (prop != null) {
        styleBits = SET(styleBits, DRAGGABLE_BACKGROUND, Boolean.parseBoolean(prop.toString()));
      }
    }

    if (isDialog) {
      styleBits = SET(styleBits, IS_DIALOG, true);
      if (((Dialog) target).isModal()) {
        styleBits = SET(styleBits, IS_MODAL, true);
      }
    }

    peer.setTextured(IS(TEXTURED, styleBits));

    return styleBits;
  }