01: /*
02: * @(#)GFileDialogPeer.java 1.14 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: *
26: */
27:
28: package sun.awt.gtk;
29:
30: import java.awt.*;
31: import sun.awt.peer.*;
32: import java.io.*;
33:
34: /**
35: *
36: *
37: * @author Nicholas Allen
38: */
39:
40: class GFileDialogPeer extends GDialogPeer implements FileDialogPeer {
41: private static native void initIDs();
42:
43: static {
44: initIDs();
45: }
46:
47: /** Creates a new GFileDialogPeer. */
48:
49: GFileDialogPeer(GToolkit toolkit, FileDialog target) {
50: super (toolkit, target);
51: String dir = target.getDirectory();
52: String file = target.getFile(); // added for Bug #4700136
53: // first "if" block added for Bug #4700136
54: if ((dir != null) && (file != null)) {
55: if (dir.endsWith("/")) {
56: setFile(dir.concat(file));
57: } else {
58: String temp = dir.concat("/");
59: setFile(temp.concat(file));
60: }
61: } else if (dir != null) {
62: String temp = null; // added for Bug #4700136
63: // "if" block added for Bug #4700136
64: if (!dir.endsWith("/"))
65: temp = dir.concat("/");
66: else
67: temp = dir;
68: setDirectory(temp);
69: } else if ((dir = target.getFile()) != null) {
70: setFile(dir);
71: }
72: }
73:
74: protected native void create();
75:
76: private native void setFileNative(byte[] file);
77:
78: public void setFile(String file) {
79: if (file != null)
80: setFileNative(stringToNulMultiByte(file));
81: }
82:
83: public void setDirectory(String dir) {
84: if (dir != null)
85: setFileNative(stringToNulMultiByte(dir));
86: }
87:
88: /** This feature cannot be supported as Gtk does not have calling back for its filter support.
89: Instead one must provide a list of file name patterns. */
90:
91: public void setFilenameFilter(FilenameFilter filter) {
92: }
93: }
|