5871
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2002 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 |
"
|
|
12 |
|
|
13 |
"{ Package: 'stx:libtool' }"
|
|
14 |
|
|
15 |
SimpleDialog subclass:#FileDialogV2
|
|
16 |
instanceVariableNames:'aspects directory pattern filterHolder initialText multipleSelect
|
|
17 |
doubleClickAction cancelLabelHolder okLabelHolder startFilename
|
|
18 |
result filterField filenameField viewFiles filenameLabelHolder
|
|
19 |
isLoadDialog newDirectoryVisibilityHolder
|
|
20 |
appendButtonVisibleHolder appendWasPressed
|
|
21 |
buttonPanelVisibleHolder appendLabelHolder contentsBrowser'
|
|
22 |
classVariableNames:''
|
|
23 |
poolDictionaries:''
|
|
24 |
category:'Interface-Tools-File'
|
|
25 |
!
|
|
26 |
|
|
27 |
!FileDialogV2 class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 2002 by eXept Software AG
|
|
32 |
All Rights Reserved
|
|
33 |
|
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
documentation
|
|
44 |
"
|
|
45 |
documentation to be added.
|
|
46 |
|
|
47 |
[author:]
|
|
48 |
Martin Walser (martin@vercingetorix)
|
|
49 |
|
|
50 |
[instance variables:]
|
|
51 |
|
|
52 |
[class variables:]
|
|
53 |
|
|
54 |
[see also:]
|
|
55 |
|
|
56 |
"
|
|
57 |
!
|
|
58 |
|
|
59 |
examples
|
|
60 |
"
|
|
61 |
[exBegin]
|
|
62 |
FileDialog open
|
|
63 |
[exEnd]
|
|
64 |
|
|
65 |
[exBegin]
|
|
66 |
FileDialog
|
|
67 |
requestFileName:'enter a fileName:'
|
|
68 |
default:''
|
|
69 |
version:nil
|
|
70 |
ifFail:['none']
|
|
71 |
pattern:'*.conf'
|
|
72 |
fromDirectory:'/etc'
|
|
73 |
whenBoxCreatedEvaluate:nil.
|
|
74 |
[exEnd]
|
|
75 |
[exBegin]
|
|
76 |
|fd|
|
|
77 |
|
|
78 |
fd := FileDialog new.
|
|
79 |
fd multipleSelect:true.
|
|
80 |
fd open
|
|
81 |
[exEnd]
|
|
82 |
"
|
|
83 |
!
|
|
84 |
|
|
85 |
todo
|
|
86 |
"
|
|
87 |
- make the filedialog windows like f
|
|
88 |
filename entry field shows only the filename not the whole directory
|
|
89 |
the tree allways starts in currrent directory
|
|
90 |
the parent tree is shown in a compobox where the perents are selectable
|
|
91 |
- do not expand the ~ or relative pathnames to absolute pathnames
|
|
92 |
"
|
|
93 |
! !
|
|
94 |
|
|
95 |
!FileDialogV2 class methodsFor:'instance creation'!
|
|
96 |
|
|
97 |
requestDirectoryName:title default:aFileName ifFail:failBlock
|
|
98 |
"same as requestFileName, but only show directories"
|
|
99 |
|
|
100 |
^ self
|
|
101 |
requestDirectoryName:title
|
|
102 |
default:aFileName
|
|
103 |
ok:nil
|
|
104 |
abort:nil
|
|
105 |
version:nil
|
|
106 |
pattern:nil
|
|
107 |
fromDirectory:nil
|
|
108 |
ifFail:failBlock
|
|
109 |
whenBoxCreatedEvaluate:nil
|
|
110 |
asLoadDialog:nil.
|
|
111 |
|
|
112 |
"
|
|
113 |
FileDialogV2
|
|
114 |
requestDirectoryName:'which directory ?'
|
|
115 |
default:Filename currentDirectory pathName
|
|
116 |
ifFail:'none'
|
|
117 |
"
|
|
118 |
!
|
|
119 |
|
|
120 |
requestDirectoryName:title default:aFileName ok:okText abort:abortText ifFail:failBlock
|
|
121 |
"same as requestFileName, but only show directories"
|
|
122 |
|
|
123 |
^ self
|
|
124 |
requestDirectoryName:title
|
|
125 |
default:aFileName
|
|
126 |
ok:okText
|
|
127 |
abort:abortText
|
|
128 |
version:nil
|
|
129 |
pattern:nil
|
|
130 |
fromDirectory:nil
|
|
131 |
ifFail:failBlock
|
|
132 |
whenBoxCreatedEvaluate:nil
|
|
133 |
asLoadDialog:nil.
|
|
134 |
|
|
135 |
"
|
|
136 |
FileDialog
|
|
137 |
requestDirectoryName:'which directory ?'
|
|
138 |
default:Filename currentDirectory pathName
|
|
139 |
ok:'Yes'
|
|
140 |
abort:'No'
|
|
141 |
ifFail:'none'
|
|
142 |
"
|
|
143 |
!
|
|
144 |
|
|
145 |
requestDirectoryName:title default:aFileName ok:okText abort:abortText ifFail:failBlock acceptReturnAsOK:aBoolean
|
|
146 |
"same as requestFileName, but only show directories"
|
|
147 |
|
|
148 |
^ self
|
|
149 |
requestDirectoryName:title
|
|
150 |
default:aFileName
|
|
151 |
ok:okText
|
|
152 |
abort:abortText
|
|
153 |
version:nil
|
|
154 |
pattern:nil
|
|
155 |
fromDirectory:nil
|
|
156 |
ifFail:failBlock
|
|
157 |
whenBoxCreatedEvaluate:[:box|box doubleClickAction:[:index|box doAccept]]
|
|
158 |
asLoadDialog:nil.
|
|
159 |
|
|
160 |
"
|
|
161 |
FileDialog
|
|
162 |
requestDirectoryName:'which directory ?'
|
|
163 |
default:Filename currentDirectory pathName
|
|
164 |
ok:'Yes'
|
|
165 |
abort:'No'
|
|
166 |
ifFail:'none'
|
|
167 |
"
|
|
168 |
!
|
|
169 |
|
|
170 |
requestDirectoryName:titleString default:aFileName ok:okText abort:abortText version:versionSymbol pattern:pattern fromDirectory:aDirectoryPath ifFail:failBlock whenBoxCreatedEvaluate:boxCreatedCallback asLoadDialog:aBoolean
|
|
171 |
"same as requestFileName, but only show directories"
|
|
172 |
|
|
173 |
|enteredFileName instance enteredFileNameString|
|
|
174 |
|
|
175 |
instance := self
|
|
176 |
startApplicationFor:titleString
|
|
177 |
default:aFileName
|
|
178 |
ok:okText
|
|
179 |
abort:abortText
|
|
180 |
ifFail:failBlock
|
|
181 |
pattern:pattern
|
|
182 |
fromDirectory:aDirectoryPath
|
|
183 |
whenBoxCreatedEvaluate:boxCreatedCallback
|
|
184 |
asLoadDialog:aBoolean
|
|
185 |
viewFiles:false
|
|
186 |
multipleSelect:false.
|
|
187 |
|
|
188 |
enteredFileNameString := instance result.
|
|
189 |
enteredFileNameString isNil ifTrue:[
|
|
190 |
^ failBlock value
|
|
191 |
].
|
|
192 |
enteredFileName := enteredFileNameString asFilename.
|
|
193 |
enteredFileNameString := enteredFileName asString.
|
|
194 |
(enteredFileName notNil
|
|
195 |
and:[enteredFileNameString notEmpty]) ifTrue:[
|
|
196 |
versionSymbol isNil ifTrue:[ ^ enteredFileNameString].
|
|
197 |
versionSymbol == #mustBeNew ifTrue:[
|
|
198 |
"/ file may not exist
|
|
199 |
enteredFileName exists ifTrue:[^ ''].
|
|
200 |
].
|
|
201 |
versionSymbol == #new ifTrue:[
|
|
202 |
"/ file may not exist
|
|
203 |
enteredFileName exists ifTrue:[
|
|
204 |
(Dialog confirm:(self classResources string:'''%1'' exists.\\Continue anyway ?' with:enteredFileNameString) withCRs)
|
|
205 |
ifFalse:[^ ''].
|
|
206 |
].
|
|
207 |
].
|
|
208 |
versionSymbol == #mustBeOld ifTrue:[
|
|
209 |
enteredFileName exists ifFalse:[^ ''].
|
|
210 |
].
|
|
211 |
versionSymbol == #old ifTrue:[
|
|
212 |
"/ file may not exist
|
|
213 |
enteredFileName exists ifFalse:[
|
|
214 |
(self confirm:(self classResources string:'''%1'' does not exist yet.\\Continue anyway ?' with:enteredFileNameString) withCRs)
|
|
215 |
ifFalse:[^ ''].
|
|
216 |
].
|
|
217 |
].
|
|
218 |
FileSelectionBox lastFileSelectionDirectory:(enteredFileNameString).
|
|
219 |
].
|
|
220 |
^ enteredFileNameString
|
|
221 |
|
|
222 |
"
|
|
223 |
FileDialog
|
|
224 |
requestDirectoryName:'which directory ?'
|
|
225 |
default:Filename currentDirectory pathName
|
|
226 |
ifFail:nil
|
|
227 |
"
|
|
228 |
"
|
|
229 |
FileDialog
|
|
230 |
requestDirectoryName:'which directory ?'
|
|
231 |
default:Filename currentDirectory pathName
|
|
232 |
ok:nil
|
|
233 |
abort:nil
|
|
234 |
version:nil
|
|
235 |
pattern:nil
|
|
236 |
fromDirectory:nil
|
|
237 |
ifFail:nil
|
|
238 |
whenBoxCreatedEvaluate:nil
|
|
239 |
asLoadDialog:true
|
|
240 |
"
|
|
241 |
!
|
|
242 |
|
|
243 |
requestDirectoryName:title default:aFileName ok:okText ifFail:failBlock
|
|
244 |
"same as requestFileName, but only show directories"
|
|
245 |
|
|
246 |
^ self
|
|
247 |
requestDirectoryName:title
|
|
248 |
default:aFileName
|
|
249 |
ok:okText
|
|
250 |
abort:nil
|
|
251 |
version:nil
|
|
252 |
pattern:nil
|
|
253 |
fromDirectory:nil
|
|
254 |
ifFail:failBlock
|
|
255 |
whenBoxCreatedEvaluate:nil
|
|
256 |
asLoadDialog:nil.
|
|
257 |
|
|
258 |
"
|
|
259 |
FileDialogV2
|
|
260 |
requestDirectoryName:'which directory ?'
|
|
261 |
default:Filename currentDirectory pathName
|
|
262 |
ok:'Yes'
|
|
263 |
ifFail:'none'
|
|
264 |
"
|
|
265 |
!
|
|
266 |
|
|
267 |
requestFileName:titleString default:defaultName ok:okText abort:abortText pattern:pattern fromDirectory:aDirectoryPathOrNil whenBoxCreatedEvaluate:boxCreatedCallback
|
|
268 |
|
|
269 |
^ self
|
|
270 |
requestFileName:titleString
|
|
271 |
default:defaultName
|
|
272 |
ok:okText
|
|
273 |
abort:abortText
|
|
274 |
version:nil
|
|
275 |
ifFail:nil
|
|
276 |
pattern:pattern
|
|
277 |
fromDirectory:aDirectoryPathOrNil
|
|
278 |
whenBoxCreatedEvaluate:boxCreatedCallback
|
|
279 |
!
|
|
280 |
|
|
281 |
requestFileName:titleString default:defaultName ok:okText abort:abortText version:versionSymbol ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPath whenBoxCreatedEvaluate:boxCreatedCallback
|
|
282 |
"launch a Dialog, which allows user to enter a filename.
|
|
283 |
The files presented initially are those in aDirectoryPathOrNil, or the
|
|
284 |
last fileBox directory (default: current directory) (if a nil path is given).
|
|
285 |
The box will show okText in its okButton, abortText in the abortButton.
|
|
286 |
The matchPattern is set to pattern initially.
|
|
287 |
Return the string, or nil if cancel was pressed
|
|
288 |
The version argument allows validation of the files existance;
|
|
289 |
it may be any of:
|
|
290 |
#mustBeNew - fail (return empty string) if the file exists
|
|
291 |
#new - confirm if the file exists
|
|
292 |
#mustBeOld - fail if the file does not exist
|
|
293 |
#old - confirm if the file does not exist
|
|
294 |
#any (other) - no validation
|
|
295 |
"
|
|
296 |
|
|
297 |
^ self
|
|
298 |
requestFileName:titleString
|
|
299 |
default:defaultName
|
|
300 |
ok:okText
|
|
301 |
abort:abortText
|
|
302 |
version:versionSymbol
|
|
303 |
ifFail:failBlock
|
|
304 |
pattern:pattern
|
|
305 |
fromDirectory:aDirectoryPath
|
|
306 |
whenBoxCreatedEvaluate:boxCreatedCallback
|
|
307 |
asLoadDialog:nil
|
|
308 |
!
|
|
309 |
|
|
310 |
requestFileName:titleString default:defaultName ok:okText abort:abortText version:versionSymbol ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPath whenBoxCreatedEvaluate:boxCreatedCallback asLoadDialog:aBoolean
|
|
311 |
"launch a Dialog, which allows user to enter a filename.
|
|
312 |
The files presented initially are those in aDirectoryPathOrNil, or the
|
|
313 |
last fileBox directory (default: current directory) (if a nil path is given).
|
|
314 |
The box will show okText in its okButton, abortText in the abortButton.
|
|
315 |
The matchPattern is set to pattern initially.
|
|
316 |
Return the string, or nil if cancel was pressed
|
|
317 |
The version argument allows validation of the files existance;
|
|
318 |
it may be any of:
|
|
319 |
#mustBeNew - fail (return empty string) if the file exists
|
|
320 |
#new - confirm if the file exists
|
|
321 |
#mustBeOld - fail if the file does not exist
|
|
322 |
#old - confirm if the file does not exist
|
|
323 |
#any (other) - no validation
|
|
324 |
"
|
|
325 |
|
|
326 |
|
|
327 |
| instance enteredFileName enteredFileNameString|
|
|
328 |
|
|
329 |
instance := self
|
|
330 |
startApplicationFor:titleString
|
|
331 |
default:defaultName
|
|
332 |
ok:okText
|
|
333 |
abort:abortText
|
|
334 |
ifFail:failBlock
|
|
335 |
pattern:pattern
|
|
336 |
fromDirectory:aDirectoryPath
|
|
337 |
whenBoxCreatedEvaluate:boxCreatedCallback
|
|
338 |
asLoadDialog:aBoolean
|
|
339 |
viewFiles:true
|
|
340 |
multipleSelect:false.
|
|
341 |
|
|
342 |
enteredFileNameString := instance result.
|
|
343 |
(enteredFileNameString isNil or:[enteredFileNameString isEmpty]) ifTrue:[
|
|
344 |
^ failBlock value
|
|
345 |
].
|
|
346 |
enteredFileName := enteredFileNameString asFilename.
|
|
347 |
enteredFileNameString := enteredFileName asString.
|
|
348 |
|
|
349 |
(enteredFileName notNil
|
|
350 |
and:[enteredFileNameString notEmpty]) ifTrue:[
|
|
351 |
FileSelectionBox lastFileSelectionDirectory:(enteredFileName directoryName).
|
|
352 |
versionSymbol isNil ifTrue:[ ^ enteredFileNameString].
|
|
353 |
versionSymbol == #mustBeNew ifTrue:[
|
|
354 |
"/ file may not exist
|
|
355 |
enteredFileName exists ifTrue:[^ ''].
|
|
356 |
].
|
|
357 |
versionSymbol == #new ifTrue:[
|
|
358 |
"/ file may not exist
|
|
359 |
enteredFileName exists ifTrue:[
|
|
360 |
(Dialog confirm:(self classResources string:'''%1'' exists.\\Continue anyway ?' with:enteredFileNameString) withCRs)
|
|
361 |
ifFalse:[^ ''].
|
|
362 |
].
|
|
363 |
].
|
|
364 |
versionSymbol == #mustBeOld ifTrue:[
|
|
365 |
enteredFileName exists ifFalse:[^ ''].
|
|
366 |
].
|
|
367 |
versionSymbol == #old ifTrue:[
|
|
368 |
"/ file may not exist
|
|
369 |
enteredFileName exists ifFalse:[
|
|
370 |
(self confirm:(self classResources string:'''%1'' does not exist yet.\\Continue anyway ?' with:enteredFileNameString) withCRs)
|
|
371 |
ifFalse:[^ ''].
|
|
372 |
].
|
|
373 |
].
|
|
374 |
].
|
|
375 |
^ enteredFileNameString
|
|
376 |
"
|
|
377 |
FileDialog
|
|
378 |
requestFileName:'enter a fileName:'
|
|
379 |
default:''
|
|
380 |
ok:nil
|
|
381 |
abort:nil
|
|
382 |
version:nil
|
|
383 |
ifFail:['none']
|
|
384 |
pattern:'*'
|
|
385 |
fromDirectory:Filename currentDirectory pathName
|
|
386 |
whenBoxCreatedEvaluate:nil
|
|
387 |
asLoadDialog:true
|
|
388 |
"
|
|
389 |
!
|
|
390 |
|
|
391 |
requestFileName:titleString default:defaultName version:versionSymbol ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPathOrNil whenBoxCreatedEvaluate:boxCreatedCallback
|
|
392 |
|
|
393 |
^ self
|
|
394 |
requestFileName:titleString
|
|
395 |
default:defaultName
|
|
396 |
ok:nil
|
|
397 |
abort:nil
|
|
398 |
version:versionSymbol
|
|
399 |
ifFail:failBlock
|
|
400 |
pattern:pattern
|
|
401 |
fromDirectory:aDirectoryPathOrNil
|
|
402 |
whenBoxCreatedEvaluate:boxCreatedCallback
|
|
403 |
|
|
404 |
"
|
|
405 |
FileDialog
|
|
406 |
requestFileName:'enter a fileName:'
|
|
407 |
default:''
|
|
408 |
version:nil
|
|
409 |
ifFail:['none']
|
|
410 |
pattern:'*.conf'
|
|
411 |
fromDirectory:Filename currentDirectory pathName
|
|
412 |
whenBoxCreatedEvaluate:nil.
|
|
413 |
Dialog
|
|
414 |
requestFileName:'enter a fileName:'
|
|
415 |
default:''
|
|
416 |
version:nil
|
|
417 |
ifFail:['none']
|
|
418 |
pattern:'*.conf'
|
|
419 |
fromDirectory:Filename currentDirectory pathName
|
|
420 |
whenBoxCreatedEvaluate:nil
|
|
421 |
"
|
|
422 |
"
|
|
423 |
FileDialog
|
|
424 |
requestFileName:'enter a fileName:'
|
|
425 |
default:''
|
|
426 |
version:#old
|
|
427 |
ifFail:['none']
|
|
428 |
pattern:'*.conf'
|
|
429 |
fromDirectory:Filename currentDirectory pathName
|
|
430 |
whenBoxCreatedEvaluate:nil
|
|
431 |
"
|
|
432 |
"
|
|
433 |
FileDialog
|
|
434 |
requestFileName:'enter a fileName:'
|
|
435 |
default:''
|
|
436 |
version:#mustBeNew
|
|
437 |
ifFail:['none']
|
|
438 |
pattern:'*.conf'
|
|
439 |
fromDirectory:Filename currentDirectory pathName
|
|
440 |
whenBoxCreatedEvaluate:nil
|
|
441 |
"
|
|
442 |
!
|
|
443 |
|
|
444 |
requestFileNames:titleString default:defaultName ok:okText abort:abortText ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPath whenBoxCreatedEvaluate:boxCreatedCallback
|
|
445 |
"launch a Dialog, which allows user to enter a filename.
|
|
446 |
The files presented initially are those in aDirectoryPathOrNil, or the
|
|
447 |
last fileBox directory (default: current directory) (if a nil path is given).
|
|
448 |
The box will show okText in its okButton, abortText in the abortButton.
|
|
449 |
The matchPattern is set to pattern initially.
|
|
450 |
Return all selected Filenames as filenames in a collection, or nil if cancel was pressed
|
|
451 |
"
|
|
452 |
|
|
453 |
|
|
454 |
^ self
|
|
455 |
requestFileNames:titleString
|
|
456 |
default:defaultName
|
|
457 |
ok:okText
|
|
458 |
abort:abortText
|
|
459 |
ifFail:failBlock
|
|
460 |
pattern:pattern
|
|
461 |
fromDirectory:aDirectoryPath
|
|
462 |
whenBoxCreatedEvaluate:boxCreatedCallback
|
|
463 |
asLoadDialog:nil.
|
|
464 |
|
|
465 |
|
|
466 |
"
|
|
467 |
FileDialogV2
|
|
468 |
requestFileNames:'enter a fileName:'
|
|
469 |
default:''
|
|
470 |
ok:nil
|
|
471 |
abort:nil
|
|
472 |
ifFail:['none']
|
|
473 |
pattern:'*.conf'
|
|
474 |
fromDirectory:Filename currentDirectory pathName
|
|
475 |
whenBoxCreatedEvaluate:nil.
|
|
476 |
"
|
|
477 |
!
|
|
478 |
|
|
479 |
requestFileNames:titleString default:defaultName ok:okText abort:abortText ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPath whenBoxCreatedEvaluate:boxCreatedCallback asLoadDialog:asLoadDialog
|
|
480 |
"launch a Dialog, which allows user to enter a filename.
|
|
481 |
The files presented initially are those in aDirectoryPathOrNil, or the
|
|
482 |
last fileBox directory (default: current directory) (if a nil path is given).
|
|
483 |
The box will show okText in its okButton, abortText in the abortButton.
|
|
484 |
The matchPattern is set to pattern initially.
|
|
485 |
Return all selected Filenames as filenames in a collection, or nil if cancel was pressed
|
|
486 |
"
|
|
487 |
|
|
488 |
|
|
489 |
| instance enteredFileNames lastDirectory|
|
|
490 |
|
|
491 |
instance := self
|
|
492 |
startApplicationFor:titleString
|
|
493 |
default:defaultName
|
|
494 |
ok:okText
|
|
495 |
abort:abortText
|
|
496 |
ifFail:failBlock
|
|
497 |
pattern:pattern
|
|
498 |
fromDirectory:aDirectoryPath
|
|
499 |
whenBoxCreatedEvaluate:boxCreatedCallback
|
|
500 |
asLoadDialog:asLoadDialog
|
|
501 |
viewFiles:true
|
|
502 |
multipleSelect:true.
|
|
503 |
|
|
504 |
enteredFileNames := instance currentSelectedFiles.
|
|
505 |
(enteredFileNames isEmpty or:[instance result isNil]) ifTrue:[
|
|
506 |
^ failBlock value
|
|
507 |
].
|
|
508 |
lastDirectory := enteredFileNames first.
|
|
509 |
lastDirectory := lastDirectory isFilename ifTrue:[lastDirectory directory] ifFalse:[lastDirectory].
|
|
510 |
FileSelectionBox lastFileSelectionDirectory:(lastDirectory directoryName).
|
|
511 |
^ enteredFileNames
|
|
512 |
|
|
513 |
"
|
|
514 |
FileDialog
|
|
515 |
requestFileNames:'enter a fileName:'
|
|
516 |
default:''
|
|
517 |
ok:nil
|
|
518 |
abort:nil
|
|
519 |
ifFail:['none']
|
|
520 |
pattern:'*.conf'
|
|
521 |
fromDirectory:Filename currentDirectory pathName
|
|
522 |
whenBoxCreatedEvaluate:nil
|
|
523 |
asLoadDialog:true.
|
|
524 |
"
|
|
525 |
!
|
|
526 |
|
|
527 |
startApplicationFor:titleString default:initialDefaultFileNameArg ok:okTextArg abort:abortTextArg ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPath whenBoxCreatedEvaluate:boxCreatedCallback asLoadDialog:asLoadDialog viewFiles:viewFiles multipleSelect:multipleSelect
|
|
528 |
"launch a Dialog, which allows user to enter a filename.
|
|
529 |
The files presented initially are those in aDirectoryPathOrNil, or the
|
|
530 |
last fileBox directory (default: current directory) (if a nil path is given).
|
|
531 |
The box will show okText in its okButton, abortText in the abortButton.
|
|
532 |
The matchPattern is set to pattern initially.
|
|
533 |
Return the string, or nil if cancel was pressed
|
|
534 |
The version argument allows validation of the files existance;
|
|
535 |
it may be any of:
|
|
536 |
#mustBeNew - fail (return empty string) if the file exists
|
|
537 |
#new - confirm if the file exists
|
|
538 |
#mustBeOld - fail if the file does not exist
|
|
539 |
#old - confirm if the file does not exist
|
|
540 |
#any (other) - no validation
|
|
541 |
"
|
|
542 |
|
|
543 |
|
|
544 |
|defaultDir instance defaultFile okText abortText initialDefaultFileName|
|
|
545 |
|
|
546 |
initialDefaultFileName := initialDefaultFileNameArg.
|
|
547 |
initialDefaultFileName notNil ifTrue:[
|
|
548 |
initialDefaultFileName := initialDefaultFileName asFilename
|
|
549 |
].
|
|
550 |
|
|
551 |
okText := okTextArg.
|
|
552 |
okText isNil ifTrue:[ okText := self resources string:'OK' ].
|
|
553 |
abortText := abortTextArg.
|
|
554 |
abortText isNil ifTrue:[ abortText := self resources string:'Cancel' ].
|
|
555 |
|
|
556 |
defaultDir := aDirectoryPath.
|
|
557 |
"/ defaultDir isNil ifTrue:[
|
|
558 |
"/ (initialDefaultFileName size > 0 and:[initialDefaultFileName exists]) ifTrue:[
|
|
559 |
"/ defaultDir := initialDefaultFileName asAbsoluteFilename directory.
|
|
560 |
"/ ] ifFalse:[
|
|
561 |
"/ defaultDir := FileSelectionBox lastFileSelectionDirectory.
|
|
562 |
"/ defaultDir isNil ifTrue:[
|
|
563 |
"/ defaultDir := Filename currentDirectory asAbsoluteFilename.
|
|
564 |
"/ ].
|
|
565 |
"/ defaultDir asFilename exists ifFalse:[
|
|
566 |
"/ defaultDir := nil
|
|
567 |
"/ ].
|
|
568 |
"/ ]
|
|
569 |
"/ ].
|
|
570 |
(initialDefaultFileName notNil
|
|
571 |
and:[initialDefaultFileName isAbsolute
|
|
572 |
and:[true "initialDefaultFileName asFilename exists"]]) ifTrue:[
|
|
573 |
defaultDir := initialDefaultFileName asAbsoluteFilename.
|
|
574 |
viewFiles ifTrue:[
|
|
575 |
defaultDir := defaultDir directory.
|
|
576 |
].
|
|
577 |
] ifFalse:[
|
|
578 |
defaultDir isNil ifTrue:[
|
|
579 |
defaultDir := FileSelectionBox lastFileSelectionDirectory.
|
|
580 |
defaultDir isNil ifTrue:[
|
|
581 |
defaultDir := Filename currentDirectory asAbsoluteFilename.
|
|
582 |
].
|
|
583 |
defaultDir asFilename exists ifFalse:[
|
|
584 |
defaultDir := nil
|
|
585 |
].
|
|
586 |
]
|
|
587 |
].
|
|
588 |
defaultDir := defaultDir asFilename asAbsoluteFilename.
|
|
589 |
"/ [defaultDir exists] whileFalse:[
|
|
590 |
"/ defaultDir := defaultDir directory.
|
|
591 |
"/ ].
|
|
592 |
|
|
593 |
viewFiles ifFalse:[
|
|
594 |
defaultFile := defaultDir asAbsoluteFilename.
|
|
595 |
] ifTrue:[
|
|
596 |
(initialDefaultFileName notNil and:[initialDefaultFileName withoutSuffix baseName ~= '*']) ifTrue:[
|
|
597 |
defaultFile := defaultDir construct:initialDefaultFileName baseName.
|
|
598 |
].
|
|
599 |
].
|
|
600 |
defaultFile isNil ifTrue:[
|
|
601 |
defaultFile := defaultDir.
|
|
602 |
].
|
|
603 |
|
|
604 |
instance := self new.
|
|
605 |
defaultDir notNil ifTrue:[instance directory:defaultDir].
|
|
606 |
instance multipleSelect:multipleSelect ? false.
|
|
607 |
instance startFilename:defaultFile.
|
|
608 |
instance pattern:((pattern isNil or:[pattern isEmpty]) ifTrue:['*'] ifFalse:[pattern]).
|
|
609 |
instance initialText:titleString.
|
|
610 |
instance okLabelHolder value:okText.
|
|
611 |
instance cancelLabelHolder value:abortText.
|
|
612 |
|
|
613 |
instance beLoadDialog:asLoadDialog ? false.
|
|
614 |
instance viewFiles:viewFiles ? true.
|
|
615 |
self setDoubleClickActionFor:instance.
|
|
616 |
instance allButOpenInterface:#windowSpec.
|
|
617 |
boxCreatedCallback notNil ifTrue:[boxCreatedCallback value:instance].
|
|
618 |
|
|
619 |
Dialog aboutToOpenBoxNotificationSignal raiseRequestWith:instance.
|
|
620 |
|
|
621 |
instance openWindowModal.
|
|
622 |
^ instance
|
|
623 |
! !
|
|
624 |
|
|
625 |
!FileDialogV2 class methodsFor:'accessing'!
|
|
626 |
|
|
627 |
setDoubleClickActionFor:instance
|
|
628 |
|
|
629 |
instance doubleClickAction:[:anIndex|
|
|
630 |
| item |
|
|
631 |
item := instance contentsBrowser browserItemList at:anIndex ifAbsent:nil.
|
|
632 |
item notNil ifTrue:[
|
5966
|
633 |
((instance viewFiles and:[item isDirectory not])
|
|
634 |
" or:[(instance viewFiles not and:[item isDirectory])] " ) ifTrue:[
|
5871
|
635 |
instance doAccept.
|
|
636 |
]
|
|
637 |
]
|
|
638 |
].
|
|
639 |
!
|
|
640 |
|
|
641 |
viewDetailsIcon
|
|
642 |
^ FileBrowserV2 viewDetailsIcon
|
|
643 |
! !
|
|
644 |
|
5966
|
645 |
!FileDialogV2 class methodsFor:'help specs'!
|
5871
|
646 |
|
|
647 |
flyByHelpSpec
|
5966
|
648 |
"This resource specification was automatically generated
|
|
649 |
by the UIHelpTool of ST/X."
|
|
650 |
|
|
651 |
"Do not manually edit this!! If it is corrupted,
|
|
652 |
the UIHelpTool may not be able to read the specification."
|
|
653 |
|
|
654 |
"
|
|
655 |
UIHelpTool openOnClass:FileDialogV2
|
|
656 |
"
|
|
657 |
|
5871
|
658 |
<resource: #help>
|
|
659 |
|
5966
|
660 |
^ super flyByHelpSpec addPairsFrom:#(
|
5871
|
661 |
|
5966
|
662 |
#fileHome
|
|
663 |
'Goto Home'
|
|
664 |
|
|
665 |
#fileBrowse
|
|
666 |
'Browse'
|
5871
|
667 |
|
|
668 |
#directoryUp
|
|
669 |
'Directory Up'
|
|
670 |
|
|
671 |
#directoryBack
|
|
672 |
'Directory Back'
|
|
673 |
|
|
674 |
#directoryForward
|
|
675 |
'Directory Forward'
|
|
676 |
|
5966
|
677 |
)
|
|
678 |
!
|
|
679 |
|
|
680 |
helpSpec
|
|
681 |
"This resource specification was automatically generated
|
|
682 |
by the UIHelpTool of ST/X."
|
|
683 |
|
|
684 |
"Do not manually edit this!! If it is corrupted,
|
|
685 |
the UIHelpTool may not be able to read the specification."
|
|
686 |
|
|
687 |
"
|
|
688 |
UIHelpTool openOnClass:FileDialogV2
|
|
689 |
"
|
|
690 |
|
|
691 |
<resource: #help>
|
|
692 |
|
|
693 |
^ super helpSpec addPairsFrom:#(
|
5871
|
694 |
|
|
695 |
#fileHome
|
5966
|
696 |
''
|
5871
|
697 |
|
5966
|
698 |
#fileBrowse
|
|
699 |
'Browse'
|
5871
|
700 |
|
5966
|
701 |
)
|
5871
|
702 |
! !
|
|
703 |
|
|
704 |
!FileDialogV2 class methodsFor:'interface specs'!
|
|
705 |
|
|
706 |
windowSpec
|
|
707 |
"This resource specification was automatically generated
|
|
708 |
by the UIPainter of ST/X."
|
|
709 |
|
|
710 |
"Do not manually edit this!! If it is corrupted,
|
|
711 |
the UIPainter may not be able to read the specification."
|
|
712 |
|
|
713 |
"
|
|
714 |
UIPainter new openOnClass:FileDialogV2 andSelector:#windowSpec
|
|
715 |
FileDialogV2 new openInterface:#windowSpec
|
|
716 |
FileDialogV2 open
|
|
717 |
"
|
|
718 |
|
|
719 |
<resource: #canvas>
|
|
720 |
|
|
721 |
^
|
|
722 |
#(FullSpec
|
|
723 |
name: windowSpec
|
|
724 |
window:
|
|
725 |
(WindowSpec
|
|
726 |
label: 'FileDialogV2'
|
|
727 |
name: 'FileDialogV2'
|
|
728 |
min: (Point 10 10)
|
|
729 |
max: (Point 1024 768)
|
|
730 |
bounds: (Rectangle 0 0 400 400)
|
|
731 |
)
|
|
732 |
component:
|
|
733 |
(SpecCollection
|
|
734 |
collection: (
|
|
735 |
(ViewSpec
|
|
736 |
name: 'FilePart'
|
|
737 |
layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 -32 1.0)
|
|
738 |
component:
|
|
739 |
(SpecCollection
|
|
740 |
collection: (
|
|
741 |
(MenuPanelSpec
|
|
742 |
name: 'ToolBar1'
|
|
743 |
layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 30 0)
|
|
744 |
tabable: true
|
|
745 |
menu: toolBarMenu
|
|
746 |
textDefault: true
|
|
747 |
)
|
|
748 |
(SubCanvasSpec
|
|
749 |
name: 'DirectoryContentsBrowser'
|
|
750 |
layout: (LayoutFrame 0 0.0 55 0 0 1.0 -30 1)
|
|
751 |
tabable: true
|
|
752 |
hasHorizontalScrollBar: false
|
|
753 |
hasVerticalScrollBar: false
|
|
754 |
majorKey: DirectoryContentsBrowser
|
|
755 |
createNewApplication: true
|
|
756 |
createNewBuilder: true
|
|
757 |
postBuildCallback: postBuildTreeBrowser:
|
|
758 |
)
|
|
759 |
(VariableHorizontalPanelSpec
|
|
760 |
name: 'VariableHorizontalPanel1'
|
|
761 |
layout: (LayoutFrame 0 0 30 0 0 1 55 0)
|
|
762 |
level: 1
|
|
763 |
showHandle: false
|
|
764 |
barLevel: 0
|
|
765 |
component:
|
|
766 |
(SpecCollection
|
|
767 |
collection: (
|
|
768 |
(ViewSpec
|
|
769 |
name: 'Box1'
|
|
770 |
)
|
|
771 |
(ViewSpec
|
|
772 |
name: 'Box2'
|
|
773 |
component:
|
|
774 |
(SpecCollection
|
|
775 |
collection: (
|
|
776 |
(LabelSpec
|
|
777 |
label: 'Filter:'
|
|
778 |
name: 'FilterLabel'
|
|
779 |
layout: (LayoutFrame 8 0 2 0 59 0 -2 1)
|
|
780 |
translateLabel: true
|
|
781 |
adjust: right
|
|
782 |
)
|
|
783 |
(InputFieldSpec
|
|
784 |
name: 'FilterEntryField'
|
|
785 |
layout: (LayoutFrame 60 0 -22 1 -2 1 -2 1)
|
|
786 |
model: filterHolder
|
|
787 |
immediateAccept: true
|
|
788 |
acceptOnReturn: true
|
|
789 |
acceptOnTab: true
|
|
790 |
acceptOnLostFocus: true
|
|
791 |
acceptOnPointerLeave: false
|
|
792 |
postBuildCallback: postBuildFilterField:
|
|
793 |
)
|
|
794 |
)
|
|
795 |
|
|
796 |
)
|
|
797 |
)
|
|
798 |
)
|
|
799 |
|
|
800 |
)
|
|
801 |
handles: (Any 0.5 1.0)
|
|
802 |
)
|
|
803 |
(LabelSpec
|
|
804 |
label: 'Filename:'
|
|
805 |
name: 'FilenameLabel'
|
|
806 |
layout: (LayoutFrame 3 0 -21 1 73 0 -1 1)
|
|
807 |
translateLabel: true
|
|
808 |
labelChannel: filenameLabelHolder
|
|
809 |
adjust: left
|
|
810 |
)
|
|
811 |
(FilenameInputFieldSpec
|
|
812 |
name: 'FilenameEntryField'
|
|
813 |
layout: (LayoutFrame 70 0 -21 1 -4 1 -1 1)
|
|
814 |
tabable: true
|
|
815 |
model: filenameHolder
|
|
816 |
immediateAccept: false
|
|
817 |
acceptOnPointerLeave: false
|
|
818 |
hasKeyboardFocusInitially: true
|
|
819 |
postBuildCallback: postBuildFileNameField:
|
|
820 |
)
|
|
821 |
)
|
|
822 |
|
|
823 |
)
|
|
824 |
)
|
|
825 |
(HorizontalPanelViewSpec
|
|
826 |
name: 'ButtonPanel'
|
|
827 |
layout: (LayoutFrame 0 0.0 -32 1 0 1 0 1)
|
|
828 |
visibilityChannel: buttonPanelVisibleHolder
|
|
829 |
horizontalLayout: fitSpace
|
|
830 |
verticalLayout: center
|
|
831 |
horizontalSpace: 3
|
|
832 |
verticalSpace: 3
|
|
833 |
reverseOrderIfOKAtLeft: true
|
|
834 |
component:
|
|
835 |
(SpecCollection
|
|
836 |
collection: (
|
|
837 |
(ActionButtonSpec
|
|
838 |
label: 'Cancel'
|
|
839 |
name: 'cancelButton'
|
|
840 |
translateLabel: true
|
|
841 |
labelChannel: cancelLabelHolder
|
|
842 |
tabable: true
|
|
843 |
model: doCancel
|
|
844 |
extent: (Point 129 22)
|
|
845 |
)
|
|
846 |
(ActionButtonSpec
|
|
847 |
label: 'Append'
|
|
848 |
name: 'appendButton'
|
|
849 |
visibilityChannel: appendButtonVisibleHolder
|
|
850 |
translateLabel: true
|
|
851 |
labelChannel: appendLabelHolder
|
|
852 |
tabable: true
|
|
853 |
model: appendPressed
|
|
854 |
extent: (Point 129 22)
|
|
855 |
)
|
|
856 |
(ActionButtonSpec
|
|
857 |
label: 'OK'
|
|
858 |
name: 'okButton'
|
|
859 |
translateLabel: true
|
|
860 |
labelChannel: okLabelHolder
|
|
861 |
tabable: true
|
|
862 |
model: okPressed
|
|
863 |
isDefault: true
|
|
864 |
extent: (Point 130 22)
|
|
865 |
)
|
|
866 |
)
|
|
867 |
|
|
868 |
)
|
|
869 |
)
|
|
870 |
)
|
|
871 |
|
|
872 |
)
|
|
873 |
)
|
|
874 |
! !
|
|
875 |
|
|
876 |
!FileDialogV2 class methodsFor:'menu specs'!
|
|
877 |
|
|
878 |
toolBarMenu
|
|
879 |
"This resource specification was automatically generated
|
|
880 |
by the MenuEditor of ST/X."
|
|
881 |
|
|
882 |
"Do not manually edit this!! If it is corrupted,
|
|
883 |
the MenuEditor may not be able to read the specification."
|
|
884 |
|
|
885 |
"
|
|
886 |
MenuEditor new openOnClass:FileDialogV2 andSelector:#toolBarMenu
|
|
887 |
(Menu new fromLiteralArrayEncoding:(FileDialogV2 toolBarMenu)) startUp
|
|
888 |
"
|
|
889 |
|
|
890 |
<resource: #menu>
|
|
891 |
|
|
892 |
^
|
|
893 |
#(Menu
|
|
894 |
(
|
|
895 |
(MenuItem
|
|
896 |
activeHelpKey: directoryUp
|
|
897 |
enabled: enableDirectoryUp
|
|
898 |
label: 'DirectoryUp'
|
|
899 |
itemValue: doGoDirectoryUp
|
|
900 |
translateLabel: true
|
|
901 |
isButton: true
|
|
902 |
labelImage: (ResourceRetriever AbstractFileBrowser upArrow20x20Icon)
|
|
903 |
)
|
|
904 |
(MenuItem
|
|
905 |
label: ''
|
|
906 |
)
|
|
907 |
(MenuItem
|
|
908 |
activeHelpKey: directoryBack
|
|
909 |
enabled: enableBack
|
|
910 |
label: 'Back'
|
|
911 |
itemValue: doBack
|
|
912 |
translateLabel: true
|
|
913 |
isButton: true
|
|
914 |
submenuChannel: menuDirHistoryBack
|
|
915 |
labelImage: (ResourceRetriever AbstractFileBrowser leftArrow20x20Icon)
|
|
916 |
keepLinkedMenu: true
|
|
917 |
)
|
|
918 |
(MenuItem
|
|
919 |
label: ''
|
|
920 |
)
|
|
921 |
(MenuItem
|
|
922 |
activeHelpKey: directoryForward
|
|
923 |
enabled: enableForward
|
|
924 |
label: 'Forward'
|
|
925 |
itemValue: doForward
|
|
926 |
translateLabel: true
|
|
927 |
isButton: true
|
|
928 |
submenuChannel: menuDirHistoryForward
|
|
929 |
labelImage: (ResourceRetriever AbstractFileBrowser rightArrow20x20Icon)
|
|
930 |
keepLinkedMenu: true
|
|
931 |
)
|
|
932 |
(MenuItem
|
|
933 |
label: ''
|
|
934 |
)
|
|
935 |
(MenuItem
|
|
936 |
activeHelpKey: fileHome
|
|
937 |
enabled: enableHome
|
|
938 |
label: 'Home'
|
|
939 |
itemValue: doGotoHomeDirectory
|
|
940 |
translateLabel: true
|
|
941 |
isButton: true
|
|
942 |
labelImage: (ResourceRetriever AbstractFileBrowser goHomeIcon)
|
|
943 |
)
|
|
944 |
(MenuItem
|
|
945 |
label: '-'
|
5966
|
946 |
isVisible: browseVisibleHolder
|
|
947 |
)
|
|
948 |
(MenuItem
|
|
949 |
activeHelpKey: fileBrowse
|
|
950 |
label: 'Browse'
|
|
951 |
itemValue: doBrowseDirectory
|
|
952 |
translateLabel: true
|
|
953 |
isButton: true
|
|
954 |
isVisible: browseVisibleHolder
|
|
955 |
labelImage: (ResourceRetriever ToolbarIconLibrary fileBrowser24x24Icon)
|
|
956 |
)
|
|
957 |
(MenuItem
|
|
958 |
label: '-'
|
5871
|
959 |
)
|
|
960 |
(MenuItem
|
|
961 |
label: 'New Directory'
|
|
962 |
itemValue: newDirectory
|
|
963 |
translateLabel: true
|
|
964 |
isButton: true
|
|
965 |
isVisible: newDirectoryVisibilityHolder
|
|
966 |
labelImage: (ResourceRetriever AbstractFileBrowser newDirectory20x20Icon)
|
|
967 |
)
|
|
968 |
(MenuItem
|
|
969 |
label: 'viewDetails'
|
|
970 |
translateLabel: true
|
|
971 |
isButton: true
|
|
972 |
startGroup: right
|
|
973 |
hideMenuOnActivated: false
|
|
974 |
indication: viewDetails
|
|
975 |
labelImage: (ResourceRetriever nil viewDetailsIcon)
|
|
976 |
)
|
|
977 |
(MenuItem
|
|
978 |
activeHelpKey: toggleDetails
|
|
979 |
label: 'viewDetails'
|
|
980 |
translateLabel: true
|
|
981 |
isButton: true
|
|
982 |
startGroup: right
|
|
983 |
isVisible: false
|
|
984 |
indication: viewDetails
|
|
985 |
submenuChannel: viewDetailsMenuSpec
|
|
986 |
labelImage: (ResourceRetriever nil viewDetailsIcon)
|
|
987 |
)
|
|
988 |
(MenuItem
|
|
989 |
activeHelpKey: selectDetails
|
|
990 |
label: ''
|
|
991 |
isButton: true
|
|
992 |
startGroup: right
|
|
993 |
submenuChannel: viewDetailsMenuSpec
|
|
994 |
labelImage: (ResourceRetriever ToolbarIconLibrary empty1x20Icon)
|
|
995 |
)
|
|
996 |
)
|
|
997 |
nil
|
|
998 |
nil
|
|
999 |
)
|
|
1000 |
! !
|
|
1001 |
|
|
1002 |
!FileDialogV2 methodsFor:'accessing'!
|
|
1003 |
|
|
1004 |
currentSelectedFiles
|
|
1005 |
|
|
1006 |
| selectedFiles|
|
|
1007 |
|
|
1008 |
selectedFiles := contentsBrowser currentFileNameHolder value.
|
|
1009 |
^ selectedFiles select:[:aFile| aFile isDirectory not].
|
|
1010 |
!
|
|
1011 |
|
|
1012 |
directory
|
|
1013 |
"return the value of the instance variable 'directory' (automatically generated)"
|
|
1014 |
|
|
1015 |
^ directory
|
|
1016 |
!
|
|
1017 |
|
|
1018 |
directory:something
|
|
1019 |
"set the value of the instance variable 'directory' (automatically generated)"
|
|
1020 |
|
|
1021 |
directory := something.
|
|
1022 |
!
|
|
1023 |
|
|
1024 |
initialText
|
|
1025 |
|
|
1026 |
initialText isNil ifTrue:[
|
|
1027 |
^ resources string:'File Dialog'.
|
|
1028 |
].
|
|
1029 |
^ resources string:initialText
|
|
1030 |
!
|
|
1031 |
|
|
1032 |
initialText:something
|
|
1033 |
"set the value of the instance variable 'initialText' (automatically generated)"
|
|
1034 |
|
|
1035 |
initialText := something.
|
|
1036 |
!
|
|
1037 |
|
|
1038 |
pattern
|
|
1039 |
"return the value of the instance variable 'pattern' (automatically generated)"
|
|
1040 |
|
|
1041 |
^ pattern
|
|
1042 |
!
|
|
1043 |
|
|
1044 |
pattern:something
|
|
1045 |
"set the value of the instance variable 'pattern' (automatically generated)"
|
|
1046 |
|
|
1047 |
pattern := something.
|
|
1048 |
!
|
|
1049 |
|
|
1050 |
result
|
|
1051 |
"return the value of the instance variable 'result' (automatically generated)"
|
|
1052 |
|
|
1053 |
^ result
|
|
1054 |
!
|
|
1055 |
|
|
1056 |
result:something
|
|
1057 |
"set the value of the instance variable 'result' (automatically generated)"
|
|
1058 |
|
|
1059 |
result := something.
|
|
1060 |
!
|
|
1061 |
|
|
1062 |
selectedDirectories
|
|
1063 |
|
|
1064 |
| selectedFiles|
|
|
1065 |
|
|
1066 |
selectedFiles := contentsBrowser currentFileNameHolder value.
|
|
1067 |
^ selectedFiles select:[:aFile| aFile isDirectory].
|
|
1068 |
!
|
|
1069 |
|
|
1070 |
startFilename
|
|
1071 |
"return the value of the instance variable 'startFilename' (automatically generated)"
|
|
1072 |
|
|
1073 |
startFilename isNil ifTrue:[
|
|
1074 |
startFilename := Filename currentDirectory asAbsoluteFilename.
|
|
1075 |
].
|
|
1076 |
^ startFilename
|
|
1077 |
!
|
|
1078 |
|
|
1079 |
startFilename:something
|
|
1080 |
"set the value of the instance variable 'startFilename' (automatically generated)"
|
|
1081 |
|
|
1082 |
startFilename := something.
|
|
1083 |
! !
|
|
1084 |
|
|
1085 |
!FileDialogV2 methodsFor:'accessing browser'!
|
|
1086 |
|
|
1087 |
showHiddenFiles
|
|
1088 |
^ contentsBrowser showHiddenFiles
|
|
1089 |
!
|
|
1090 |
|
|
1091 |
userContextAvailable
|
|
1092 |
^ contentsBrowser userContextAvailable
|
|
1093 |
!
|
|
1094 |
|
|
1095 |
viewDescription
|
|
1096 |
^ contentsBrowser viewDescription
|
|
1097 |
!
|
|
1098 |
|
|
1099 |
viewDetails
|
|
1100 |
^ contentsBrowser viewDetails
|
|
1101 |
!
|
|
1102 |
|
|
1103 |
viewDetailsMenuSpec
|
|
1104 |
^ contentsBrowser viewDetailsMenuSpec
|
|
1105 |
!
|
|
1106 |
|
|
1107 |
viewGroup
|
|
1108 |
^ contentsBrowser viewGroup
|
|
1109 |
!
|
|
1110 |
|
|
1111 |
viewIcon
|
|
1112 |
^ contentsBrowser viewIcon
|
|
1113 |
!
|
|
1114 |
|
|
1115 |
viewInodeNumber
|
|
1116 |
^ contentsBrowser viewInodeNumber
|
|
1117 |
!
|
|
1118 |
|
|
1119 |
viewOwner
|
|
1120 |
^ contentsBrowser viewOwner
|
|
1121 |
!
|
|
1122 |
|
|
1123 |
viewPermissions
|
|
1124 |
^ contentsBrowser viewPermissions
|
|
1125 |
!
|
|
1126 |
|
|
1127 |
viewPreview
|
|
1128 |
^ contentsBrowser viewPreview
|
|
1129 |
!
|
|
1130 |
|
|
1131 |
viewSize
|
|
1132 |
^ contentsBrowser viewSize
|
|
1133 |
!
|
|
1134 |
|
|
1135 |
viewSizeInBytes
|
|
1136 |
^ contentsBrowser viewSizeInBytes
|
|
1137 |
!
|
|
1138 |
|
|
1139 |
viewSizeInKiloBytes
|
|
1140 |
^ contentsBrowser viewSizeInKiloBytes
|
|
1141 |
!
|
|
1142 |
|
|
1143 |
viewTime
|
|
1144 |
^ contentsBrowser viewTime
|
|
1145 |
!
|
|
1146 |
|
|
1147 |
viewType
|
|
1148 |
^ contentsBrowser viewType
|
|
1149 |
! !
|
|
1150 |
|
|
1151 |
!FileDialogV2 methodsFor:'accessing-behavior'!
|
|
1152 |
|
|
1153 |
asLoadDialog
|
|
1154 |
^ self isLoadDialog
|
|
1155 |
!
|
|
1156 |
|
|
1157 |
asLoadDialog:aBoolean
|
|
1158 |
self beLoadDialog:aBoolean
|
|
1159 |
!
|
|
1160 |
|
|
1161 |
beLoadDialog:aBoolean
|
|
1162 |
|
|
1163 |
isLoadDialog := aBoolean
|
|
1164 |
!
|
|
1165 |
|
|
1166 |
doubleClickAction
|
|
1167 |
"return the value of the instance variable 'doubleClickAction' (automatically generated)"
|
|
1168 |
|
|
1169 |
^ doubleClickAction
|
|
1170 |
!
|
|
1171 |
|
|
1172 |
doubleClickAction:something
|
|
1173 |
"set the value of the instance variable 'doubleClickAction' (automatically generated)"
|
|
1174 |
|
|
1175 |
doubleClickAction := something.
|
|
1176 |
!
|
|
1177 |
|
|
1178 |
isLoadDialog
|
|
1179 |
|
|
1180 |
^ isLoadDialog ? true
|
|
1181 |
!
|
|
1182 |
|
|
1183 |
multipleSelect
|
|
1184 |
^ multipleSelect ? false
|
|
1185 |
!
|
|
1186 |
|
|
1187 |
multipleSelect:aBoolean
|
|
1188 |
multipleSelect := aBoolean.
|
|
1189 |
contentsBrowser notNil ifTrue:[
|
|
1190 |
contentsBrowser multipleSelect:aBoolean.
|
|
1191 |
].
|
|
1192 |
! !
|
|
1193 |
|
|
1194 |
!FileDialogV2 methodsFor:'accessing-components'!
|
|
1195 |
|
|
1196 |
addButton:aButton
|
|
1197 |
DialogBox defaultOKButtonAtLeft ifTrue:[
|
|
1198 |
(self componentAt:#ButtonPanel) addSubView:aButton before:(self okButton)
|
|
1199 |
] ifFalse:[
|
|
1200 |
(self componentAt:#ButtonPanel) addSubView:aButton after:(self okButton)
|
|
1201 |
].
|
|
1202 |
!
|
|
1203 |
|
|
1204 |
contentsBrowser
|
|
1205 |
"return the value of the instance variable 'treeBrowser' (automatically generated)"
|
|
1206 |
|
|
1207 |
^ contentsBrowser
|
|
1208 |
!
|
|
1209 |
|
|
1210 |
okButton
|
|
1211 |
^ (self componentAt:#okButton)
|
|
1212 |
! !
|
|
1213 |
|
|
1214 |
!FileDialogV2 methodsFor:'accessing-look'!
|
|
1215 |
|
5966
|
1216 |
browseVisibleHolder
|
|
1217 |
^ true
|
|
1218 |
!
|
|
1219 |
|
5871
|
1220 |
hideButtonPanel
|
|
1221 |
self buttonPanelVisibleHolder value:false
|
|
1222 |
!
|
|
1223 |
|
|
1224 |
newDirectoryVisibilityHolder
|
|
1225 |
newDirectoryVisibilityHolder isNil ifTrue:[
|
|
1226 |
newDirectoryVisibilityHolder := true asValue.
|
|
1227 |
].
|
|
1228 |
^ newDirectoryVisibilityHolder
|
|
1229 |
!
|
|
1230 |
|
|
1231 |
showButtonPanel
|
|
1232 |
self buttonPanelVisibleHolder value:true
|
|
1233 |
!
|
|
1234 |
|
|
1235 |
viewFiles
|
|
1236 |
"return the value of the instance variable 'viewFiles' (automatically generated)"
|
|
1237 |
|
|
1238 |
^ viewFiles
|
|
1239 |
!
|
|
1240 |
|
|
1241 |
viewFiles:something
|
|
1242 |
"set the value of the instance variable 'viewFiles' (automatically generated)"
|
|
1243 |
|
|
1244 |
viewFiles := something.
|
|
1245 |
! !
|
|
1246 |
|
|
1247 |
!FileDialogV2 methodsFor:'aspects'!
|
|
1248 |
|
|
1249 |
appendButtonVisibleHolder
|
|
1250 |
appendButtonVisibleHolder isNil ifTrue:[
|
|
1251 |
appendButtonVisibleHolder := false asValue.
|
|
1252 |
].
|
|
1253 |
^ appendButtonVisibleHolder
|
|
1254 |
!
|
|
1255 |
|
|
1256 |
appendLabelHolder
|
|
1257 |
appendLabelHolder isNil ifTrue:[
|
|
1258 |
appendLabelHolder := 'Append' asValue.
|
|
1259 |
].
|
|
1260 |
^ appendLabelHolder
|
|
1261 |
!
|
|
1262 |
|
|
1263 |
aspectOrNil:aKey forSubApplication:aSubApp
|
|
1264 |
"this hook provides an aspect for a subApp"
|
|
1265 |
|
|
1266 |
aKey == #currentFileNameHolder ifTrue:[
|
|
1267 |
directory notNil ifTrue:[
|
|
1268 |
^ (OrderedCollection with:directory) asValue
|
|
1269 |
]
|
|
1270 |
].
|
|
1271 |
^ nil
|
|
1272 |
!
|
|
1273 |
|
|
1274 |
buttonPanelVisibleHolder
|
|
1275 |
buttonPanelVisibleHolder isNil ifTrue:[
|
|
1276 |
buttonPanelVisibleHolder := true asValue.
|
|
1277 |
buttonPanelVisibleHolder onChangeSend:#buttonPanelVisibilityChanged to:self.
|
|
1278 |
].
|
|
1279 |
^ buttonPanelVisibleHolder.
|
|
1280 |
!
|
|
1281 |
|
|
1282 |
cancelLabelHolder
|
|
1283 |
"automatically generated by UIPainter ..."
|
|
1284 |
|
|
1285 |
"*** the code below creates a default model when invoked."
|
|
1286 |
"*** (which may not be the one you wanted)"
|
|
1287 |
"*** Please change as required and accept it in the browser."
|
|
1288 |
"*** (and replace this comment by something more useful ;-)"
|
|
1289 |
|
|
1290 |
cancelLabelHolder isNil ifTrue:[
|
|
1291 |
cancelLabelHolder := 'Cancel' asValue.
|
|
1292 |
].
|
|
1293 |
^ cancelLabelHolder.
|
|
1294 |
!
|
|
1295 |
|
|
1296 |
enableBack
|
|
1297 |
^ contentsBrowser enableBack.
|
|
1298 |
!
|
|
1299 |
|
|
1300 |
enableDirectoryUp
|
|
1301 |
^ contentsBrowser enableDirectoryUp.
|
|
1302 |
!
|
|
1303 |
|
|
1304 |
enableForward
|
|
1305 |
^ contentsBrowser enableForward.
|
|
1306 |
!
|
|
1307 |
|
|
1308 |
enableHome
|
|
1309 |
^ contentsBrowser enableHome.
|
|
1310 |
!
|
|
1311 |
|
|
1312 |
filenameHolder
|
|
1313 |
"Return a value holder with the filename.
|
|
1314 |
Shown in the filename input-field.
|
|
1315 |
Being the selection in the tree.
|
|
1316 |
"
|
|
1317 |
|holder|
|
|
1318 |
holder := builder bindingAt:#filenameHolder.
|
|
1319 |
|
|
1320 |
holder ifNil:[
|
|
1321 |
holder := ValueHolder new.
|
|
1322 |
holder addDependent:self.
|
|
1323 |
builder aspectAt:#filenameHolder
|
|
1324 |
put:holder.
|
|
1325 |
].
|
|
1326 |
|
|
1327 |
^ holder.
|
|
1328 |
!
|
|
1329 |
|
|
1330 |
filenameLabelHolder
|
|
1331 |
"Return a value holder for the input string.
|
|
1332 |
"
|
|
1333 |
filenameLabelHolder isNil ifTrue:[
|
|
1334 |
filenameLabelHolder := 'Filename:' asValue.
|
|
1335 |
].
|
|
1336 |
^ filenameLabelHolder
|
|
1337 |
!
|
|
1338 |
|
|
1339 |
filterHolder
|
|
1340 |
"Return a value holder for filter
|
|
1341 |
"
|
|
1342 |
|
|
1343 |
filterHolder isNil ifTrue:[
|
|
1344 |
filterHolder := contentsBrowser filterModel.
|
|
1345 |
self pattern notNil ifTrue:[
|
|
1346 |
filterHolder value:pattern.
|
|
1347 |
]
|
|
1348 |
].
|
|
1349 |
^ filterHolder
|
|
1350 |
!
|
|
1351 |
|
|
1352 |
okLabelHolder
|
|
1353 |
"automatically generated by UIPainter ..."
|
|
1354 |
|
|
1355 |
"*** the code below creates a default model when invoked."
|
|
1356 |
"*** (which may not be the one you wanted)"
|
|
1357 |
"*** Please change as required and accept it in the browser."
|
|
1358 |
"*** (and replace this comment by something more useful ;-)"
|
|
1359 |
|
|
1360 |
okLabelHolder isNil ifTrue:[
|
|
1361 |
okLabelHolder := 'OK' asValue.
|
|
1362 |
].
|
|
1363 |
^ okLabelHolder.
|
|
1364 |
! !
|
|
1365 |
|
|
1366 |
!FileDialogV2 methodsFor:'change & update'!
|
|
1367 |
|
|
1368 |
buttonPanelVisibilityChanged
|
|
1369 |
|filePart|
|
|
1370 |
|
|
1371 |
filePart := builder componentAt:#FilePart.
|
|
1372 |
filePart notNil ifTrue:[
|
|
1373 |
buttonPanelVisibleHolder value ifTrue:[
|
|
1374 |
filePart layout bottomOffset:-40
|
|
1375 |
] ifFalse:[
|
|
1376 |
filePart layout bottomOffset:0
|
|
1377 |
].
|
|
1378 |
filePart containerChangedSize "/ force resize
|
|
1379 |
]
|
|
1380 |
!
|
|
1381 |
|
|
1382 |
update:something with:aParameter from:changedObject
|
|
1383 |
|files newFile newLabel fn entryFieldFilename|
|
|
1384 |
|
|
1385 |
changedObject == contentsBrowser currentFileNameHolder ifTrue:[
|
|
1386 |
files := changedObject value.
|
|
1387 |
|
|
1388 |
(files isEmpty) ifTrue:[
|
|
1389 |
newFile := nil.
|
|
1390 |
] ifFalse:[
|
|
1391 |
files size == 1 ifTrue:[
|
|
1392 |
newFile := files first.
|
|
1393 |
] ifFalse:[
|
|
1394 |
newFile := ''.
|
|
1395 |
].
|
|
1396 |
].
|
|
1397 |
(self filenameHolder value notNil and:[newFile asFilename isDirectory]) ifTrue:[
|
|
1398 |
entryFieldFilename := self filenameHolder value asFilename.
|
|
1399 |
self startFilename asFilename baseName = entryFieldFilename baseName ifTrue:[
|
|
1400 |
entryFieldFilename isDirectory not ifTrue:[
|
|
1401 |
newFile := newFile asFilename construct:entryFieldFilename baseName.
|
|
1402 |
].
|
|
1403 |
].
|
|
1404 |
].
|
|
1405 |
self filenameHolder value:newFile withoutNotifying:self.
|
|
1406 |
].
|
|
1407 |
|
|
1408 |
changedObject == contentsBrowser viewFilesInDirectoryTree ifTrue:[
|
|
1409 |
changedObject value ifTrue:[
|
|
1410 |
newLabel := 'Filename:'.
|
|
1411 |
] ifFalse:[
|
|
1412 |
newLabel := 'Directory:'.
|
|
1413 |
].
|
|
1414 |
self filenameLabelHolder value:(resources string:newLabel)
|
|
1415 |
].
|
|
1416 |
changedObject == self filenameHolder ifTrue:[
|
|
1417 |
fn := changedObject value asFilename.
|
|
1418 |
(fn exists) ifFalse:[^ self].
|
|
1419 |
contentsBrowser currentFileNameHolder value:(OrderedCollection with:fn) withoutNotifying:self.
|
|
1420 |
].
|
|
1421 |
^ super update:something with:aParameter from:changedObject
|
|
1422 |
! !
|
|
1423 |
|
|
1424 |
!FileDialogV2 methodsFor:'event handling'!
|
|
1425 |
|
|
1426 |
appendWasPressed
|
|
1427 |
"valid after the dialog has been closed: true if append was pressed"
|
|
1428 |
|
|
1429 |
^ appendWasPressed
|
|
1430 |
! !
|
|
1431 |
|
|
1432 |
!FileDialogV2 methodsFor:'initialization & release'!
|
|
1433 |
|
|
1434 |
postBuildFileNameField:aWidget
|
|
1435 |
|
|
1436 |
filenameField := aWidget.
|
|
1437 |
!
|
|
1438 |
|
|
1439 |
postBuildFilterField:aWidget
|
|
1440 |
|
|
1441 |
filterField := aWidget.
|
|
1442 |
!
|
|
1443 |
|
|
1444 |
postBuildTreeBrowser:aSubCanvasView
|
|
1445 |
|
|
1446 |
contentsBrowser := aSubCanvasView client.
|
|
1447 |
!
|
|
1448 |
|
|
1449 |
postBuildWith:aBuilder
|
|
1450 |
contentsBrowser multipleSelect:multipleSelect.
|
|
1451 |
appendWasPressed := false.
|
|
1452 |
|
|
1453 |
(aBuilder componentAt:'cancelButton') cursor:(Cursor thumbsDown).
|
|
1454 |
(aBuilder componentAt:'appendButton') cursor:(Cursor thumbsUp).
|
|
1455 |
(aBuilder componentAt:'okButton') cursor:(Cursor thumbsUp).
|
|
1456 |
|
|
1457 |
^ super postBuildWith:aBuilder
|
|
1458 |
!
|
|
1459 |
|
|
1460 |
postOpen
|
|
1461 |
|directory rootDirectory|
|
|
1462 |
|
|
1463 |
"/ self windowGroup addPreEventHook:self.
|
|
1464 |
|
|
1465 |
"No ok and cancel buttons, when dialog is part of a larger dialog"
|
|
1466 |
self window topView isModal ifFalse:[
|
|
1467 |
self hideButtonPanel
|
|
1468 |
].
|
|
1469 |
|
|
1470 |
contentsBrowser currentFileNameHolder addDependent:self.
|
|
1471 |
contentsBrowser doubleClickAction:self doubleClickAction.
|
|
1472 |
|
|
1473 |
directory := (self directory) ? (Filename currentDirectory asAbsoluteFilename).
|
|
1474 |
rootDirectory := directory asFilename directory.
|
|
1475 |
contentsBrowser rootHolder value:rootDirectory.
|
|
1476 |
|
|
1477 |
contentsBrowser viewDirsInContentsBrowser value:true.
|
|
1478 |
contentsBrowser sortDirectoriesBeforeFiles value:true.
|
|
1479 |
contentsBrowser viewFilesInContentsBrowser setValue:(self viewFiles ? true).
|
|
1480 |
contentsBrowser viewFilesInDirectoryTree changed.
|
|
1481 |
contentsBrowser currentFileNameHolder value:(OrderedCollection with:self startFilename).
|
|
1482 |
|
|
1483 |
self isLoadDialog ifTrue:[
|
|
1484 |
"/ contentsBrowser newVisibilityHolder value:false.
|
|
1485 |
"/ contentsBrowser allowFileOperations value:false.
|
|
1486 |
self newDirectoryVisibilityHolder value:false.
|
|
1487 |
].
|
|
1488 |
self filenameHolder value:self startFilename.
|
|
1489 |
self window label:self initialText.
|
|
1490 |
!
|
|
1491 |
|
|
1492 |
postOpenAsSubcanvasWith:aBuilder
|
|
1493 |
self postOpen.
|
|
1494 |
^ super postOpenAsSubcanvasWith:aBuilder
|
|
1495 |
!
|
|
1496 |
|
|
1497 |
postOpenWith:aBuilder
|
|
1498 |
|
|
1499 |
self postOpen.
|
|
1500 |
^ super postOpenWith:aBuilder.
|
|
1501 |
! !
|
|
1502 |
|
|
1503 |
!FileDialogV2 methodsFor:'private'!
|
|
1504 |
|
|
1505 |
returnWasPressedInFilterField
|
|
1506 |
|ev|
|
|
1507 |
|
|
1508 |
ev := self windowGroup lastEvent.
|
|
1509 |
(ev notNil
|
|
1510 |
and:[ev isKeyEvent
|
|
1511 |
and:[ev key == #Return
|
|
1512 |
and:[( ev targetView isSameOrComponentOf:filterField)
|
|
1513 |
or:[false "ev targetView isSameOrComponentOf:filenameField"]]]]) ifTrue:[
|
|
1514 |
^ true
|
|
1515 |
].
|
|
1516 |
^ false
|
|
1517 |
!
|
|
1518 |
|
|
1519 |
returnWasPressedInFilterOrFilenameField
|
|
1520 |
|ev|
|
|
1521 |
|
|
1522 |
ev := self windowGroup lastEvent.
|
|
1523 |
(ev notNil
|
|
1524 |
and:[ev isKeyEvent
|
|
1525 |
and:[ev key == #Return
|
|
1526 |
and:[( ev targetView isSameOrComponentOf:filterField)
|
|
1527 |
or:[false "ev targetView isSameOrComponentOf:filenameField"]]]]) ifTrue:[
|
|
1528 |
^ true
|
|
1529 |
].
|
|
1530 |
^ false
|
|
1531 |
! !
|
|
1532 |
|
|
1533 |
!FileDialogV2 methodsFor:'user actions'!
|
|
1534 |
|
|
1535 |
appendPressed
|
|
1536 |
appendWasPressed := true.
|
|
1537 |
self commonAcceptAction.
|
|
1538 |
!
|
|
1539 |
|
|
1540 |
commonAcceptAction
|
|
1541 |
filenameField accept.
|
|
1542 |
self result:(self filenameHolder value asString).
|
|
1543 |
|
|
1544 |
^ super doAccept
|
|
1545 |
!
|
|
1546 |
|
|
1547 |
doAccept
|
|
1548 |
"force accept - ignore in filterField"
|
|
1549 |
|
|
1550 |
self returnWasPressedInFilterField ifTrue:[
|
|
1551 |
^ self
|
|
1552 |
].
|
|
1553 |
appendWasPressed := false.
|
|
1554 |
self commonAcceptAction.
|
|
1555 |
!
|
|
1556 |
|
|
1557 |
doBack
|
|
1558 |
|
|
1559 |
contentsBrowser doBack.
|
|
1560 |
!
|
|
1561 |
|
|
1562 |
doCancel
|
|
1563 |
|
|
1564 |
self result:nil.
|
|
1565 |
^ super doCancel.
|
|
1566 |
!
|
|
1567 |
|
|
1568 |
doForward
|
|
1569 |
|
|
1570 |
contentsBrowser doForward.
|
|
1571 |
!
|
|
1572 |
|
|
1573 |
doGoDirectoryUp
|
|
1574 |
|
|
1575 |
contentsBrowser doGoDirectoryUp.
|
|
1576 |
!
|
|
1577 |
|
|
1578 |
doGotoHomeDirectory
|
|
1579 |
|
|
1580 |
contentsBrowser doGotoHomeDirectory.
|
|
1581 |
!
|
|
1582 |
|
|
1583 |
menuDirHistory:backOrForward
|
|
1584 |
|
|
1585 |
^ contentsBrowser menuDirHistory:backOrForward.
|
|
1586 |
!
|
|
1587 |
|
|
1588 |
menuDirHistoryBack
|
|
1589 |
|
|
1590 |
^ contentsBrowser menuDirHistory:#back.
|
|
1591 |
!
|
|
1592 |
|
|
1593 |
menuDirHistoryForward
|
|
1594 |
|
|
1595 |
^ contentsBrowser menuDirHistory:#forward.
|
|
1596 |
!
|
|
1597 |
|
|
1598 |
newDirectory
|
|
1599 |
|
|
1600 |
^ contentsBrowser newDirectory
|
|
1601 |
!
|
|
1602 |
|
|
1603 |
okPressed
|
|
1604 |
self doAccept
|
|
1605 |
! !
|
|
1606 |
|
|
1607 |
!FileDialogV2 class methodsFor:'documentation'!
|
|
1608 |
|
|
1609 |
version
|
5966
|
1610 |
^ '$Header: /cvs/stx/stx/libtool/FileDialogV2.st,v 1.2 2004-08-04 14:05:15 cg Exp $'
|
5871
|
1611 |
! !
|