author | Claus Gittinger <cg@exept.de> |
Wed, 08 Aug 2018 14:17:49 +0200 | |
changeset 5872 | 798ab0cedaeb |
parent 5569 | 73812d992757 |
child 5954 | 3c254cdfdfbc |
permissions | -rw-r--r-- |
3318 | 1 |
" |
2 |
COPYRIGHT (c) 2007 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
3251 | 12 |
"{ Package: 'stx:libwidg2' }" |
13 |
||
4708
adabb83e93bf
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4330
diff
changeset
|
14 |
"{ NameSpace: Smalltalk }" |
adabb83e93bf
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4330
diff
changeset
|
15 |
|
3251 | 16 |
SimpleView subclass:#FilenameWidgetWithHistory |
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
17 |
instanceVariableNames:'fileNameEntryField browseButton history directoriesOnly filesOnly |
5872 | 18 |
dialogTitle initialDirectoryHolder baseDirectory |
19 |
fileNameTranslationHook' |
|
3251 | 20 |
classVariableNames:'' |
21 |
poolDictionaries:'' |
|
22 |
category:'Views-Interactors' |
|
23 |
! |
|
24 |
||
25 |
!FilenameWidgetWithHistory class methodsFor:'documentation'! |
|
26 |
||
3318 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 2007 by eXept Software AG |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
3471 | 41 |
documentation |
42 |
" |
|
43 |
A Filename InputField with history-list and a browse-button, which opens a file dialog. |
|
44 |
||
45 |
[author:] |
|
46 |
Claus Gittinger |
|
47 |
||
48 |
[see also:] |
|
49 |
ComboBoxView |
|
50 |
FilenameEditField |
|
51 |
FilenameComboBoxView |
|
52 |
" |
|
53 |
! |
|
54 |
||
3251 | 55 |
examples |
56 |
" |
|
57 |
[exBegin] |
|
58 |
|top b| |
|
59 |
||
60 |
top := StandardSystemView new. |
|
61 |
top extent:(300 @ 200). |
|
62 |
||
63 |
b := FilenameWidgetWithHistory in:top. |
|
64 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
65 |
b bottomInset:(b preferredExtent y negated). |
|
66 |
||
67 |
top open. |
|
68 |
[exEnd] |
|
69 |
" |
|
70 |
! ! |
|
71 |
||
72 |
!FilenameWidgetWithHistory methodsFor:'accessing'! |
|
73 |
||
3950 | 74 |
acceptOnExpand:aBoolean |
75 |
fileNameEntryField acceptOnExpand:aBoolean |
|
76 |
||
77 |
"Created: / 20-10-2010 / 17:49:54 / cg" |
|
78 |
! |
|
79 |
||
3959 | 80 |
baseDirectory |
81 |
^ baseDirectory |
|
82 |
! |
|
83 |
||
84 |
baseDirectory:something |
|
85 |
baseDirectory := something. |
|
86 |
! |
|
87 |
||
3950 | 88 |
contents |
89 |
^ fileNameEntryField contents |
|
90 |
||
91 |
"Created: / 20-10-2010 / 17:51:07 / cg" |
|
92 |
! |
|
93 |
||
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
94 |
dialogTitle:something |
5569 | 95 |
"set the dialog's title" |
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
96 |
|
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
97 |
dialogTitle := something. |
5569 | 98 |
|
99 |
"Modified (comment): / 03-08-2017 / 14:39:00 / cg" |
|
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
100 |
! |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
101 |
|
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
102 |
directoriesOnly:aBoolean |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
103 |
"if true, directories are selectable only. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
104 |
If both filesOnly and directoriesOnly are false, which is the default, |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
105 |
anything is selectable." |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
106 |
|
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
107 |
directoriesOnly := aBoolean. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
108 |
directoriesOnly ifTrue:[ |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
109 |
filesOnly := false. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
110 |
]. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
111 |
fileNameEntryField notNil ifTrue:[ |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
112 |
fileNameEntryField directoriesOnly:aBoolean |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
113 |
]. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
114 |
! |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
115 |
|
5872 | 116 |
fileNameTranslationHook |
117 |
^ fileNameTranslationHook |
|
118 |
! |
|
119 |
||
120 |
fileNameTranslationHook:aBlock |
|
121 |
"an optional hook which gets the filename from the editField |
|
122 |
and produces a full path for the file dialog (in the ...-button). |
|
123 |
Use this, if the filename contains $(xxx) variables to be expanded" |
|
124 |
||
125 |
fileNameTranslationHook := aBlock. |
|
126 |
! |
|
127 |
||
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
128 |
filesOnly:aBoolean |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
129 |
"if true, files are selectable only. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
130 |
If both filesOnly and directoriesOnly are false, which is the default, |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
131 |
anything is selectable." |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
132 |
|
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
133 |
filesOnly := aBoolean. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
134 |
filesOnly ifTrue:[ |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
135 |
directoriesOnly := false. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
136 |
]. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
137 |
fileNameEntryField notNil ifTrue:[ |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
138 |
fileNameEntryField filesOnly:aBoolean |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
139 |
]. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
140 |
! |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
141 |
|
3251 | 142 |
historyList |
3474 | 143 |
history isNil ifTrue:[ |
4708
adabb83e93bf
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4330
diff
changeset
|
144 |
history := ValueHolder with:nil |
3474 | 145 |
]. |
146 |
^ history |
|
3251 | 147 |
! |
148 |
||
4798
88362e198319
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4797
diff
changeset
|
149 |
historyList:aCollection |
3593 | 150 |
"set the history - useful when two or more such fields shall share a common history" |
151 |
||
4798
88362e198319
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4797
diff
changeset
|
152 |
self historyList value: aCollection |
3593 | 153 |
! |
154 |
||
3594 | 155 |
initialDirectoryHolder |
156 |
"can be used to force the file-dialog into some initial directory" |
|
157 |
||
158 |
^ initialDirectoryHolder |
|
159 |
! |
|
160 |
||
3251 | 161 |
model |
162 |
^ fileNameEntryField model |
|
163 |
! |
|
164 |
||
165 |
model:aFilenameHolder |
|
166 |
fileNameEntryField model:aFilenameHolder. |
|
3950 | 167 |
! |
168 |
||
169 |
selectAllInitially |
|
170 |
fileNameEntryField selectAllInitially |
|
171 |
||
172 |
"Created: / 20-10-2010 / 17:50:23 / cg" |
|
3251 | 173 |
! ! |
174 |
||
3546 | 175 |
!FilenameWidgetWithHistory methodsFor:'accessing-channels'! |
176 |
||
4797
b145bd0e466d
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4721
diff
changeset
|
177 |
acceptChannel:aValueHolder |
b145bd0e466d
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4721
diff
changeset
|
178 |
fileNameEntryField acceptChannel:aValueHolder. |
b145bd0e466d
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4721
diff
changeset
|
179 |
! |
b145bd0e466d
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4721
diff
changeset
|
180 |
|
5336 | 181 |
backgroundChannel |
182 |
^ fileNameEntryField backgroundChannel |
|
183 |
||
184 |
"Created: / 17-11-2016 / 21:34:10 / cg" |
|
185 |
! |
|
186 |
||
5335 | 187 |
backgroundChannel:aValueHolder |
188 |
fileNameEntryField backgroundChannel:aValueHolder. |
|
189 |
||
190 |
"Created: / 17-11-2016 / 21:32:04 / cg" |
|
191 |
! |
|
192 |
||
3546 | 193 |
enableChannel:aValueHolder |
194 |
fileNameEntryField enableChannel:aValueHolder. |
|
195 |
browseButton enableChannel:aValueHolder. |
|
4084 | 196 |
! |
197 |
||
5336 | 198 |
foregroundChannel |
199 |
^ fileNameEntryField foregroundChannel |
|
200 |
||
201 |
"Created: / 17-11-2016 / 21:34:17 / cg" |
|
202 |
! |
|
203 |
||
5335 | 204 |
foregroundChannel:aValueHolder |
205 |
fileNameEntryField foregroundChannel:aValueHolder. |
|
206 |
||
207 |
"Created: / 17-11-2016 / 21:32:11 / cg" |
|
208 |
! |
|
209 |
||
4084 | 210 |
modifiedChannel:aValueHolder |
211 |
fileNameEntryField modifiedChannel:aValueHolder. |
|
212 |
||
213 |
"Created: / 05-10-2011 / 14:59:48 / cg" |
|
3546 | 214 |
! ! |
215 |
||
216 |
!FilenameWidgetWithHistory methodsFor:'accessing-editField attributes'! |
|
3472 | 217 |
|
218 |
acceptIfUnchanged:aBoolean |
|
219 |
fileNameEntryField acceptIfUnchanged:aBoolean |
|
220 |
! |
|
221 |
||
222 |
acceptOnLeave:aBoolean |
|
223 |
fileNameEntryField acceptOnLeave:aBoolean |
|
224 |
! |
|
225 |
||
226 |
acceptOnLostFocus:aBoolean |
|
227 |
fileNameEntryField acceptOnLostFocus:aBoolean |
|
228 |
! |
|
229 |
||
230 |
acceptOnPointerLeave:aBoolean |
|
231 |
fileNameEntryField acceptOnPointerLeave:aBoolean |
|
232 |
! |
|
233 |
||
234 |
acceptOnReturn:aBoolean |
|
235 |
fileNameEntryField acceptOnReturn:aBoolean |
|
236 |
! |
|
237 |
||
238 |
acceptOnTab:aBoolean |
|
239 |
fileNameEntryField acceptOnTab:aBoolean |
|
240 |
! |
|
241 |
||
242 |
contents:aString |
|
243 |
fileNameEntryField contents:aString |
|
244 |
! |
|
245 |
||
246 |
immediateAccept:aBoolean |
|
247 |
fileNameEntryField immediateAccept:aBoolean |
|
248 |
! |
|
249 |
||
250 |
maxChars:aBoolean |
|
251 |
fileNameEntryField maxChars:aBoolean |
|
252 |
! |
|
253 |
||
254 |
readOnly:aBoolean |
|
255 |
fileNameEntryField readOnly:aBoolean |
|
256 |
! ! |
|
257 |
||
3251 | 258 |
!FilenameWidgetWithHistory methodsFor:'initialization'! |
259 |
||
260 |
initialize |
|
261 |
super initialize. |
|
262 |
||
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
263 |
directoriesOnly := filesOnly := false. |
4708
adabb83e93bf
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4330
diff
changeset
|
264 |
initialDirectoryHolder := ValueHolder with:nil. |
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
265 |
|
3940
705b77e37f67
added: #initializeFilenameField
Claus Gittinger <cg@exept.de>
parents:
3700
diff
changeset
|
266 |
self initializeFilenameField. |
3251 | 267 |
fileNameEntryField layout:(LayoutFrame |
268 |
leftFraction:0 offset:0 |
|
269 |
rightFraction:1 offset:-22 |
|
270 |
topFraction:0 offset:0 |
|
271 |
bottomFraction:1 offset:0). |
|
272 |
||
3959 | 273 |
self initializeBrowseButton. |
3251 | 274 |
browseButton layout:(LayoutFrame |
275 |
leftFraction:1 offset:-22 |
|
276 |
rightFraction:1 offset:-2 |
|
277 |
topFraction:0 offset:0 |
|
278 |
bottomFraction:1 offset:0). |
|
3940
705b77e37f67
added: #initializeFilenameField
Claus Gittinger <cg@exept.de>
parents:
3700
diff
changeset
|
279 |
|
3959 | 280 |
"Modified: / 02-11-2010 / 19:50:33 / cg" |
281 |
! |
|
282 |
||
283 |
initializeBrowseButton |
|
284 |
browseButton := Button in:self. |
|
285 |
browseButton label:'...'. |
|
286 |
browseButton action:[ self browseForFileOrDirectory ]. |
|
287 |
||
288 |
"Created: / 02-11-2010 / 19:50:21 / cg" |
|
3940
705b77e37f67
added: #initializeFilenameField
Claus Gittinger <cg@exept.de>
parents:
3700
diff
changeset
|
289 |
! |
705b77e37f67
added: #initializeFilenameField
Claus Gittinger <cg@exept.de>
parents:
3700
diff
changeset
|
290 |
|
705b77e37f67
added: #initializeFilenameField
Claus Gittinger <cg@exept.de>
parents:
3700
diff
changeset
|
291 |
initializeFilenameField |
705b77e37f67
added: #initializeFilenameField
Claus Gittinger <cg@exept.de>
parents:
3700
diff
changeset
|
292 |
fileNameEntryField := FilenameComboBoxView in:self. |
705b77e37f67
added: #initializeFilenameField
Claus Gittinger <cg@exept.de>
parents:
3700
diff
changeset
|
293 |
fileNameEntryField listHolder:(self historyList). |
705b77e37f67
added: #initializeFilenameField
Claus Gittinger <cg@exept.de>
parents:
3700
diff
changeset
|
294 |
|
705b77e37f67
added: #initializeFilenameField
Claus Gittinger <cg@exept.de>
parents:
3700
diff
changeset
|
295 |
"Created: / 19-10-2010 / 16:20:09 / cg" |
3251 | 296 |
! ! |
297 |
||
298 |
!FilenameWidgetWithHistory methodsFor:'queries'! |
|
299 |
||
300 |
preferredExtent |
|
3568
2f293d1e2eef
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3546
diff
changeset
|
301 |
"/ If I have an explicit preferredExtent.. |
2f293d1e2eef
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3546
diff
changeset
|
302 |
explicitExtent notNil ifTrue:[ |
2f293d1e2eef
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3546
diff
changeset
|
303 |
^ explicitExtent |
2f293d1e2eef
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3546
diff
changeset
|
304 |
]. |
2f293d1e2eef
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3546
diff
changeset
|
305 |
"/ If I have a cached preferredExtent value.. |
3251 | 306 |
preferredExtent notNil ifTrue:[ |
307 |
^ preferredExtent |
|
308 |
]. |
|
309 |
||
3427
9927e4970fce
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3318
diff
changeset
|
310 |
preferredExtent := (fileNameEntryField preferredWidth + browseButton preferredWidth) |
3251 | 311 |
@ |
3427
9927e4970fce
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3318
diff
changeset
|
312 |
(fileNameEntryField preferredHeight "max: browseButton preferredExtent y"). |
3251 | 313 |
^ preferredExtent |
314 |
! ! |
|
315 |
||
316 |
!FilenameWidgetWithHistory methodsFor:'user actions'! |
|
317 |
||
318 |
browseForDestinationDirectory |
|
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
319 |
<resource: #obsolete> |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
320 |
self obsoleteMethodWarning. |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
321 |
self browseForFileOrDirectory |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
322 |
! |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
323 |
|
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
324 |
browseForFileOrDirectory |
3594 | 325 |
|path | |
3251 | 326 |
|
4721
e3cb03ac761a
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4708
diff
changeset
|
327 |
Dialog modifyingBoxWith:[:box | |
4797
b145bd0e466d
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4721
diff
changeset
|
328 |
|holder| |
b145bd0e466d
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4721
diff
changeset
|
329 |
|
b145bd0e466d
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4721
diff
changeset
|
330 |
holder := box perform:#browsemenuItemVisibleHolder ifNotUnderstood:[nil]. |
b145bd0e466d
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4721
diff
changeset
|
331 |
holder notNil ifTrue:[ |
b145bd0e466d
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4721
diff
changeset
|
332 |
holder value:true |
b145bd0e466d
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4721
diff
changeset
|
333 |
] |
3251 | 334 |
] do:[ |
3594 | 335 |
|title defaultPath defaultDir| |
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
336 |
|
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
337 |
title := dialogTitle notNil |
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
338 |
ifTrue:[ dialogTitle ] |
3959 | 339 |
ifFalse:[ |
340 |
resources string:( |
|
341 |
directoriesOnly |
|
342 |
ifTrue:[ 'Select Directory' ] |
|
343 |
ifFalse:[ |
|
344 |
filesOnly |
|
345 |
ifTrue:[ 'Select File' ] |
|
346 |
ifFalse:[ 'Select Path' ]])]. |
|
3590
c3c778e11564
fixes (thanx to bretts info)
Claus Gittinger <cg@exept.de>
parents:
3568
diff
changeset
|
347 |
|
3950 | 348 |
defaultPath := (self model notNil) |
349 |
ifTrue:[ self model value ] |
|
350 |
ifFalse:[ fileNameEntryField contents ]. |
|
3959 | 351 |
|
4019
33b8c1b762cb
changed: #browseForFileOrDirectory
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
352 |
defaultPath notEmptyOrNil ifTrue:[ |
5872 | 353 |
fileNameTranslationHook notNil ifTrue:[ |
354 |
defaultPath := fileNameTranslationHook value:defaultPath |
|
355 |
]. |
|
4019
33b8c1b762cb
changed: #browseForFileOrDirectory
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
356 |
defaultPath asFilename isAbsolute ifFalse:[ |
33b8c1b762cb
changed: #browseForFileOrDirectory
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
357 |
baseDirectory notNil ifTrue:[ |
33b8c1b762cb
changed: #browseForFileOrDirectory
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
358 |
defaultPath := baseDirectory asFilename construct:defaultPath. |
33b8c1b762cb
changed: #browseForFileOrDirectory
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
359 |
]. |
3959 | 360 |
]. |
3594 | 361 |
defaultDir := defaultPath asFilename directory. |
362 |
] ifFalse:[ |
|
363 |
defaultDir := initialDirectoryHolder value. |
|
364 |
]. |
|
365 |
path := Dialog |
|
3954
e28b5c4fe0c9
comment/format in: #browseForFileOrDirectory
Claus Gittinger <cg@exept.de>
parents:
3953
diff
changeset
|
366 |
requestFileName:title |
e28b5c4fe0c9
comment/format in: #browseForFileOrDirectory
Claus Gittinger <cg@exept.de>
parents:
3953
diff
changeset
|
367 |
default:defaultPath |
e28b5c4fe0c9
comment/format in: #browseForFileOrDirectory
Claus Gittinger <cg@exept.de>
parents:
3953
diff
changeset
|
368 |
fromDirectory:defaultDir. |
3251 | 369 |
]. |
3594 | 370 |
path isEmptyOrNil ifTrue:[ ^ self ]. |
3953
370687d1030b
changed: #browseForFileOrDirectory
Stefan Vogel <sv@exept.de>
parents:
3950
diff
changeset
|
371 |
path := path asFilename. |
3251 | 372 |
|
3959 | 373 |
baseDirectory notNil ifTrue:[ |
374 |
(path pathName startsWith:baseDirectory asFilename pathName) ifTrue:[ |
|
375 |
path := (path pathName copyFrom:(baseDirectory asFilename pathName size + 2)) asFilename. |
|
376 |
]. |
|
377 |
]. |
|
378 |
||
3953
370687d1030b
changed: #browseForFileOrDirectory
Stefan Vogel <sv@exept.de>
parents:
3950
diff
changeset
|
379 |
initialDirectoryHolder value:path directory. |
370687d1030b
changed: #browseForFileOrDirectory
Stefan Vogel <sv@exept.de>
parents:
3950
diff
changeset
|
380 |
path := path pathName. |
370687d1030b
changed: #browseForFileOrDirectory
Stefan Vogel <sv@exept.de>
parents:
3950
diff
changeset
|
381 |
|
3594 | 382 |
"/ lastDirectoryHolder value:path directory. |
3950 | 383 |
self model notNil ifTrue:[ |
384 |
self model value:path. |
|
385 |
]. |
|
386 |
fileNameEntryField contents:path. |
|
3251 | 387 |
|
4019
33b8c1b762cb
changed: #browseForFileOrDirectory
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
388 |
"Modified: / 08-02-2011 / 09:24:51 / cg" |
3251 | 389 |
! ! |
390 |
||
391 |
!FilenameWidgetWithHistory class methodsFor:'documentation'! |
|
392 |
||
393 |
version |
|
4797
b145bd0e466d
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4721
diff
changeset
|
394 |
^ '$Header$' |
3940
705b77e37f67
added: #initializeFilenameField
Claus Gittinger <cg@exept.de>
parents:
3700
diff
changeset
|
395 |
! |
705b77e37f67
added: #initializeFilenameField
Claus Gittinger <cg@exept.de>
parents:
3700
diff
changeset
|
396 |
|
705b77e37f67
added: #initializeFilenameField
Claus Gittinger <cg@exept.de>
parents:
3700
diff
changeset
|
397 |
version_CVS |
4797
b145bd0e466d
class: FilenameWidgetWithHistory
Claus Gittinger <cg@exept.de>
parents:
4721
diff
changeset
|
398 |
^ '$Header$' |
3251 | 399 |
! ! |
4330
69a2cba2229e
aboutToOpenBoxNotificationSignal semantic change (for Jan)
Claus Gittinger <cg@exept.de>
parents:
4084
diff
changeset
|
400 |