01: /*
02: * @(#)QtFileDialogPeer.java 1.17 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: package sun.awt.qt;
28:
29: import java.awt.*;
30: import sun.awt.peer.*;
31: import java.io.*;
32:
33: /**
34: *
35: *
36: * @author Nicholas Allen
37: */
38:
39: class QtFileDialogPeer extends QtDialogPeer implements FileDialogPeer {
40: private static native void initIDs();
41:
42: static {
43: initIDs();
44: }
45:
46: /** Creates a new QtFileDialogPeer. */
47:
48: QtFileDialogPeer(QtToolkit toolkit, FileDialog target) {
49: super (toolkit, target);
50:
51: String dir = target.getDirectory();
52: String file = target.getFile();
53:
54: if (dir != null)
55: setDirectory(dir);
56:
57: if (file != null)
58: setFile(file);
59: }
60:
61: protected native void create(QtComponentPeer parentPeer,
62: boolean isUndecorated);
63:
64: protected void create(QtComponentPeer parentPeer) {
65: create(parentPeer, ((FileDialog) target).isUndecorated());
66: }
67:
68: private native void setFileNative(String file);
69:
70: private native void setDirectoryNative(String dir);
71:
72: public native void showNative();
73:
74: public void show() {
75: // 6224133.
76: // No longer needed.
77: // toolkit.setRun(true);
78: // 6224133.
79: Rectangle bounds = target.getBounds();
80: setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
81: showNative();
82: }
83:
84: public void setFile(String file) {
85: if (file != null)
86: setFileNative(file);
87: }
88:
89: public void setDirectory(String dir) {
90: if (dir != null)
91: setDirectoryNative(dir);
92: }
93:
94: /** This feature cannot be supported as Qt does not have calling back for its filter support.
95: Instead one must provide a list of file name patterns. */
96:
97: public void setFilenameFilter(FilenameFilter filter) {
98: }
99: }
|