changeset 4265:f05164caa490

7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail Reviewed-by: dcherepanov, dav, art, denis
author serb
date Mon, 30 May 2011 17:16:21 +0400
parents eab94f59b6dc
children b955226868af
files src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java
diffstat 1 files changed, 27 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java	Mon May 30 13:25:02 2011 +0400
+++ b/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java	Mon May 30 17:16:21 2011 +0400
@@ -29,8 +29,6 @@
 import java.awt.peer.FileDialogPeer;
 import java.io.File;
 import java.io.FilenameFilter;
-import javax.swing.SwingUtilities;
-import javax.swing.SwingWorker;
 import sun.awt.AWTAccessor;
 
 /**
@@ -107,9 +105,7 @@
             if (b) {
                 Thread t = new Thread() {
                     public void run() {
-                        GtkFileDialogPeer.this.run(fd.getTitle(), fd.getMode(),
-                                   fd.getDirectory(), fd.getFile(), fd.getFilenameFilter(), fd.isMultipleMode(),
-                                   fd.getX(), fd.getY());
+                        showNativeDialog();
                         fd.setVisible(false);
                     }
                 };
@@ -146,4 +142,30 @@
         // We do not implement this method because we
         // have delegated to FileDialog#setFilenameFilter
     }
+
+    private void showNativeDialog() {
+        String dirname = fd.getDirectory();
+        // File path has a priority against directory path.
+        String filename = fd.getFile();
+        if (filename != null) {
+            final File file = new File(filename);
+            if (fd.getMode() == FileDialog.LOAD
+                && dirname != null
+                && file.getParent() == null) {
+                // File path for gtk_file_chooser_set_filename.
+                filename = dirname + (dirname.endsWith(File.separator) ? "" :
+                                              File.separator) + filename;
+            }
+            if (fd.getMode() == FileDialog.SAVE && file.getParent() != null) {
+                // Filename for gtk_file_chooser_set_current_name.
+                filename = file.getName();
+                // Directory path for gtk_file_chooser_set_current_folder.
+                dirname = file.getParent();
+            }
+        }
+        GtkFileDialogPeer.this.run(fd.getTitle(), fd.getMode(), dirname,
+                                   filename, fd.getFilenameFilter(),
+                                   fd.isMultipleMode(), fd.getX(), fd.getY());
+    }
+
 }