Mercurial > projects > dwt-addons
annotate dwtx/jface/preference/PathEditor.d @ 95:1088ca33d3e0 Release-1
Removed version=TANGOSVN for release 0.99.7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 26 Jul 2008 02:46:58 +0200 |
parents | dadb23ea55a6 |
children | 0168c579a3f9 |
rev | line source |
---|---|
34 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2006 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 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.jface.preference.PathEditor; | |
14 | |
15 import dwtx.jface.preference.ListEditor; | |
16 | |
17 import tango.io.FilePath; | |
95
1088ca33d3e0
Removed version=TANGOSVN for release 0.99.7
Frank Benoit <benoit@tionex.de>
parents:
94
diff
changeset
|
18 import tango.io.model.IFile; |
94 | 19 |
34 | 20 // import java.util.ArrayList; |
21 // import java.util.StringTokenizer; | |
22 | |
23 import dwt.widgets.Composite; | |
24 import dwt.widgets.DirectoryDialog; | |
25 | |
26 import dwt.dwthelper.utils; | |
27 import tango.text.Util; | |
28 | |
29 /** | |
30 * A field editor to edit directory paths. | |
31 */ | |
32 public class PathEditor : ListEditor { | |
33 | |
34 /** | |
35 * The last path, or <code>null</code> if none. | |
36 */ | |
37 private String lastPath; | |
38 | |
39 /** | |
40 * The special label text for directory chooser, | |
41 * or <code>null</code> if none. | |
42 */ | |
43 private String dirChooserLabelText; | |
44 | |
45 /** | |
46 * Creates a new path field editor | |
47 */ | |
48 protected this() { | |
49 } | |
50 | |
51 /** | |
52 * Creates a path field editor. | |
53 * | |
54 * @param name the name of the preference this field editor works on | |
55 * @param labelText the label text of the field editor | |
56 * @param dirChooserLabelText the label text displayed for the directory chooser | |
57 * @param parent the parent of the field editor's control | |
58 */ | |
59 public this(String name, String labelText, | |
60 String dirChooserLabelText, Composite parent) { | |
61 init(name, labelText); | |
62 this.dirChooserLabelText = dirChooserLabelText; | |
63 createControl(parent); | |
64 } | |
65 | |
66 /* (non-Javadoc) | |
67 * Method declared on ListEditor. | |
68 * Creates a single string from the given array by separating each | |
69 * string with the appropriate OS-specific path separator. | |
70 */ | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
34
diff
changeset
|
71 protected override String createList(String[] items) { |
34 | 72 StringBuffer path = new StringBuffer("");//$NON-NLS-1$ |
73 | |
74 for (int i = 0; i < items.length; i++) { | |
75 path.append(items[i]); | |
50 | 76 path.append(FileConst.SystemPathString); |
34 | 77 } |
78 return path.toString(); | |
79 } | |
80 | |
81 /* (non-Javadoc) | |
82 * Method declared on ListEditor. | |
83 * Creates a new path element by means of a directory dialog. | |
84 */ | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
34
diff
changeset
|
85 protected override String getNewInputObject() { |
34 | 86 |
87 DirectoryDialog dialog = new DirectoryDialog(getShell()); | |
88 if (dirChooserLabelText !is null) { | |
89 dialog.setMessage(dirChooserLabelText); | |
90 } | |
91 if (lastPath !is null) { | |
92 if ((new FilePath(lastPath)).exists()) { | |
93 dialog.setFilterPath(lastPath); | |
94 } | |
95 } | |
96 String dir = dialog.open(); | |
97 if (dir !is null) { | |
98 dir = dwt.dwthelper.utils.trim(dir); | |
99 if (dir.length is 0) { | |
100 return null; | |
101 } | |
102 lastPath = dir; | |
103 } | |
104 return dir; | |
105 } | |
106 | |
107 /* (non-Javadoc) | |
108 * Method declared on ListEditor. | |
109 */ | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
34
diff
changeset
|
110 protected override String[] parseString(String stringList) { |
50 | 111 return tango.text.Util.delimit(stringList.dup, FileConst.SystemPathString |
34 | 112 ~ "\n\r");//$NON-NLS-1$ |
113 } | |
114 } |