jdk/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java
author darcy
Thu, 13 Mar 2014 12:40:27 -0700
changeset 23647 41d22f2dbeb5
parent 23328 4c53a6ebc779
permissions -rw-r--r--
8033712: Fix more serial lint warnings in sun.awt Reviewed-by: alanb, serb, prr
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
/*
23254
cfd1819394cd 8030987: sun_awt_X11_GtkFileDialogPeer.h can be removed
serb
parents: 12653
diff changeset
     2
 * Copyright (c) 2010, 2013, 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.FileDialog;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    28
import java.awt.peer.FileDialogPeer;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    29
import java.io.File;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    30
import java.io.FilenameFilter;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    31
import sun.awt.AWTAccessor;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    32
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
 * FileDialogPeer for the GtkFileChooser.
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    35
 *
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    36
 * @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
    37
 */
23254
cfd1819394cd 8030987: sun_awt_X11_GtkFileDialogPeer.h can be removed
serb
parents: 12653
diff changeset
    38
final class GtkFileDialogPeer extends XDialogPeer implements FileDialogPeer {
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    39
23254
cfd1819394cd 8030987: sun_awt_X11_GtkFileDialogPeer.h can be removed
serb
parents: 12653
diff changeset
    40
    private final FileDialog fd;
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    41
7150
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    42
    // A pointer to the native GTK FileChooser widget
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    43
    private volatile long widget = 0L;
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    44
23254
cfd1819394cd 8030987: sun_awt_X11_GtkFileDialogPeer.h can be removed
serb
parents: 12653
diff changeset
    45
    GtkFileDialogPeer(FileDialog fd) {
cfd1819394cd 8030987: sun_awt_X11_GtkFileDialogPeer.h can be removed
serb
parents: 12653
diff changeset
    46
        super(fd);
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    47
        this.fd = fd;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    48
    }
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    49
7150
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    50
    private static native void initIDs();
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    51
    static {
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    52
        initIDs();
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    53
    }
6c95b4f80a72 6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents: 6644
diff changeset
    54
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    55
    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
    56
                            FilenameFilter filter, boolean isMultipleMode, int x, int y);
7243
4678eab93673 6998592: FileDialog tests crashed on solaris
anthony
parents: 7150
diff changeset
    57
    private native void quit();
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    58
7243
4678eab93673 6998592: FileDialog tests crashed on solaris
anthony
parents: 7150
diff changeset
    59
    @Override
4678eab93673 6998592: FileDialog tests crashed on solaris
anthony
parents: 7150
diff changeset
    60
    public native void toFront();
4678eab93673 6998592: FileDialog tests crashed on solaris
anthony
parents: 7150
diff changeset
    61
8513
101b3095ff5a 7009114: GTK FileDialog lies about it's Bounds
dcherepanov
parents: 7243
diff changeset
    62
    @Override
101b3095ff5a 7009114: GTK FileDialog lies about it's Bounds
dcherepanov
parents: 7243
diff changeset
    63
    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
    64
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
     * 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
    67
     */
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    68
    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
    69
        AWTAccessor.FileDialogAccessor accessor = AWTAccessor
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    70
                .getFileDialogAccessor();
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    71
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    72
        if (filenames == null) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    73
            accessor.setDirectory(fd, null);
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    74
            accessor.setFile(fd, null);
12653
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    75
            accessor.setFiles(fd, null);
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    76
        } else {
6644
ee35bd1e91f9 6987233: FileDialog.getDirectory() should add a trainling slash when GTK FileDialog is used
anthony
parents: 5506
diff changeset
    77
            // 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
    78
            String with_separator = directory;
c40240392a01 7130662: GTK file dialog crashes with a NPE
anthony
parents: 9766
diff changeset
    79
            if (directory != null) {
c40240392a01 7130662: GTK file dialog crashes with a NPE
anthony
parents: 9766
diff changeset
    80
                with_separator = directory.endsWith(File.separator) ?
c40240392a01 7130662: GTK file dialog crashes with a NPE
anthony
parents: 9766
diff changeset
    81
                        directory : (directory + File.separator);
c40240392a01 7130662: GTK file dialog crashes with a NPE
anthony
parents: 9766
diff changeset
    82
            }
c40240392a01 7130662: GTK file dialog crashes with a NPE
anthony
parents: 9766
diff changeset
    83
            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
    84
            accessor.setFile(fd, filenames[0]);
12653
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    85
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    86
            int filesNumber = (filenames != null) ? filenames.length : 0;
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    87
            File[] files = new File[filesNumber];
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    88
            for (int i = 0; i < filesNumber; i++) {
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    89
                files[i] = new File(directory, filenames[i]);
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    90
            }
07d5ca30e79e 7124337: [macosx] FileDialog fails to select multiple files
dcherepanov
parents: 11503
diff changeset
    91
            accessor.setFiles(fd, files);
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    92
        }
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
     * 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
    97
     */
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    98
    private boolean filenameFilterCallback(String fullname) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
    99
        if (fd.getFilenameFilter() == null) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   100
            // no filter, accept all.
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   101
            return true;
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   102
        }
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
        File filen = new File(fullname);
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   105
        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
   106
                filen.getName());
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   107
    }
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
    @Override
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   110
    public void setVisible(boolean b) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   111
        XToolkit.awtLock();
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   112
        try {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   113
            if (b) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   114
                Thread t = new Thread() {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   115
                    public void run() {
9766
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   116
                        showNativeDialog();
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   117
                        fd.setVisible(false);
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   118
                    }
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
                t.start();
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   121
            } else {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   122
                quit();
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   123
                fd.setVisible(false);
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   124
            }
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   125
        } finally {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   126
            XToolkit.awtUnlock();
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   127
        }
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
    @Override
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   131
    public void dispose() {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   132
        quit();
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   133
        super.dispose();
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   134
    }
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
    @Override
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   137
    public void setDirectory(String dir) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   138
        // 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
   139
        // have delegated to FileDialog#setDirectory
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   140
    }
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
    @Override
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   143
    public void setFile(String file) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   144
        // 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
   145
        // have delegated to FileDialog#setFile
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   146
    }
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
    @Override
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   149
    public void setFilenameFilter(FilenameFilter filter) {
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   150
        // 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
   151
        // have delegated to FileDialog#setFilenameFilter
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   152
    }
9766
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   153
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   154
    private void showNativeDialog() {
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   155
        String dirname = fd.getDirectory();
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   156
        // File path has a priority against directory path.
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   157
        String filename = fd.getFile();
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   158
        if (filename != null) {
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   159
            final File file = new File(filename);
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   160
            if (fd.getMode() == FileDialog.LOAD
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   161
                && dirname != null
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   162
                && file.getParent() == null) {
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   163
                // File path for gtk_file_chooser_set_filename.
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   164
                filename = dirname + (dirname.endsWith(File.separator) ? "" :
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   165
                                              File.separator) + filename;
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   166
            }
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   167
            if (fd.getMode() == FileDialog.SAVE && file.getParent() != null) {
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   168
                // Filename for gtk_file_chooser_set_current_name.
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   169
                filename = file.getName();
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   170
                // Directory path for gtk_file_chooser_set_current_folder.
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   171
                dirname = file.getParent();
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   172
            }
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   173
        }
23254
cfd1819394cd 8030987: sun_awt_X11_GtkFileDialogPeer.h can be removed
serb
parents: 12653
diff changeset
   174
        run(fd.getTitle(), fd.getMode(), dirname, filename,
cfd1819394cd 8030987: sun_awt_X11_GtkFileDialogPeer.h can be removed
serb
parents: 12653
diff changeset
   175
            fd.getFilenameFilter(), fd.isMultipleMode(), fd.getX(), fd.getY());
9766
bf57566e576d 7045193: interactive JCK tests java_awt/interactive/FileDialogTests fail
serb
parents: 9035
diff changeset
   176
    }
5444
f7c5aeb82a14 6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff changeset
   177
}