Mercurial > projects > dwt-addons
comparison dwtx/jface/preference/FileFieldEditor.d @ 97:0168c579a3f9
Fix path handling, thanks yidabu for reporting.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 01 Aug 2008 07:06:52 +0200 |
parents | 46a6e0e6ccd4 |
children |
comparison
equal
deleted
inserted
replaced
96:b492ba44e44d | 97:0168c579a3f9 |
---|---|
20 import dwt.widgets.FileDialog; | 20 import dwt.widgets.FileDialog; |
21 import dwtx.jface.resource.JFaceResources; | 21 import dwtx.jface.resource.JFaceResources; |
22 | 22 |
23 import dwt.dwthelper.utils; | 23 import dwt.dwthelper.utils; |
24 import tango.io.FilePath; | 24 import tango.io.FilePath; |
25 static import tango.io.Path; | |
25 import tango.io.FileSystem; | 26 import tango.io.FileSystem; |
26 | 27 |
27 /** | 28 /** |
28 * A field editor for a file path type preference. A standard file | 29 * A field editor for a file path type preference. A standard file |
29 * dialog appears when the user presses the change button. | 30 * dialog appears when the user presses the change button. |
100 /* (non-Javadoc) | 101 /* (non-Javadoc) |
101 * Method declared on StringButtonFieldEditor. | 102 * Method declared on StringButtonFieldEditor. |
102 * Opens the file chooser dialog and returns the selected file. | 103 * Opens the file chooser dialog and returns the selected file. |
103 */ | 104 */ |
104 protected override String changePressed() { | 105 protected override String changePressed() { |
105 auto f = new FilePath(getTextControl().getText()); | 106 auto f = new FilePath(tango.io.Path.standard(getTextControl().getText())); |
106 if (!f.exists()) { | 107 if (!f.exists()) { |
107 f = cast(FilePath)null; | 108 f = cast(FilePath)null; |
108 } | 109 } |
109 auto d = getFile(f); | 110 auto d = getFile(f); |
110 if (d is null) { | 111 if (d is null) { |
131 if (path.length is 0) { | 132 if (path.length is 0) { |
132 if (!isEmptyStringAllowed()) { | 133 if (!isEmptyStringAllowed()) { |
133 msg = getErrorMessage(); | 134 msg = getErrorMessage(); |
134 } | 135 } |
135 } else { | 136 } else { |
136 auto file = new FilePath(path); | 137 auto file = new FilePath(tango.io.Path.standard(path)); |
137 if (/+file.isFile()+/ file.exists && !file.isFolder ) { | 138 if (/+file.isFile()+/ file.exists && !file.isFolder ) { |
138 if (enforceAbsolute && !file.isAbsolute()) { | 139 if (enforceAbsolute && !file.isAbsolute()) { |
139 msg = JFaceResources | 140 msg = JFaceResources |
140 .getString("FileFieldEditor.errorMessage2");//$NON-NLS-1$ | 141 .getString("FileFieldEditor.errorMessage2");//$NON-NLS-1$ |
141 } | 142 } |
171 } | 172 } |
172 String file = dialog.open(); | 173 String file = dialog.open(); |
173 if (file !is null) { | 174 if (file !is null) { |
174 file = file.trim(); | 175 file = file.trim(); |
175 if (file.length > 0) { | 176 if (file.length > 0) { |
176 return new FilePath(file); | 177 return new FilePath(tango.io.Path.standard(file)); |
177 } | 178 } |
178 } | 179 } |
179 | 180 |
180 return null; | 181 return null; |
181 } | 182 } |