author | Claus Gittinger <cg@exept.de> |
Tue, 31 Aug 2004 12:28:49 +0200 | |
changeset 5982 | 51881020b2d1 |
parent 5969 | 3b4c0c099aab |
child 6065 | 500ec804b779 |
permissions | -rw-r--r-- |
5140 | 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 |
||
3892 | 13 |
"{ Package: 'stx:libtool' }" |
14 |
||
15 |
SimpleDialog subclass:#FileDialog |
|
5220
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
16 |
instanceVariableNames:'aspects treeBrowser directory pattern filterHolder initialText |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
17 |
multipleSelect doubleClickAction cancelLabelHolder okLabelHolder |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
18 |
startFilename result filterField filenameField viewFiles |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
19 |
filenameLabelHolder isLoadDialog newDirectoryVisibilityHolder |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
20 |
appendButtonVisibleHolder appendWasPressed |
5969 | 21 |
buttonPanelVisibleHolder appendLabelHolder browseVisibleHolder' |
5931 | 22 |
classVariableNames:'LastExtent' |
5220
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
23 |
poolDictionaries:'' |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
24 |
category:'Interface-Tools-File' |
3892 | 25 |
! |
26 |
||
27 |
!FileDialog class methodsFor:'documentation'! |
|
28 |
||
5140 | 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 |
||
3892 | 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] |
|
5188
283a77f6efe2
care for non-existing initial dir.
Claus Gittinger <cg@exept.de>
parents:
5173
diff
changeset
|
66 |
FileDialog |
4804 | 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 |
|
3892 | 81 |
[exEnd] |
82 |
" |
|
5062 | 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 |
" |
|
3892 | 93 |
! ! |
94 |
||
95 |
!FileDialog class methodsFor:'instance creation'! |
|
96 |
||
97 |
requestDirectoryName:title default:aFileName ifFail:failBlock |
|
98 |
"same as requestFileName, but only show directories" |
|
99 |
||
4795 | 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. |
|
3892 | 111 |
|
112 |
" |
|
3904 | 113 |
FileDialog |
3892 | 114 |
requestDirectoryName:'which directory ?' |
4627 | 115 |
default:Filename currentDirectory pathName |
3892 | 116 |
ifFail:'none' |
117 |
" |
|
118 |
! |
|
119 |
||
5336 | 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 |
||
5823 | 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 |
||
3956 | 170 |
requestDirectoryName:titleString default:aFileName ok:okText abort:abortText version:versionSymbol pattern:pattern fromDirectory:aDirectoryPath ifFail:failBlock whenBoxCreatedEvaluate:boxCreatedCallback asLoadDialog:aBoolean |
3892 | 171 |
"same as requestFileName, but only show directories" |
172 |
||
3956 | 173 |
|enteredFileName instance enteredFileNameString| |
3892 | 174 |
|
4795 | 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 |
|
5329 | 185 |
viewFiles:false |
4795 | 186 |
multipleSelect:false. |
3892 | 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 ?' |
|
4627 | 225 |
default:Filename currentDirectory pathName |
3892 | 226 |
ifFail:nil |
227 |
" |
|
3956 | 228 |
" |
229 |
FileDialog |
|
230 |
requestDirectoryName:'which directory ?' |
|
4627 | 231 |
default:Filename currentDirectory pathName |
3956 | 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 |
" |
|
3892 | 241 |
! |
242 |
||
5336 | 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 |
FileDialog |
|
260 |
requestDirectoryName:'which directory ?' |
|
261 |
default:Filename currentDirectory pathName |
|
262 |
ok:'Yes' |
|
263 |
ifFail:'none' |
|
264 |
" |
|
265 |
! |
|
266 |
||
3892 | 267 |
requestFileName:titleString default:defaultName ok:okText abort:abortText pattern:pattern fromDirectory:aDirectoryPathOrNil whenBoxCreatedEvaluate:boxCreatedCallback |
268 |
||
4795 | 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 |
|
3892 | 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 |
||
4795 | 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 |
|
3956 | 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 |
||
3892 | 326 |
|
3904 | 327 |
| instance enteredFileName enteredFileNameString| |
3892 | 328 |
|
4795 | 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 |
|
5329 | 339 |
viewFiles:true |
4795 | 340 |
multipleSelect:false. |
3892 | 341 |
|
342 |
enteredFileNameString := instance result. |
|
3938 | 343 |
(enteredFileNameString isNil or:[enteredFileNameString isEmpty]) ifTrue:[ |
3892 | 344 |
^ failBlock value |
345 |
]. |
|
346 |
enteredFileName := enteredFileNameString asFilename. |
|
5867 | 347 |
enteredFileNameString := enteredFileName asString. |
5858
d5648b365b8d
returns construct with defaultName if directory selected on requestFilename
penk
parents:
5853
diff
changeset
|
348 |
|
3892 | 349 |
(enteredFileName notNil |
350 |
and:[enteredFileNameString notEmpty]) ifTrue:[ |
|
4666 | 351 |
FileSelectionBox lastFileSelectionDirectory:(enteredFileName directoryName). |
3892 | 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 |
|
3956 | 376 |
" |
377 |
FileDialog |
|
378 |
requestFileName:'enter a fileName:' |
|
379 |
default:'' |
|
380 |
ok:nil |
|
381 |
abort:nil |
|
382 |
version:nil |
|
383 |
ifFail:['none'] |
|
5858
d5648b365b8d
returns construct with defaultName if directory selected on requestFilename
penk
parents:
5853
diff
changeset
|
384 |
pattern:'*' |
4627 | 385 |
fromDirectory:Filename currentDirectory pathName |
3956 | 386 |
whenBoxCreatedEvaluate:nil |
387 |
asLoadDialog:true |
|
388 |
" |
|
3892 | 389 |
! |
390 |
||
391 |
requestFileName:titleString default:defaultName version:versionSymbol ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPathOrNil whenBoxCreatedEvaluate:boxCreatedCallback |
|
392 |
||
4795 | 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 |
|
3892 | 403 |
|
404 |
" |
|
405 |
FileDialog |
|
406 |
requestFileName:'enter a fileName:' |
|
407 |
default:'' |
|
408 |
version:nil |
|
409 |
ifFail:['none'] |
|
410 |
pattern:'*.conf' |
|
4627 | 411 |
fromDirectory:Filename currentDirectory pathName |
3892 | 412 |
whenBoxCreatedEvaluate:nil. |
413 |
Dialog |
|
414 |
requestFileName:'enter a fileName:' |
|
415 |
default:'' |
|
416 |
version:nil |
|
417 |
ifFail:['none'] |
|
418 |
pattern:'*.conf' |
|
4627 | 419 |
fromDirectory:Filename currentDirectory pathName |
3892 | 420 |
whenBoxCreatedEvaluate:nil |
421 |
" |
|
422 |
" |
|
423 |
FileDialog |
|
424 |
requestFileName:'enter a fileName:' |
|
425 |
default:'' |
|
426 |
version:#old |
|
427 |
ifFail:['none'] |
|
428 |
pattern:'*.conf' |
|
4627 | 429 |
fromDirectory:Filename currentDirectory pathName |
3892 | 430 |
whenBoxCreatedEvaluate:nil |
431 |
" |
|
432 |
" |
|
433 |
FileDialog |
|
434 |
requestFileName:'enter a fileName:' |
|
435 |
default:'' |
|
436 |
version:#mustBeNew |
|
437 |
ifFail:['none'] |
|
438 |
pattern:'*.conf' |
|
4627 | 439 |
fromDirectory:Filename currentDirectory pathName |
3892 | 440 |
whenBoxCreatedEvaluate:nil |
441 |
" |
|
3904 | 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. |
|
3905 | 450 |
Return all selected Filenames as filenames in a collection, or nil if cancel was pressed |
3904 | 451 |
" |
452 |
||
453 |
||
4795 | 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. |
|
3956 | 464 |
|
465 |
||
466 |
" |
|
467 |
FileDialog |
|
468 |
requestFileNames:'enter a fileName:' |
|
469 |
default:'' |
|
470 |
ok:nil |
|
471 |
abort:nil |
|
472 |
ifFail:['none'] |
|
473 |
pattern:'*.conf' |
|
4627 | 474 |
fromDirectory:Filename currentDirectory pathName |
3956 | 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 |
||
3904 | 489 |
| instance enteredFileNames lastDirectory| |
490 |
||
4795 | 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 |
|
5329 | 501 |
viewFiles:true |
4795 | 502 |
multipleSelect:true. |
3904 | 503 |
|
3996 | 504 |
enteredFileNames := instance currentSelectedFiles. |
3904 | 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' |
|
4627 | 521 |
fromDirectory:Filename currentDirectory pathName |
3956 | 522 |
whenBoxCreatedEvaluate:nil |
523 |
asLoadDialog:true. |
|
3904 | 524 |
" |
525 |
! |
|
526 |
||
5790 | 527 |
startApplicationFor:titleString default:initialDefaultFileNameArg ok:okTextArg abort:abortTextArg ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPath whenBoxCreatedEvaluate:boxCreatedCallback asLoadDialog:asLoadDialog viewFiles:viewFiles multipleSelect:multipleSelect |
3904 | 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 |
||
5790 | 544 |
|defaultDir instance defaultFile okText abortText initialDefaultFileName| |
545 |
||
546 |
initialDefaultFileName := initialDefaultFileNameArg. |
|
547 |
initialDefaultFileName notNil ifTrue:[ |
|
548 |
initialDefaultFileName := initialDefaultFileName asFilename |
|
549 |
]. |
|
5163 | 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' ]. |
|
3904 | 555 |
|
556 |
defaultDir := aDirectoryPath. |
|
5220
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
557 |
"/ defaultDir isNil ifTrue:[ |
5790 | 558 |
"/ (initialDefaultFileName size > 0 and:[initialDefaultFileName exists]) ifTrue:[ |
559 |
"/ defaultDir := initialDefaultFileName asAbsoluteFilename directory. |
|
5220
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
560 |
"/ ] ifFalse:[ |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
561 |
"/ defaultDir := FileSelectionBox lastFileSelectionDirectory. |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
562 |
"/ defaultDir isNil ifTrue:[ |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
563 |
"/ defaultDir := Filename currentDirectory asAbsoluteFilename. |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
564 |
"/ ]. |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
565 |
"/ defaultDir asFilename exists ifFalse:[ |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
566 |
"/ defaultDir := nil |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
567 |
"/ ]. |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
568 |
"/ ] |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
569 |
"/ ]. |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
570 |
(initialDefaultFileName notNil |
5790 | 571 |
and:[initialDefaultFileName isAbsolute |
5220
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
572 |
and:[true "initialDefaultFileName asFilename exists"]]) ifTrue:[ |
5790 | 573 |
defaultDir := initialDefaultFileName asAbsoluteFilename. |
5329 | 574 |
viewFiles ifTrue:[ |
5220
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
575 |
defaultDir := defaultDir directory. |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
576 |
]. |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
577 |
] ifFalse:[ |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
578 |
defaultDir isNil ifTrue:[ |
5193 | 579 |
defaultDir := FileSelectionBox lastFileSelectionDirectory. |
580 |
defaultDir isNil ifTrue:[ |
|
581 |
defaultDir := Filename currentDirectory asAbsoluteFilename. |
|
582 |
]. |
|
5188
283a77f6efe2
care for non-existing initial dir.
Claus Gittinger <cg@exept.de>
parents:
5173
diff
changeset
|
583 |
defaultDir asFilename exists ifFalse:[ |
283a77f6efe2
care for non-existing initial dir.
Claus Gittinger <cg@exept.de>
parents:
5173
diff
changeset
|
584 |
defaultDir := nil |
283a77f6efe2
care for non-existing initial dir.
Claus Gittinger <cg@exept.de>
parents:
5173
diff
changeset
|
585 |
]. |
3956 | 586 |
] |
3904 | 587 |
]. |
4206 | 588 |
defaultDir := defaultDir asFilename asAbsoluteFilename. |
5220
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
589 |
"/ [defaultDir exists] whileFalse:[ |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
590 |
"/ defaultDir := defaultDir directory. |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
591 |
"/ ]. |
5066
57de46852214
Do not select '/tmp/tmp' if '/tmp' is given as default directory
Stefan Vogel <sv@exept.de>
parents:
5062
diff
changeset
|
592 |
|
5329 | 593 |
viewFiles ifFalse:[ |
5790 | 594 |
defaultFile := defaultDir asAbsoluteFilename. |
5329 | 595 |
] ifTrue:[ |
5790 | 596 |
(initialDefaultFileName notNil and:[initialDefaultFileName withoutSuffix baseName ~= '*']) ifTrue:[ |
597 |
defaultFile := defaultDir construct:initialDefaultFileName baseName. |
|
3956 | 598 |
]. |
3904 | 599 |
]. |
4562 | 600 |
defaultFile isNil ifTrue:[ |
601 |
defaultFile := defaultDir. |
|
602 |
]. |
|
3956 | 603 |
|
3904 | 604 |
instance := self new. |
5066
57de46852214
Do not select '/tmp/tmp' if '/tmp' is given as default directory
Stefan Vogel <sv@exept.de>
parents:
5062
diff
changeset
|
605 |
defaultDir notNil ifTrue:[instance directory:defaultDir]. |
3958 | 606 |
instance multipleSelect:multipleSelect ? false. |
3904 | 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. |
|
5571
333ee892a087
thumbsUp/Down in confirm dialog
Claus Gittinger <cg@exept.de>
parents:
5375
diff
changeset
|
612 |
|
4804 | 613 |
instance beLoadDialog:asLoadDialog ? false. |
5329 | 614 |
instance viewFiles:viewFiles ? true. |
3953 | 615 |
self setDoubleClickActionFor:instance. |
3904 | 616 |
instance allButOpenInterface:#windowSpec. |
617 |
boxCreatedCallback notNil ifTrue:[boxCreatedCallback value:instance]. |
|
4603
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
618 |
|
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
619 |
Dialog aboutToOpenBoxNotificationSignal raiseRequestWith:instance. |
5853 | 620 |
|
3904 | 621 |
instance openWindowModal. |
622 |
^ instance |
|
3892 | 623 |
! ! |
624 |
||
625 |
!FileDialog class methodsFor:'accessing'! |
|
626 |
||
5931 | 627 |
lastExtent |
628 |
^ LastExtent |
|
629 |
! |
|
630 |
||
631 |
lastExtent:anExtent |
|
632 |
LastExtent := anExtent |
|
633 |
! |
|
634 |
||
3953 | 635 |
setDoubleClickActionFor:instance |
636 |
||
637 |
instance doubleClickAction:[:anIndex| |
|
638 |
| item | |
|
639 |
item := instance treeBrowser fileList at:anIndex ifAbsent:nil. |
|
640 |
item notNil ifTrue:[ |
|
5329 | 641 |
(instance viewFiles and:[item isDirectory not]) ifTrue:[ |
3953 | 642 |
instance doAccept. |
643 |
] |
|
644 |
] |
|
645 |
]. |
|
3892 | 646 |
! ! |
647 |
||
4603
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
648 |
!FileDialog class methodsFor:'active help'! |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
649 |
|
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
650 |
flyByHelpSpec |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
651 |
<resource: #help> |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
652 |
|
5966 | 653 |
|spec| |
4603
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
654 |
|
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
655 |
spec := super flyByHelpSpec addPairsFrom:#( |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
656 |
|
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
657 |
#directoryUp |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
658 |
'Directory Up' |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
659 |
|
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
660 |
#directoryBack |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
661 |
'Directory Back' |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
662 |
|
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
663 |
#directoryForward |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
664 |
'Directory Forward' |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
665 |
|
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
666 |
#directoryHistory |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
667 |
'Directory' |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
668 |
|
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
669 |
#fileHome |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
670 |
'Home Directory' |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
671 |
|
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
672 |
#fileGotoDefault |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
673 |
'Default Directory (ST/X Start Directory)' |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
674 |
|
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
675 |
#fileHistory |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
676 |
'File History' |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
677 |
|
5966 | 678 |
#fileBrowse |
679 |
'Browse' |
|
680 |
||
4603
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
681 |
). |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
682 |
|
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
683 |
"/ hist := self directoryHistory. |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
684 |
"/ hist notNil ifTrue:[ |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
685 |
"/ hist canForward ifTrue:[ |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
686 |
"/ spec at:#directoryForward put:(self classResources string:'Forward to: %1' with:hist nextForwardItem). |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
687 |
"/ ]. |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
688 |
"/ hist canBackward ifTrue:[ |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
689 |
"/ spec at:#directoryBack put:(self classResources string:'Back to: %1' with:hist nextBackwardItem). |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
690 |
"/ ]. |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
691 |
"/ ]. |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
692 |
^ spec. |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
693 |
|
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
694 |
" |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
695 |
self flyByHelpSpec |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
696 |
" |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
697 |
! ! |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
698 |
|
3892 | 699 |
!FileDialog class methodsFor:'interface specs'! |
700 |
||
701 |
windowSpec |
|
702 |
"This resource specification was automatically generated |
|
703 |
by the UIPainter of ST/X." |
|
704 |
||
705 |
"Do not manually edit this!! If it is corrupted, |
|
706 |
the UIPainter may not be able to read the specification." |
|
707 |
||
708 |
" |
|
709 |
UIPainter new openOnClass:FileDialog andSelector:#windowSpec |
|
710 |
FileDialog new openInterface:#windowSpec |
|
711 |
FileDialog open |
|
712 |
" |
|
713 |
||
714 |
<resource: #canvas> |
|
715 |
||
716 |
^ |
|
5229 | 717 |
#(FullSpec |
718 |
name: windowSpec |
|
719 |
window: |
|
720 |
(WindowSpec |
|
721 |
label: 'FileDialog' |
|
722 |
name: 'FileDialog' |
|
723 |
min: (Point 10 10) |
|
724 |
max: (Point 1024 768) |
|
5873 | 725 |
bounds: (Rectangle 0 0 407 400) |
3892 | 726 |
) |
5229 | 727 |
component: |
728 |
(SpecCollection |
|
729 |
collection: ( |
|
730 |
(ViewSpec |
|
731 |
name: 'FilePart' |
|
732 |
layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 -32 1.0) |
|
733 |
component: |
|
734 |
(SpecCollection |
|
735 |
collection: ( |
|
736 |
(MenuPanelSpec |
|
737 |
name: 'ToolBar1' |
|
738 |
layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 30 0) |
|
739 |
tabable: true |
|
740 |
menu: toolBarMenu |
|
741 |
textDefault: true |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
742 |
) |
5229 | 743 |
(SubCanvasSpec |
744 |
name: 'DirectoryTreeBrowser' |
|
745 |
layout: (LayoutFrame 0 0.0 55 0 0 1.0 -30 1) |
|
746 |
tabable: true |
|
747 |
hasHorizontalScrollBar: false |
|
748 |
hasVerticalScrollBar: false |
|
749 |
majorKey: DirectoryTreeBrowser |
|
750 |
createNewApplication: true |
|
751 |
createNewBuilder: true |
|
752 |
postBuildCallback: postBuildTreeBrowser: |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
753 |
) |
5229 | 754 |
(VariableHorizontalPanelSpec |
755 |
name: 'VariableHorizontalPanel1' |
|
756 |
layout: (LayoutFrame 0 0 30 0 0 1 55 0) |
|
757 |
level: 1 |
|
758 |
showHandle: false |
|
759 |
component: |
|
760 |
(SpecCollection |
|
761 |
collection: ( |
|
762 |
(ViewSpec |
|
763 |
name: 'Box1' |
|
4804 | 764 |
) |
5229 | 765 |
(ViewSpec |
766 |
name: 'Box2' |
|
767 |
component: |
|
768 |
(SpecCollection |
|
769 |
collection: ( |
|
770 |
(LabelSpec |
|
771 |
label: 'Filter:' |
|
772 |
name: 'FilterLabel' |
|
773 |
layout: (LayoutFrame 8 0 2 0 59 0 -2 1) |
|
774 |
translateLabel: true |
|
775 |
adjust: right |
|
4804 | 776 |
) |
5229 | 777 |
(InputFieldSpec |
778 |
name: 'FilterEntryField' |
|
779 |
layout: (LayoutFrame 60 0 -22 1 -2 1 -2 1) |
|
780 |
model: filterHolder |
|
781 |
immediateAccept: true |
|
782 |
acceptOnReturn: true |
|
783 |
acceptOnTab: true |
|
784 |
acceptOnLostFocus: true |
|
785 |
acceptOnPointerLeave: false |
|
786 |
postBuildCallback: postBuildFilterField: |
|
4804 | 787 |
) |
788 |
) |
|
789 |
||
790 |
) |
|
791 |
) |
|
792 |
) |
|
793 |
||
794 |
) |
|
5873 | 795 |
handles: (Any 0.636364 1.0) |
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
796 |
) |
5230 | 797 |
(LabelSpec |
798 |
label: 'Filename:' |
|
799 |
name: 'FilenameLabel' |
|
800 |
layout: (LayoutFrame 3 0 -21 1 73 0 -1 1) |
|
801 |
translateLabel: true |
|
802 |
labelChannel: filenameLabelHolder |
|
803 |
adjust: left |
|
804 |
) |
|
805 |
(FilenameInputFieldSpec |
|
806 |
name: 'FilenameEntryField' |
|
807 |
layout: (LayoutFrame 70 0 -21 1 -4 1 -1 1) |
|
808 |
tabable: true |
|
809 |
model: filenameHolder |
|
810 |
immediateAccept: false |
|
811 |
acceptOnPointerLeave: false |
|
5853 | 812 |
hasKeyboardFocusInitially: true |
5230 | 813 |
postBuildCallback: postBuildFileNameField: |
814 |
) |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
815 |
) |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
816 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
817 |
) |
3892 | 818 |
) |
5229 | 819 |
(HorizontalPanelViewSpec |
820 |
name: 'ButtonPanel' |
|
821 |
layout: (LayoutFrame 0 0.0 -32 1 0 1 0 1) |
|
822 |
visibilityChannel: buttonPanelVisibleHolder |
|
823 |
horizontalLayout: fitSpace |
|
824 |
verticalLayout: center |
|
825 |
horizontalSpace: 3 |
|
826 |
verticalSpace: 3 |
|
827 |
reverseOrderIfOKAtLeft: true |
|
828 |
component: |
|
829 |
(SpecCollection |
|
830 |
collection: ( |
|
831 |
(ActionButtonSpec |
|
832 |
label: 'Cancel' |
|
833 |
name: 'cancelButton' |
|
834 |
translateLabel: true |
|
835 |
labelChannel: cancelLabelHolder |
|
836 |
tabable: true |
|
837 |
model: doCancel |
|
5873 | 838 |
extent: (Point 131 22) |
4603
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
839 |
) |
5229 | 840 |
(ActionButtonSpec |
841 |
label: 'Append' |
|
842 |
name: 'appendButton' |
|
843 |
visibilityChannel: appendButtonVisibleHolder |
|
844 |
translateLabel: true |
|
845 |
labelChannel: appendLabelHolder |
|
846 |
tabable: true |
|
847 |
model: appendPressed |
|
5873 | 848 |
extent: (Point 132 22) |
3892 | 849 |
) |
5229 | 850 |
(ActionButtonSpec |
851 |
label: 'OK' |
|
852 |
name: 'okButton' |
|
853 |
translateLabel: true |
|
854 |
labelChannel: okLabelHolder |
|
855 |
tabable: true |
|
856 |
model: okPressed |
|
857 |
isDefault: true |
|
5873 | 858 |
extent: (Point 132 22) |
3892 | 859 |
) |
860 |
) |
|
861 |
||
862 |
) |
|
863 |
) |
|
864 |
) |
|
865 |
||
866 |
) |
|
867 |
) |
|
868 |
! ! |
|
869 |
||
870 |
!FileDialog class methodsFor:'menu specs'! |
|
871 |
||
872 |
toolBarMenu |
|
873 |
"This resource specification was automatically generated |
|
874 |
by the MenuEditor of ST/X." |
|
875 |
||
876 |
"Do not manually edit this!! If it is corrupted, |
|
877 |
the MenuEditor may not be able to read the specification." |
|
878 |
||
879 |
" |
|
880 |
MenuEditor new openOnClass:FileDialog andSelector:#toolBarMenu |
|
881 |
(Menu new fromLiteralArrayEncoding:(FileDialog toolBarMenu)) startUp |
|
882 |
" |
|
883 |
||
884 |
<resource: #menu> |
|
885 |
||
886 |
^ |
|
5873 | 887 |
#(Menu |
888 |
( |
|
889 |
(MenuItem |
|
890 |
activeHelpKey: directoryUp |
|
891 |
enabled: enableDirectoryUp |
|
892 |
label: 'DirectoryUp' |
|
893 |
itemValue: doGoDirectoryUp |
|
894 |
translateLabel: true |
|
895 |
isButton: true |
|
896 |
labelImage: (ResourceRetriever AbstractFileBrowser upArrow20x20Icon) |
|
897 |
) |
|
898 |
(MenuItem |
|
899 |
label: '' |
|
3892 | 900 |
) |
5873 | 901 |
(MenuItem |
902 |
activeHelpKey: directoryBack |
|
903 |
enabled: enableBack |
|
904 |
label: 'Back' |
|
905 |
itemValue: doBack |
|
906 |
translateLabel: true |
|
907 |
isButton: true |
|
908 |
submenuChannel: menuDirHistoryBack |
|
909 |
labelImage: (ResourceRetriever AbstractFileBrowser leftArrow20x20Icon) |
|
910 |
keepLinkedMenu: true |
|
3892 | 911 |
) |
5873 | 912 |
(MenuItem |
913 |
label: '' |
|
3892 | 914 |
) |
5873 | 915 |
(MenuItem |
916 |
activeHelpKey: directoryForward |
|
917 |
enabled: enableForward |
|
918 |
label: 'Forward' |
|
919 |
itemValue: doForward |
|
920 |
translateLabel: true |
|
921 |
isButton: true |
|
922 |
submenuChannel: menuDirHistoryForward |
|
923 |
labelImage: (ResourceRetriever AbstractFileBrowser rightArrow20x20Icon) |
|
924 |
keepLinkedMenu: true |
|
3892 | 925 |
) |
5873 | 926 |
(MenuItem |
927 |
label: '' |
|
3892 | 928 |
) |
5873 | 929 |
(MenuItem |
930 |
activeHelpKey: fileHome |
|
931 |
enabled: enableHome |
|
932 |
label: 'Home' |
|
933 |
itemValue: doGotoHomeDirectory |
|
934 |
translateLabel: true |
|
935 |
isButton: true |
|
936 |
labelImage: (ResourceRetriever AbstractFileBrowser goHomeIcon) |
|
3892 | 937 |
) |
5873 | 938 |
(MenuItem |
939 |
label: '-' |
|
5966 | 940 |
isVisible: browseVisibleHolder |
941 |
) |
|
942 |
(MenuItem |
|
943 |
activeHelpKey: fileBrowse |
|
944 |
label: 'Browse' |
|
945 |
itemValue: doBrowseDirectory |
|
946 |
translateLabel: true |
|
947 |
isButton: true |
|
948 |
isVisible: browseVisibleHolder |
|
949 |
labelImage: (ResourceRetriever ToolbarIconLibrary fileBrowser24x24Icon) |
|
950 |
) |
|
951 |
(MenuItem |
|
952 |
label: '-' |
|
5873 | 953 |
isVisible: newDirectoryVisibilityHolder |
3923 | 954 |
) |
5873 | 955 |
(MenuItem |
956 |
label: 'New Directory' |
|
957 |
itemValue: newDirectory |
|
958 |
translateLabel: true |
|
959 |
isButton: true |
|
960 |
isVisible: newDirectoryVisibilityHolder |
|
961 |
labelImage: (ResourceRetriever AbstractFileBrowser newDirectory20x20Icon) |
|
3923 | 962 |
) |
3892 | 963 |
) |
964 |
nil |
|
965 |
nil |
|
966 |
) |
|
967 |
! ! |
|
968 |
||
969 |
!FileDialog methodsFor:'accessing'! |
|
970 |
||
3996 | 971 |
currentSelectedFiles |
972 |
||
973 |
| selectedFiles| |
|
974 |
||
975 |
selectedFiles := treeBrowser currentFileNameHolder value. |
|
976 |
^ selectedFiles select:[:aFile| aFile isDirectory not]. |
|
977 |
! |
|
978 |
||
3892 | 979 |
directory |
980 |
"return the value of the instance variable 'directory' (automatically generated)" |
|
981 |
||
982 |
^ directory |
|
983 |
! |
|
984 |
||
985 |
directory:something |
|
986 |
"set the value of the instance variable 'directory' (automatically generated)" |
|
987 |
||
988 |
directory := something. |
|
989 |
! |
|
990 |
||
991 |
initialText |
|
992 |
||
5598 | 993 |
initialText isNil ifTrue:[ |
994 |
^ resources string:'File Dialog'. |
|
995 |
]. |
|
996 |
^ resources string:initialText |
|
3892 | 997 |
! |
998 |
||
999 |
initialText:something |
|
1000 |
"set the value of the instance variable 'initialText' (automatically generated)" |
|
1001 |
||
1002 |
initialText := something. |
|
1003 |
! |
|
1004 |
||
1005 |
pattern |
|
1006 |
"return the value of the instance variable 'pattern' (automatically generated)" |
|
1007 |
||
1008 |
^ pattern |
|
1009 |
! |
|
1010 |
||
1011 |
pattern:something |
|
1012 |
"set the value of the instance variable 'pattern' (automatically generated)" |
|
1013 |
||
1014 |
pattern := something. |
|
1015 |
! |
|
1016 |
||
1017 |
result |
|
1018 |
"return the value of the instance variable 'result' (automatically generated)" |
|
1019 |
||
1020 |
^ result |
|
1021 |
! |
|
1022 |
||
1023 |
result:something |
|
1024 |
"set the value of the instance variable 'result' (automatically generated)" |
|
1025 |
||
1026 |
result := something. |
|
1027 |
! |
|
1028 |
||
3904 | 1029 |
selectedDirectories |
1030 |
||
1031 |
| selectedFiles| |
|
1032 |
||
1033 |
selectedFiles := treeBrowser currentFileNameHolder value. |
|
1034 |
^ selectedFiles select:[:aFile| aFile isDirectory]. |
|
1035 |
! |
|
1036 |
||
3892 | 1037 |
startFilename |
1038 |
"return the value of the instance variable 'startFilename' (automatically generated)" |
|
1039 |
||
1040 |
startFilename isNil ifTrue:[ |
|
1041 |
startFilename := Filename currentDirectory asAbsoluteFilename. |
|
1042 |
]. |
|
1043 |
^ startFilename |
|
1044 |
! |
|
1045 |
||
1046 |
startFilename:something |
|
1047 |
"set the value of the instance variable 'startFilename' (automatically generated)" |
|
1048 |
||
1049 |
startFilename := something. |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1050 |
! ! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1051 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1052 |
!FileDialog methodsFor:'accessing-behavior'! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1053 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1054 |
asLoadDialog |
4804 | 1055 |
^ self isLoadDialog |
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1056 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1057 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1058 |
asLoadDialog:aBoolean |
4804 | 1059 |
self beLoadDialog:aBoolean |
1060 |
! |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1061 |
|
4804 | 1062 |
beLoadDialog:aBoolean |
1063 |
||
1064 |
isLoadDialog := aBoolean |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1065 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1066 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1067 |
doubleClickAction |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1068 |
"return the value of the instance variable 'doubleClickAction' (automatically generated)" |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1069 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1070 |
^ doubleClickAction |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1071 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1072 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1073 |
doubleClickAction:something |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1074 |
"set the value of the instance variable 'doubleClickAction' (automatically generated)" |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1075 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1076 |
doubleClickAction := something. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1077 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1078 |
|
4804 | 1079 |
isLoadDialog |
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1080 |
|
4804 | 1081 |
^ isLoadDialog ? true |
1082 |
! |
|
1083 |
||
1084 |
multipleSelect |
|
1085 |
^ multipleSelect ? false |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1086 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1087 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1088 |
multipleSelect:aBoolean |
4804 | 1089 |
multipleSelect := aBoolean. |
1090 |
treeBrowser notNil ifTrue:[ |
|
1091 |
treeBrowser multipleSelect:aBoolean. |
|
1092 |
]. |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1093 |
! ! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1094 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1095 |
!FileDialog methodsFor:'accessing-components'! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1096 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1097 |
addButton:aButton |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1098 |
DialogBox defaultOKButtonAtLeft ifTrue:[ |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1099 |
(self componentAt:#ButtonPanel) addSubView:aButton before:(self okButton) |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1100 |
] ifFalse:[ |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1101 |
(self componentAt:#ButtonPanel) addSubView:aButton after:(self okButton) |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1102 |
]. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1103 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1104 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1105 |
okButton |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1106 |
^ (self componentAt:#okButton) |
3892 | 1107 |
! |
1108 |
||
3904 | 1109 |
treeBrowser |
1110 |
"return the value of the instance variable 'treeBrowser' (automatically generated)" |
|
1111 |
||
1112 |
^ treeBrowser |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1113 |
! ! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1114 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1115 |
!FileDialog methodsFor:'accessing-look'! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1116 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1117 |
hideButtonPanel |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1118 |
self buttonPanelVisibleHolder value:false |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1119 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1120 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1121 |
newDirectoryVisibilityHolder |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1122 |
newDirectoryVisibilityHolder isNil ifTrue:[ |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1123 |
newDirectoryVisibilityHolder := true asValue. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1124 |
]. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1125 |
^ newDirectoryVisibilityHolder |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1126 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1127 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1128 |
showButtonPanel |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1129 |
self buttonPanelVisibleHolder value:true |
3904 | 1130 |
! |
1131 |
||
3892 | 1132 |
viewFiles |
1133 |
"return the value of the instance variable 'viewFiles' (automatically generated)" |
|
1134 |
||
1135 |
^ viewFiles |
|
1136 |
! |
|
1137 |
||
1138 |
viewFiles:something |
|
1139 |
"set the value of the instance variable 'viewFiles' (automatically generated)" |
|
1140 |
||
1141 |
viewFiles := something. |
|
1142 |
! ! |
|
1143 |
||
1144 |
!FileDialog methodsFor:'aspects'! |
|
1145 |
||
4603
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1146 |
appendButtonVisibleHolder |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1147 |
appendButtonVisibleHolder isNil ifTrue:[ |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1148 |
appendButtonVisibleHolder := false asValue. |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1149 |
]. |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1150 |
^ appendButtonVisibleHolder |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1151 |
! |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1152 |
|
5193 | 1153 |
appendLabelHolder |
1154 |
appendLabelHolder isNil ifTrue:[ |
|
1155 |
appendLabelHolder := 'Append' asValue. |
|
1156 |
]. |
|
1157 |
^ appendLabelHolder |
|
1158 |
! |
|
1159 |
||
4804 | 1160 |
aspectOrNil:aKey forSubApplication:aSubApp |
1161 |
"this hook provides an aspect for a subApp" |
|
1162 |
||
1163 |
aKey == #currentFileNameHolder ifTrue:[ |
|
1164 |
directory notNil ifTrue:[ |
|
1165 |
^ (OrderedCollection with:directory) asValue |
|
1166 |
] |
|
1167 |
]. |
|
1168 |
^ nil |
|
1169 |
! |
|
1170 |
||
5969 | 1171 |
browseVisibleHolder |
1172 |
browseVisibleHolder isNil ifTrue:[ |
|
1173 |
browseVisibleHolder := false asValue. |
|
1174 |
]. |
|
1175 |
^ browseVisibleHolder. |
|
1176 |
! |
|
1177 |
||
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1178 |
buttonPanelVisibleHolder |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1179 |
buttonPanelVisibleHolder isNil ifTrue:[ |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1180 |
buttonPanelVisibleHolder := true asValue. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1181 |
buttonPanelVisibleHolder onChangeSend:#buttonPanelVisibilityChanged to:self. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1182 |
]. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1183 |
^ buttonPanelVisibleHolder. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1184 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1185 |
|
3892 | 1186 |
cancelLabelHolder |
1187 |
||
1188 |
cancelLabelHolder isNil ifTrue:[ |
|
1189 |
cancelLabelHolder := 'Cancel' asValue. |
|
1190 |
]. |
|
1191 |
^ cancelLabelHolder. |
|
1192 |
! |
|
1193 |
||
1194 |
enableBack |
|
4804 | 1195 |
^ treeBrowser enableBack. |
3892 | 1196 |
! |
1197 |
||
1198 |
enableDirectoryUp |
|
4804 | 1199 |
^ treeBrowser enableDirectoryUp. |
3892 | 1200 |
! |
1201 |
||
1202 |
enableForward |
|
4804 | 1203 |
^ treeBrowser enableForward. |
3892 | 1204 |
! |
1205 |
||
1206 |
enableHome |
|
4804 | 1207 |
^ treeBrowser enableHome. |
3892 | 1208 |
! |
1209 |
||
1210 |
filenameHolder |
|
1211 |
"Return a value holder with the filename. |
|
1212 |
Shown in the filename input-field. |
|
1213 |
Being the selection in the tree. |
|
1214 |
" |
|
1215 |
|holder| |
|
1216 |
holder := builder bindingAt:#filenameHolder. |
|
1217 |
||
1218 |
holder ifNil:[ |
|
1219 |
holder := ValueHolder new. |
|
1220 |
holder addDependent:self. |
|
1221 |
builder aspectAt:#filenameHolder |
|
1222 |
put:holder. |
|
1223 |
]. |
|
1224 |
||
1225 |
^ holder. |
|
1226 |
! |
|
1227 |
||
3904 | 1228 |
filenameLabelHolder |
1229 |
"Return a value holder for the input string. |
|
1230 |
" |
|
1231 |
filenameLabelHolder isNil ifTrue:[ |
|
1232 |
filenameLabelHolder := 'Filename:' asValue. |
|
1233 |
]. |
|
1234 |
^ filenameLabelHolder |
|
1235 |
! |
|
1236 |
||
3892 | 1237 |
filterHolder |
4011 | 1238 |
"Return a value holder for filter |
3892 | 1239 |
" |
1240 |
||
1241 |
filterHolder isNil ifTrue:[ |
|
1242 |
filterHolder := treeBrowser filterModel. |
|
1243 |
self pattern notNil ifTrue:[ |
|
1244 |
filterHolder value:pattern. |
|
1245 |
] |
|
1246 |
]. |
|
1247 |
^ filterHolder |
|
1248 |
! |
|
1249 |
||
1250 |
okLabelHolder |
|
1251 |
"automatically generated by UIPainter ..." |
|
1252 |
||
1253 |
"*** the code below creates a default model when invoked." |
|
1254 |
"*** (which may not be the one you wanted)" |
|
1255 |
"*** Please change as required and accept it in the browser." |
|
1256 |
"*** (and replace this comment by something more useful ;-)" |
|
1257 |
||
1258 |
okLabelHolder isNil ifTrue:[ |
|
1259 |
okLabelHolder := 'OK' asValue. |
|
1260 |
]. |
|
1261 |
^ okLabelHolder. |
|
1262 |
! ! |
|
1263 |
||
1264 |
!FileDialog methodsFor:'change & update'! |
|
1265 |
||
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1266 |
buttonPanelVisibilityChanged |
5598 | 1267 |
|filePart| |
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1268 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1269 |
filePart := builder componentAt:#FilePart. |
5598 | 1270 |
filePart notNil ifTrue:[ |
1271 |
buttonPanelVisibleHolder value ifTrue:[ |
|
1272 |
filePart layout bottomOffset:-40 |
|
1273 |
] ifFalse:[ |
|
1274 |
filePart layout bottomOffset:0 |
|
1275 |
]. |
|
1276 |
filePart containerChangedSize "/ force resize |
|
1277 |
] |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1278 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1279 |
|
3892 | 1280 |
update:something with:aParameter from:changedObject |
5867 | 1281 |
|files newFile newLabel fn entryFieldFilename| |
3892 | 1282 |
|
1283 |
changedObject == treeBrowser currentFileNameHolder ifTrue:[ |
|
4804 | 1284 |
files := changedObject value. |
3892 | 1285 |
|
1286 |
(files isEmpty) ifTrue:[ |
|
4804 | 1287 |
newFile := nil. |
3892 | 1288 |
] ifFalse:[ |
1289 |
files size == 1 ifTrue:[ |
|
4804 | 1290 |
newFile := files first. |
3892 | 1291 |
] ifFalse:[ |
4804 | 1292 |
newFile := ''. |
3892 | 1293 |
]. |
1294 |
]. |
|
5924 | 1295 |
(self filenameHolder value notNil |
1296 |
and:[newFile notNil |
|
1297 |
and:[newFile asFilename isDirectory]]) ifTrue:[ |
|
5867 | 1298 |
entryFieldFilename := self filenameHolder value asFilename. |
1299 |
self startFilename asFilename baseName = entryFieldFilename baseName ifTrue:[ |
|
1300 |
entryFieldFilename isDirectory not ifTrue:[ |
|
1301 |
newFile := newFile asFilename construct:entryFieldFilename baseName. |
|
1302 |
]. |
|
1303 |
]. |
|
1304 |
]. |
|
4804 | 1305 |
self filenameHolder value:newFile withoutNotifying:self. |
3892 | 1306 |
]. |
4804 | 1307 |
|
3904 | 1308 |
changedObject == treeBrowser viewFilesInDirectoryTree ifTrue:[ |
1309 |
changedObject value ifTrue:[ |
|
4804 | 1310 |
newLabel := 'Filename:'. |
3904 | 1311 |
] ifFalse:[ |
4804 | 1312 |
newLabel := 'Directory:'. |
1313 |
]. |
|
1314 |
self filenameLabelHolder value:(resources string:newLabel) |
|
3904 | 1315 |
]. |
3892 | 1316 |
changedObject == self filenameHolder ifTrue:[ |
4804 | 1317 |
fn := changedObject value asFilename. |
1318 |
(fn exists) ifFalse:[^ self]. |
|
1319 |
treeBrowser currentFileNameHolder value:(OrderedCollection with:fn) withoutNotifying:self. |
|
5949 | 1320 |
fn isDirectory ifTrue:[ |
1321 |
treeBrowser expandEnforceSelectedItems. |
|
1322 |
]. |
|
3892 | 1323 |
]. |
1324 |
^ super update:something with:aParameter from:changedObject |
|
1325 |
! ! |
|
1326 |
||
1327 |
!FileDialog methodsFor:'event handling'! |
|
1328 |
||
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1329 |
appendWasPressed |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1330 |
"valid after the dialog has been closed: true if append was pressed" |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1331 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1332 |
^ appendWasPressed |
3892 | 1333 |
! ! |
1334 |
||
1335 |
!FileDialog methodsFor:'initialization & release'! |
|
1336 |
||
5932 | 1337 |
closeDownViews |
1338 |
self remarkExtent. |
|
1339 |
super closeDownViews. |
|
1340 |
! |
|
1341 |
||
1342 |
closeWindow |
|
1343 |
self remarkExtent. |
|
1344 |
super closeWindow. |
|
1345 |
! |
|
1346 |
||
5903
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1347 |
commonPostOpen |
5934 | 1348 |
|directory rootDirectory selection lastExtent| |
3892 | 1349 |
|
1350 |
"/ self windowGroup addPreEventHook:self. |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1351 |
|
5617
2b10cdfc8b38
oops - do not hide button panel too early
Claus Gittinger <cg@exept.de>
parents:
5598
diff
changeset
|
1352 |
"No ok and cancel buttons, when dialog is part of a larger dialog" |
2b10cdfc8b38
oops - do not hide button panel too early
Claus Gittinger <cg@exept.de>
parents:
5598
diff
changeset
|
1353 |
self window topView isModal ifFalse:[ |
2b10cdfc8b38
oops - do not hide button panel too early
Claus Gittinger <cg@exept.de>
parents:
5598
diff
changeset
|
1354 |
self hideButtonPanel |
2b10cdfc8b38
oops - do not hide button panel too early
Claus Gittinger <cg@exept.de>
parents:
5598
diff
changeset
|
1355 |
]. |
5934 | 1356 |
lastExtent := self class lastExtent. |
1357 |
lastExtent notNil ifTrue:[ |
|
1358 |
self window topView extent:lastExtent. |
|
1359 |
]. |
|
3892 | 1360 |
treeBrowser currentFileNameHolder addDependent:self. |
5598 | 1361 |
treeBrowser doubleClickAction:self doubleClickAction. |
3904 | 1362 |
treeBrowser viewFilesInDirectoryTree addDependent:self. |
5863
e31e066a41d9
root is one up (showing containing directory)
Claus Gittinger <cg@exept.de>
parents:
5858
diff
changeset
|
1363 |
|
e31e066a41d9
root is one up (showing containing directory)
Claus Gittinger <cg@exept.de>
parents:
5858
diff
changeset
|
1364 |
directory := (self directory) ? (Filename currentDirectory asAbsoluteFilename). |
e31e066a41d9
root is one up (showing containing directory)
Claus Gittinger <cg@exept.de>
parents:
5858
diff
changeset
|
1365 |
rootDirectory := directory asFilename directory. |
e31e066a41d9
root is one up (showing containing directory)
Claus Gittinger <cg@exept.de>
parents:
5858
diff
changeset
|
1366 |
treeBrowser rootHolder value:rootDirectory. |
4804 | 1367 |
|
1368 |
treeBrowser viewFilesInDirectoryTree setValue:(self viewFiles ? true). |
|
4796 | 1369 |
treeBrowser viewFilesInDirectoryTree changed. |
5598 | 1370 |
treeBrowser currentFileNameHolder value:(OrderedCollection with:self startFilename). |
4804 | 1371 |
|
1372 |
self isLoadDialog ifTrue:[ |
|
4796 | 1373 |
treeBrowser newVisibilityHolder value:false. |
1374 |
treeBrowser allowFileOperations value:false. |
|
1375 |
self newDirectoryVisibilityHolder value:false. |
|
1376 |
]. |
|
5598 | 1377 |
self filenameHolder value:self startFilename. |
5927 | 1378 |
treeBrowser expandEnforceSelectedItems. |
5929 | 1379 |
|
1380 |
selection := treeBrowser treeSelectionHolder value. |
|
1381 |
selection notEmptyOrNil ifTrue:[ |
|
5930 | 1382 |
selection := selection asCollection first. |
5929 | 1383 |
selection enforcedExpand. |
1384 |
treeBrowser browser makeItemVisible:selection withMinimumLines:5. |
|
1385 |
]. |
|
5598 | 1386 |
self window label:self initialText. |
4796 | 1387 |
! |
1388 |
||
5903
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1389 |
postBuildFileNameField:aWidget |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1390 |
|
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1391 |
filenameField := aWidget. |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1392 |
! |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1393 |
|
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1394 |
postBuildFilterField:aWidget |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1395 |
|
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1396 |
filterField := aWidget. |
4796 | 1397 |
! |
1398 |
||
5903
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1399 |
postBuildTreeBrowser:aSubCanvasView |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1400 |
|
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1401 |
treeBrowser := aSubCanvasView client. |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1402 |
! |
4796 | 1403 |
|
5903
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1404 |
postBuildWith:aBuilder |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1405 |
treeBrowser multipleSelect:multipleSelect. |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1406 |
appendWasPressed := false. |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1407 |
|
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1408 |
(aBuilder componentAt:'cancelButton') cursor:(Cursor thumbsDown). |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1409 |
(aBuilder componentAt:'appendButton') cursor:(Cursor thumbsUp). |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1410 |
(aBuilder componentAt:'okButton') cursor:(Cursor thumbsUp). |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1411 |
|
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
1412 |
^ super postBuildWith:aBuilder |
5932 | 1413 |
! |
1414 |
||
1415 |
remarkExtent |
|
1416 |
self class lastExtent:self window topView extent. |
|
4796 | 1417 |
! ! |
1418 |
||
1419 |
!FileDialog methodsFor:'private'! |
|
1420 |
||
1421 |
returnWasPressedInFilterField |
|
1422 |
|ev| |
|
1423 |
||
1424 |
ev := self windowGroup lastEvent. |
|
1425 |
(ev notNil |
|
1426 |
and:[ev isKeyEvent |
|
1427 |
and:[ev key == #Return |
|
1428 |
and:[( ev targetView isSameOrComponentOf:filterField) |
|
1429 |
or:[false "ev targetView isSameOrComponentOf:filenameField"]]]]) ifTrue:[ |
|
1430 |
^ true |
|
1431 |
]. |
|
1432 |
^ false |
|
1433 |
! |
|
1434 |
||
1435 |
returnWasPressedInFilterOrFilenameField |
|
1436 |
|ev| |
|
1437 |
||
1438 |
ev := self windowGroup lastEvent. |
|
1439 |
(ev notNil |
|
1440 |
and:[ev isKeyEvent |
|
1441 |
and:[ev key == #Return |
|
1442 |
and:[( ev targetView isSameOrComponentOf:filterField) |
|
1443 |
or:[false "ev targetView isSameOrComponentOf:filenameField"]]]]) ifTrue:[ |
|
1444 |
^ true |
|
1445 |
]. |
|
1446 |
^ false |
|
1447 |
! ! |
|
1448 |
||
1449 |
!FileDialog methodsFor:'user actions'! |
|
1450 |
||
1451 |
appendPressed |
|
1452 |
appendWasPressed := true. |
|
1453 |
self commonAcceptAction. |
|
1454 |
! |
|
1455 |
||
1456 |
commonAcceptAction |
|
1457 |
filenameField accept. |
|
1458 |
self result:(self filenameHolder value asString). |
|
1459 |
||
1460 |
^ super doAccept |
|
1461 |
! |
|
1462 |
||
1463 |
doAccept |
|
1464 |
"force accept - ignore in filterField" |
|
1465 |
||
1466 |
self returnWasPressedInFilterField ifTrue:[ |
|
1467 |
^ self |
|
1468 |
]. |
|
4996
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4824
diff
changeset
|
1469 |
treeBrowser hasOpenEditor ifTrue:[ |
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4824
diff
changeset
|
1470 |
"/ have to send the event to the TreeView |
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4824
diff
changeset
|
1471 |
treeBrowser browser closeEditor. |
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4824
diff
changeset
|
1472 |
^ self |
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4824
diff
changeset
|
1473 |
]. |
4796 | 1474 |
appendWasPressed := false. |
1475 |
self commonAcceptAction. |
|
1476 |
! |
|
1477 |
||
1478 |
doBack |
|
1479 |
||
1480 |
treeBrowser doBack. |
|
1481 |
! |
|
1482 |
||
5966 | 1483 |
doBrowseDirectory |
1484 |
UserPreferences fileBrowserClass openOn:(treeBrowser currentDirectory ? treeBrowser rootHolder value). |
|
1485 |
||
1486 |
||
1487 |
! |
|
1488 |
||
4796 | 1489 |
doCancel |
1490 |
||
1491 |
self result:nil. |
|
1492 |
^ super doCancel. |
|
1493 |
! |
|
1494 |
||
1495 |
doForward |
|
1496 |
||
1497 |
treeBrowser doForward. |
|
1498 |
! |
|
1499 |
||
1500 |
doGoDirectoryUp |
|
1501 |
||
1502 |
treeBrowser doGoDirectoryUp. |
|
1503 |
! |
|
1504 |
||
1505 |
doGotoHomeDirectory |
|
1506 |
||
1507 |
treeBrowser doGotoHomeDirectory. |
|
1508 |
! |
|
1509 |
||
1510 |
menuDirHistory:backOrForward |
|
1511 |
||
1512 |
^ treeBrowser menuDirHistory:backOrForward. |
|
1513 |
! |
|
1514 |
||
1515 |
menuDirHistoryBack |
|
1516 |
||
1517 |
^ treeBrowser menuDirHistory:#back. |
|
1518 |
! |
|
1519 |
||
1520 |
menuDirHistoryForward |
|
1521 |
||
1522 |
^ treeBrowser menuDirHistory:#forward. |
|
1523 |
! |
|
1524 |
||
1525 |
newDirectory |
|
1526 |
||
1527 |
^ treeBrowser newDirectory |
|
1528 |
! |
|
1529 |
||
1530 |
okPressed |
|
1531 |
self doAccept |
|
1532 |
! ! |
|
1533 |
||
1534 |
!FileDialog class methodsFor:'documentation'! |
|
1535 |
||
1536 |
version |
|
5982 | 1537 |
^ '$Header: /cvs/stx/stx/libtool/FileDialog.st,v 1.74 2004-08-31 10:28:49 cg Exp $' |
4796 | 1538 |
! ! |