6959174: Need to introduce sun.awt.disableGtkFileDialogs system property
authordcherepanov
Wed, 07 Jul 2010 14:20:22 +0400
changeset 5944 1041870341a8
parent 5943 240bcabaca0f
child 5945 873dcaf7fa0a
6959174: Need to introduce sun.awt.disableGtkFileDialogs system property Reviewed-by: art, anthony
jdk/src/share/classes/sun/awt/SunToolkit.java
jdk/src/solaris/classes/sun/awt/X11/XToolkit.java
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java	Tue Jul 06 18:23:09 2010 +0400
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java	Wed Jul 07 14:20:22 2010 +0400
@@ -1944,6 +1944,25 @@
         return (Window)comp;
     }
 
+    /**
+     * Returns the value of the system property indicated by the specified key.
+     */
+    public static String getSystemProperty(final String key) {
+        return (String)AccessController.doPrivileged(new PrivilegedAction() {
+                public Object run() {
+                    return System.getProperty(key);
+                }
+            });
+    }
+
+    /**
+     * Returns the boolean value of the system property indicated by the specified key.
+     */
+    protected static Boolean getBooleanSystemProperty(String key) {
+        return Boolean.valueOf(AccessController.
+                   doPrivileged(new GetBooleanAction(key)));
+    }
+
     private static Boolean sunAwtDisableMixing = null;
 
     /**
@@ -1952,9 +1971,7 @@
      */
     public synchronized static boolean getSunAwtDisableMixing() {
         if (sunAwtDisableMixing == null) {
-            sunAwtDisableMixing = Boolean.valueOf(
-                    AccessController.doPrivileged(
-                        new GetBooleanAction("sun.awt.disableMixing")));
+            sunAwtDisableMixing = getBooleanSystemProperty("sun.awt.disableMixing");
         }
         return sunAwtDisableMixing.booleanValue();
     }
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Tue Jul 06 18:23:09 2010 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Wed Jul 07 14:20:22 2010 +0400
@@ -1053,10 +1053,28 @@
         return peer;
     }
 
+    private static Boolean sunAwtDisableGtkFileDialogs = null;
+
+    /**
+     * Returns the value of "sun.awt.disableGtkFileDialogs" property. Default
+     * value is {@code false}.
+     */
+    public synchronized static boolean getSunAwtDisableGtkFileDialogs() {
+        if (sunAwtDisableGtkFileDialogs == null) {
+            sunAwtDisableGtkFileDialogs =
+                getBooleanSystemProperty("sun.awt.disableGtkFileDialogs");
+        }
+        return sunAwtDisableGtkFileDialogs.booleanValue();
+    }
+
     public FileDialogPeer createFileDialog(FileDialog target) {
+        FileDialogPeer peer = null;
         // The current GtkFileChooser is available from GTK+ 2.4
-        FileDialogPeer peer = checkGtkVersion(2, 4, 0) ? new GtkFileDialogPeer(
-                target) : new XFileDialogPeer(target);
+        if (!getSunAwtDisableGtkFileDialogs() && checkGtkVersion(2, 4, 0)) {
+            peer = new GtkFileDialogPeer(target);
+        } else {
+            peer = new XFileDialogPeer(target);
+        }
         targetCreatedPeer(target, peer);
         return peer;
     }
@@ -1201,14 +1219,6 @@
         }
     }
 
-    static String getSystemProperty(final String name) {
-        return (String)AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
-                    return System.getProperty(name);
-                }
-            });
-    }
-
     public PrintJob getPrintJob(final Frame frame, final String doctitle,
                                 final Properties props) {