28
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * D Port:
|
|
11 * Jesse Phillips <Jesse.K.Phillips+D> gmail.com
|
|
12 *******************************************************************************/
|
|
13 module org.eclipse.swt.snippets.Snippet33;
|
|
14
|
|
15 /*
|
|
16 * DirectoryDialog example snippet: prompt for a directory
|
|
17 *
|
|
18 * For a list of all SWT example snippets see
|
|
19 * http://www.eclipse.org/swt/snippets/
|
|
20 */
|
|
21
|
|
22 import org.eclipse.swt.widgets.DirectoryDialog;
|
|
23 import org.eclipse.swt.widgets.Display;
|
|
24 import org.eclipse.swt.widgets.Shell;
|
112
|
25 import java.lang.all;
|
28
|
26
|
112
|
27 version(Tango){
|
|
28 import tango.sys.Environment;
|
|
29 import tango.io.Stdout;
|
|
30 import tango.util.Convert;
|
|
31 } else { // Phobos
|
|
32 import std.file;
|
|
33 import std.stdio;
|
|
34 import std.conv;
|
|
35 }
|
28
|
36
|
|
37 void main () {
|
|
38 auto display = new Display ();
|
|
39 auto shell = new Shell (display);
|
|
40 shell.open ();
|
|
41 auto dialog = new DirectoryDialog (shell);
|
112
|
42 version(Tango){
|
|
43 dialog.setFilterPath (Environment.cwd());
|
|
44 Stdout("RESULT=" ~ to!(String)(dialog.open())).newline;
|
|
45 } else {
|
|
46 dialog.setFilterPath (getcwd());
|
|
47 writeln("RESULT=" ~ to!(String)(dialog.open()));
|
|
48 }
|
28
|
49 while (!shell.isDisposed()) {
|
|
50 if (!display.readAndDispatch ()) display.sleep ();
|
|
51 }
|
|
52 display.dispose ();
|
|
53 }
|