changeset 6768:33ba3a542f62 8u5-b04

RT-35138: Laminar flow for FX windows Reviewed-by: Anthony Petrov, Martin Sladecek, Mark Howe, Chris Ries, Alexander Fomin
author kcr
date Mon, 13 Jan 2014 08:41:59 -0800
parents 114ec4e19e76
children 39943f76cf47
files modules/graphics/src/main/java/com/sun/javafx/stage/StageHelper.java modules/graphics/src/main/java/com/sun/javafx/tk/DummyToolkit.java modules/graphics/src/main/java/com/sun/javafx/tk/Toolkit.java modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java modules/graphics/src/main/java/javafx/stage/Stage.java modules/graphics/src/test/java/com/sun/javafx/pgstub/StubToolkit.java
diffstat 7 files changed, 73 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/stage/StageHelper.java	Fri Jan 10 12:04:01 2014 -0800
+++ b/modules/graphics/src/main/java/com/sun/javafx/stage/StageHelper.java	Mon Jan 13 08:41:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,8 @@
     private static StageAccessor stageAccessor;
 
     public static interface StageAccessor {
-          public ObservableList<Stage> getStages();
+        public ObservableList<Stage> getStages();
+        public void initSecurityDialog(Stage stage, boolean securityDialog);
     }
 
     /**
@@ -60,6 +61,10 @@
         return stageAccessor.getStages();
     }
 
+    public static void initSecurityDialog(Stage stage, boolean securityDialog) {
+        stageAccessor.initSecurityDialog(stage, securityDialog);
+    }
+
     public static void setStageAccessor(StageAccessor a) {
         if (stageAccessor != null) {
             System.out.println("Warning: Stage accessor already set: " + stageAccessor);
--- a/modules/graphics/src/main/java/com/sun/javafx/tk/DummyToolkit.java	Fri Jan 10 12:04:01 2014 -0800
+++ b/modules/graphics/src/main/java/com/sun/javafx/tk/DummyToolkit.java	Mon Jan 13 08:41:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -92,7 +92,7 @@
     }
 
     @Override
-    public TKStage createTKStage(Window peerWindow, StageStyle stageStyle, boolean primary, Modality modality, TKStage owner, boolean rtl, AccessControlContext acc) {
+    public TKStage createTKStage(Window peerWindow, boolean securityDialog, StageStyle stageStyle, boolean primary, Modality modality, TKStage owner, boolean rtl, AccessControlContext acc) {
         throw new UnsupportedOperationException("Not supported yet.");
     }
 
--- a/modules/graphics/src/main/java/com/sun/javafx/tk/Toolkit.java	Fri Jan 10 12:04:01 2014 -0800
+++ b/modules/graphics/src/main/java/com/sun/javafx/tk/Toolkit.java	Mon Jan 13 08:41:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -274,8 +274,7 @@
 
     public abstract boolean isNestedLoopRunning();
 
-    public abstract TKStage createTKStage(Window peerWindow, StageStyle stageStyle, boolean primary,
-            Modality modality, TKStage owner, boolean rtl, AccessControlContext acc);
+    public abstract TKStage createTKStage(Window peerWindow, boolean securityDialog, StageStyle stageStyle, boolean primary, Modality modality, TKStage owner, boolean rtl, AccessControlContext acc);
 
     public abstract TKStage createTKPopupStage(Window peerWindow, StageStyle popupStyle, TKStage owner, AccessControlContext acc);
     public abstract TKStage createTKEmbeddedStage(HostInterface host, AccessControlContext acc);
--- a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java	Fri Jan 10 12:04:01 2014 -0800
+++ b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java	Mon Jan 13 08:41:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -511,10 +511,9 @@
         }
     }
 
-    @Override public TKStage createTKStage(Window peerWindow, StageStyle stageStyle,
-            boolean primary, Modality modality, TKStage owner, boolean rtl, AccessControlContext acc) {
+    @Override public TKStage createTKStage(Window peerWindow, boolean securityDialog, StageStyle stageStyle, boolean primary, Modality modality, TKStage owner, boolean rtl, AccessControlContext acc) {
         assertToolkitRunning();
-        WindowStage stage = new WindowStage(peerWindow, stageStyle, modality, owner);
+        WindowStage stage = new WindowStage(peerWindow, securityDialog, stageStyle, modality, owner);
         stage.setSecurityContext(acc);
         if (primary) {
             stage.setIsPrimary();
@@ -569,7 +568,9 @@
                                                 TKStage owner,
                                                 AccessControlContext acc) {
         assertToolkitRunning();
-        WindowStage stage = new WindowStage(peerWindow, popupStyle, null, owner);
+        boolean securityDialog = owner instanceof WindowStage ?
+                ((WindowStage)owner).isSecurityDialog() : false;
+        WindowStage stage = new WindowStage(peerWindow, securityDialog, popupStyle, null, owner);
         stage.setSecurityContext(acc);
         stage.setIsPopup();
         stage.init(systemMenu);
--- a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java	Fri Jan 10 12:04:01 2014 -0800
+++ b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java	Mon Jan 13 08:41:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -68,6 +68,7 @@
     private StageStyle style;
     private GlassStage owner = null;
     private Modality modality = Modality.NONE;
+    private final boolean securityDialog;
 
     private OverlayWarning warning = null;
     private boolean rtl = false;
@@ -104,10 +105,11 @@
                                  ".QuantumMessagesBundle", LOCALE);
 
 
-    public WindowStage(javafx.stage.Window peerWindow, final StageStyle stageStyle, Modality modality, TKStage owner) {
+    public WindowStage(javafx.stage.Window peerWindow, boolean securityDialog, final StageStyle stageStyle, Modality modality, TKStage owner) {
         this.style = stageStyle;
         this.owner = (GlassStage)owner;
         this.modality = modality;
+        this.securityDialog = securityDialog;
 
         if (peerWindow instanceof javafx.stage.Stage) {
             fxStage = (Stage)peerWindow;
@@ -135,6 +137,10 @@
         isPopupStage = true;
     }
 
+    final boolean isSecurityDialog() {
+        return securityDialog;
+    }
+
     // Called by QuantumToolkit, so we can override initPlatformWindow in subclasses
     public final WindowStage init(GlassSystemMenu sysmenu) {
         initPlatformWindow();
@@ -190,6 +196,9 @@
                         app.createWindow(ownerWindow, Screen.getMainScreen(), windowMask);
                 platformWindow.setResizable(resizable);
                 platformWindow.setFocusable(focusable);
+                if (securityDialog) {
+                    platformWindow.setLevel(Window.Level.FLOATING);
+                }
             }
         }
         platformWindows.put(platformWindow, this);
--- a/modules/graphics/src/main/java/javafx/stage/Stage.java	Fri Jan 10 12:04:01 2014 -0800
+++ b/modules/graphics/src/main/java/javafx/stage/Stage.java	Mon Jan 13 08:41:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -180,6 +180,9 @@
             @Override public ObservableList<Stage> getStages() {
                 return stages;
             }
+            @Override public void initSecurityDialog(Stage stage, boolean securityDialog) {
+                stage.initSecurityDialog(securityDialog);
+            }
         });
     }
     
@@ -239,7 +242,7 @@
     @Override final public void setScene(Scene value) {
         super.setScene(value);
     }
-    
+
     /**
      * @inheritDoc
      */
@@ -249,6 +252,43 @@
     
     private boolean primary = false;
 
+    ////////////////////////////////////////////////////////////////////
+
+    // Flag indicating that this stage is being used to show a security dialog
+    private boolean securityDialog = false;
+
+    /**
+     * Sets a flag indicating that this stage is used for a security dialog and
+     * must always be on top. If set, this will cause the window to be always
+     * on top, regardless of the setting of the alwaysOnTop property, and
+     * whether or not all permissions are granted when the dialog is shown.
+     * NOTE: this flag must be set prior to showing the stage the first time.
+     *
+     * @param securityDialog flag indicating that this Stage is being used to
+     * show a security dialog that should be always-on-top
+     *
+     * @throws IllegalStateException if this property is set after the stage
+     * has ever been made visible.
+     *
+     * @defaultValue false
+     */
+    final void initSecurityDialog(boolean securityDialog) {
+        if (hasBeenVisible) {
+            throw new IllegalStateException("Cannot set securityDialog once stage has been set visible");
+        }
+
+        this.securityDialog = securityDialog;
+    }
+
+    /**
+     * Returns the state of the securityDialog flag.
+     *
+     * @return a flag indicating whether or not this is a security dialog
+     */
+    final boolean isSecurityDialog() {
+        return securityDialog;
+    }
+
     /**
      * sets this stage to be the primary stage.
      * When run as an applet, this stage will appear in the broswer
@@ -1056,7 +1096,7 @@
                     }
                 }
             }
-            impl_peer = toolkit.createTKStage(this, stageStyle, isPrimary(),
+            impl_peer = toolkit.createTKStage(this, isSecurityDialog(), stageStyle, isPrimary(),
                                               getModality(), tkStage, rtl, acc);
             impl_peer.setMinimumSize((int) Math.ceil(getMinWidth()),
                     (int) Math.ceil(getMinHeight()));
--- a/modules/graphics/src/test/java/com/sun/javafx/pgstub/StubToolkit.java	Fri Jan 10 12:04:01 2014 -0800
+++ b/modules/graphics/src/test/java/com/sun/javafx/pgstub/StubToolkit.java	Mon Jan 13 08:41:59 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -119,8 +119,7 @@
     }
 
     @Override
-    public TKStage createTKStage(Window peerWindow, StageStyle stageStyle, boolean primary,
-            Modality modality, TKStage owner, boolean rtl, AccessControlContext acc) {
+    public TKStage createTKStage(Window peerWindow, boolean securityDialog, StageStyle stageStyle, boolean primary, Modality modality, TKStage owner, boolean rtl, AccessControlContext acc) {
 
         return new StubStage();
     }