jdk/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java
author dcherepanov
Wed, 16 May 2012 13:15:27 +0400
changeset 12653 07d5ca30e79e
parent 11503 c40240392a01
child 23010 6dadb192ad81
child 23254 cfd1819394cd
permissions -rw-r--r--
7124337: [macosx] FileDialog fails to select multiple files Reviewed-by: anthony, swingler
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 8513
diff changeset
     2
 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
     4
 *
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5444
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5444
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    10
 *
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    15
 * accompanied this code).
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    16
 *
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5444
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5444
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5444
diff changeset
    23
 * questions.
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    24
 */
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    25
package sun.awt.X11;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    26
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    27
import java.awt.Dialog;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    28
import java.awt.FileDialog;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    29
import java.awt.peer.FileDialogPeer;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    30
import java.io.File;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    31
import java.io.FilenameFilter;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    32
import sun.awt.AWTAccessor;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    33
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    34
/**
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    35
 * FileDialogPeer for the GtkFileChooser.
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    36
 *
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    37
 * @author Costantino Cerbo (c.cerbo@gmail.com)
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    38
 */
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    39
class GtkFileDialogPeer extends XDialogPeer implements FileDialogPeer {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    40
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    41
    private FileDialog fd;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    42
7150
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    43
    // A pointer to the native GTK FileChooser widget
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    44
    private volatile long widget = 0L;
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    45
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    46
    public GtkFileDialogPeer(FileDialog fd) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    47
        super((Dialog) fd);
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    48
        this.fd = fd;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    49
    }
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    50
7150
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    51
    private static native void initIDs();
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    52
    static {
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    53
        initIDs();
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    54
    }
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    55
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    56
    private native void run(String title, int mode, String dir, String file,
8513
101b3095ff5a 7009114: GTK FileDialog lies about it's Bounds
dcherepanov
parents: 7243
diff changeset
    57
                            FilenameFilter filter, boolean isMultipleMode, int x, int y);
7243
4678eab93673 6998592: FileDialog tests crashed on solaris
anthony
parents: 7150
diff changeset
    58
    private native void quit();
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    59
7243
4678eab93673 6998592: FileDialog tests crashed on solaris
anthony
parents: 7150
diff changeset
    60
    @Override
4678eab93673 6998592: FileDialog tests crashed on solaris
anthony
parents: 7150
diff changeset
    61
    public native void toFront();
4678eab93673 6998592: FileDialog tests crashed on solaris
anthony
parents: 7150
diff changeset
    62
8513
101b3095ff5a 7009114: GTK FileDialog lies about it's Bounds
dcherepanov
parents: 7243
diff changeset
    63
    @Override
101b3095ff5a 7009114: GTK FileDialog lies about it's Bounds
dcherepanov
parents: 7243
diff changeset
    64
    public native void setBounds(int x, int y, int width, int height, int op);
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    65
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    66
    /**
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    67
     * Called exclusively by the native C code.
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    68
     */
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    69
    private void setFileInternal(String directory, String[] filenames) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    70
        AWTAccessor.FileDialogAccessor accessor = AWTAccessor
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    71
                .getFileDialogAccessor();
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    72
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    73
        if (filenames == null) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    74
            accessor.setDirectory(fd, null);
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    75
            accessor.setFile(fd, null);
12653
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    76
            accessor.setFiles(fd, null);
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    77
        } else {
6644
ee35bd1e91f9 6987233: FileDialog.getDirectory() should add a trainling slash when GTK FileDialog is used
anthony
parents: 5506
diff changeset
    78
            // Fix 6987233: add the trailing slash if it's absent
11503
c40240392a01 7130662: GTK file dialog crashes with a NPE
anthony
parents: 9766
diff changeset
    79
            String with_separator = directory;
c40240392a01 7130662: GTK file dialog crashes with a NPE
anthony
parents: 9766
diff changeset
    80
            if (directory != null) {
c40240392a01 7130662: GTK file dialog crashes with a NPE
anthony
parents: 9766
diff changeset
    81
                with_separator = directory.endsWith(File.separator) ?
c40240392a01 7130662: GTK file dialog crashes with a NPE
anthony
parents: 9766
diff changeset
    82
                        directory : (directory + File.separator);
c40240392a01 7130662: GTK file dialog crashes with a NPE
anthony
parents: 9766
diff changeset
    83
            }
c40240392a01 7130662: GTK file dialog crashes with a NPE
anthony
parents: 9766
diff changeset
    84
            accessor.setDirectory(fd, with_separator);
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    85
            accessor.setFile(fd, filenames[0]);
12653
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    86
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    87
            int filesNumber = (filenames != null) ? filenames.length : 0;
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    88
            File[] files = new File[filesNumber];
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    89
            for (int i = 0; i < filesNumber; i++) {
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    90
                files[i] = new File(directory, filenames[i]);
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    91
            }
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    92
            accessor.setFiles(fd, files);
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    93
        }
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    94
    }
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    95
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    96
    /**
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    97
     * Called exclusively by the native C code.
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    98
     */
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    99
    private boolean filenameFilterCallback(String fullname) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   100
        if (fd.getFilenameFilter() == null) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   101
            // no filter, accept all.
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   102
            return true;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   103
        }
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   104
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   105
        File filen = new File(fullname);
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   106
        return fd.getFilenameFilter().accept(new File(filen.getParent()),
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   107
                filen.getName());
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   108
    }
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   109
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   110
    @Override
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   111
    public void setVisible(boolean b) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   112
        XToolkit.awtLock();
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   113
        try {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   114
            if (b) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   115
                Thread t = new Thread() {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   116
                    public void run() {
9766
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   117
                        showNativeDialog();
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   118
                        fd.setVisible(false);
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   119
                    }
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   120
                };
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   121
                t.start();
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   122
            } else {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   123
                quit();
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   124
                fd.setVisible(false);
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   125
            }
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   126
        } finally {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   127
            XToolkit.awtUnlock();
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   128
        }
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   129
    }
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   130
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   131
    @Override
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   132
    public void dispose() {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   133
        quit();
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   134
        super.dispose();
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   135
    }
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   136
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   137
    @Override
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   138
    public void setDirectory(String dir) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   139
        // We do not implement this method because we
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   140
        // have delegated to FileDialog#setDirectory
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   141
    }
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   142
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   143
    @Override
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   144
    public void setFile(String file) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   145
        // We do not implement this method because we
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   146
        // have delegated to FileDialog#setFile
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   147
    }
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   148
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   149
    @Override
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   150
    public void setFilenameFilter(FilenameFilter filter) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   151
        // We do not implement this method because we
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   152
        // have delegated to FileDialog#setFilenameFilter
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   153
    }
9766
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   154
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   155
    private void showNativeDialog() {
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   156
        String dirname = fd.getDirectory();
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   157
        // File path has a priority against directory path.
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   158
        String filename = fd.getFile();
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   159
        if (filename != null) {
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   160
            final File file = new File(filename);
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   161
            if (fd.getMode() == FileDialog.LOAD
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   162
                && dirname != null
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   163
                && file.getParent() == null) {
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   164
                // File path for gtk_file_chooser_set_filename.
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   165
                filename = dirname + (dirname.endsWith(File.separator) ? "" :
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   166
                                              File.separator) + filename;
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   167
            }
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   168
            if (fd.getMode() == FileDialog.SAVE && file.getParent() != null) {
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   169
                // Filename for gtk_file_chooser_set_current_name.
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   170
                filename = file.getName();
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   171
                // Directory path for gtk_file_chooser_set_current_folder.
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   172
                dirname = file.getParent();
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   173
            }
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   174
        }
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   175
        GtkFileDialogPeer.this.run(fd.getTitle(), fd.getMode(), dirname,
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   176
                                   filename, fd.getFilenameFilter(),
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   177
                                   fd.isMultipleMode(), fd.getX(), fd.getY());
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   178
    }
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   179
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   180
}