author | Claus Gittinger <cg@exept.de> |
Wed, 19 Feb 2020 21:07:34 +0100 | |
changeset 19478 | fd69284871c4 |
parent 19357 | 0e76e9a27375 |
child 19482 | e8e782b89265 |
permissions | -rw-r--r-- |
19120 | 1 |
"{ Encoding: utf8 }" |
2 |
||
5140 | 3 |
" |
4 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
8250 | 14 |
"{ Package: 'stx:libtool' }" |
15 |
||
15366 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
3892 | 18 |
SimpleDialog subclass:#FileDialog |
19195 | 19 |
instanceVariableNames:'aspects treeBrowser directory pattern filterHolder initialText |
20 |
multipleSelect doubleClickAction cancelLabelHolder okLabelHolder |
|
21 |
startFilename result filterField filenameField viewFiles |
|
22 |
filenameLabelHolder isLoadDialog newDirectoryVisibilityHolder |
|
23 |
appendButtonVisibleHolder appendWasPressed |
|
24 |
buttonPanelVisibleHolder appendLabelHolder |
|
25 |
browseMenuItemVisibleHolder selectedDeviceDrive |
|
26 |
listOfDeviceDrives rootDirectoryHolder initialRoot |
|
27 |
verticalPanelView okLabelEnabled searchInfoBoxVisibleHolder |
|
19478 | 28 |
searchedDirectoryInfoHolder additionalFolderItemsInMenu' |
29 |
classVariableNames:'AdditionalFolderItemsInMenu LastExtent LastFindPattern' |
|
19195 | 30 |
poolDictionaries:'' |
31 |
category:'Interface-Tools-File' |
|
3892 | 32 |
! |
33 |
||
34 |
!FileDialog class methodsFor:'documentation'! |
|
35 |
||
5140 | 36 |
copyright |
37 |
" |
|
38 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
39 |
All Rights Reserved |
|
40 |
||
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
47 |
" |
|
48 |
! |
|
49 |
||
3892 | 50 |
documentation |
51 |
" |
|
9767 | 52 |
A slightly better file dialog |
3892 | 53 |
|
19478 | 54 |
API of interest: |
55 |
[class side] additionalFolderItemsInMenu |
|
56 |
optional list of additional folders to be presented |
|
57 |
in the directory menu. |
|
58 |
If not empty, entries will be added to EVERY file dialog. |
|
59 |
||
60 |
[instance side] additionalFolderItemsInMenu |
|
61 |
optional list of additional folders to be presented in the directory menu. |
|
62 |
If not empty, entries will be added to this file dialog. |
|
63 |
||
3892 | 64 |
[author:] |
65 |
Martin Walser (martin@vercingetorix) |
|
66 |
||
67 |
[instance variables:] |
|
68 |
||
69 |
[class variables:] |
|
70 |
||
71 |
[see also:] |
|
72 |
||
73 |
" |
|
74 |
! |
|
75 |
||
76 |
examples |
|
77 |
" |
|
15451 | 78 |
usually direct access to FileDialog is not recommended; |
79 |
please use the Dialog interface, which is able to dispatch to |
|
80 |
alternative file choosers if the settings say so |
|
81 |
(native dialogs, for example): |
|
3892 | 82 |
[exBegin] |
15451 | 83 |
|fileOrNil| |
84 |
||
85 |
fileOrNil := Dialog requestFileName:'Choose a File'. |
|
86 |
Transcript showCR:fileOrNil |
|
3892 | 87 |
[exEnd] |
88 |
||
15451 | 89 |
simple examples: |
3892 | 90 |
[exBegin] |
5188
283a77f6efe2
care for non-existing initial dir.
Claus Gittinger <cg@exept.de>
parents:
5173
diff
changeset
|
91 |
FileDialog |
4804 | 92 |
requestFileName:'enter a fileName:' |
93 |
default:'' |
|
94 |
version:nil |
|
95 |
ifFail:['none'] |
|
96 |
pattern:'*.conf' |
|
97 |
fromDirectory:'/etc' |
|
98 |
whenBoxCreatedEvaluate:nil. |
|
99 |
[exEnd] |
|
15451 | 100 |
|
4804 | 101 |
[exBegin] |
102 |
|fd| |
|
103 |
||
104 |
fd := FileDialog new. |
|
105 |
fd multipleSelect:true. |
|
106 |
fd open |
|
3892 | 107 |
[exEnd] |
12816 | 108 |
|
15451 | 109 |
[exBegin] |
110 |
|fd| |
|
111 |
||
112 |
fd := FileDialog new. |
|
113 |
fd multipleSelect:true. |
|
114 |
fd browseMenuItemVisible:false. |
|
115 |
fd open |
|
116 |
[exEnd] |
|
117 |
||
12816 | 118 |
Adding custom components: |
119 |
[exBegin] |
|
15451 | 120 |
Dialog modifyingBoxWith:[:dialog | |
12816 | 121 |
| fmtBox | |
122 |
||
123 |
fmtBox := ComboListView new. |
|
124 |
fmtBox list: #('Comma Separated Values (.csv)' |
|
125 |
'Microsoft Excel (.xls)' |
|
126 |
'Microsoft Excel XML (.xlsx)') . |
|
127 |
fmtBox model:'Select...' asValue. |
|
15451 | 128 |
dialog application addComponent: fmtBox. |
12816 | 129 |
] do:[ |
130 |
Dialog requestFileName: 'Save file as...' |
|
131 |
] |
|
132 |
[exEnd] |
|
133 |
||
3892 | 134 |
" |
5062 | 135 |
! |
136 |
||
137 |
todo |
|
138 |
" |
|
17527 | 139 |
- make the filedialog windows like |
140 |
filename entry field shows only the filename not the whole directory |
|
141 |
the tree always starts in current directory |
|
142 |
the parent tree is shown in a combobox where the perents are selectable |
|
9769 | 143 |
|
17527 | 144 |
- do not expand the ~ or relative pathnames to absolute pathnames |
5062 | 145 |
" |
3892 | 146 |
! ! |
147 |
||
148 |
!FileDialog class methodsFor:'instance creation'! |
|
149 |
||
150 |
requestDirectoryName:title default:aFileName ifFail:failBlock |
|
151 |
"same as requestFileName, but only show directories" |
|
152 |
||
4795 | 153 |
^ self |
154 |
requestDirectoryName:title |
|
155 |
default:aFileName |
|
156 |
ok:nil |
|
157 |
abort:nil |
|
158 |
version:nil |
|
159 |
pattern:nil |
|
160 |
fromDirectory:nil |
|
161 |
ifFail:failBlock |
|
162 |
whenBoxCreatedEvaluate:nil |
|
163 |
asLoadDialog:nil. |
|
3892 | 164 |
|
165 |
" |
|
3904 | 166 |
FileDialog |
3892 | 167 |
requestDirectoryName:'which directory ?' |
4627 | 168 |
default:Filename currentDirectory pathName |
3892 | 169 |
ifFail:'none' |
170 |
" |
|
171 |
! |
|
172 |
||
5336 | 173 |
requestDirectoryName:title default:aFileName ok:okText abort:abortText ifFail:failBlock |
174 |
"same as requestFileName, but only show directories" |
|
175 |
||
176 |
^ self |
|
177 |
requestDirectoryName:title |
|
178 |
default:aFileName |
|
179 |
ok:okText |
|
180 |
abort:abortText |
|
181 |
version:nil |
|
182 |
pattern:nil |
|
183 |
fromDirectory:nil |
|
184 |
ifFail:failBlock |
|
185 |
whenBoxCreatedEvaluate:nil |
|
186 |
asLoadDialog:nil. |
|
187 |
||
188 |
" |
|
189 |
FileDialog |
|
190 |
requestDirectoryName:'which directory ?' |
|
191 |
default:Filename currentDirectory pathName |
|
192 |
ok:'Yes' |
|
193 |
abort:'No' |
|
194 |
ifFail:'none' |
|
195 |
" |
|
196 |
! |
|
197 |
||
5823 | 198 |
requestDirectoryName:title default:aFileName ok:okText abort:abortText ifFail:failBlock acceptReturnAsOK:aBoolean |
199 |
"same as requestFileName, but only show directories" |
|
200 |
||
201 |
^ self |
|
202 |
requestDirectoryName:title |
|
203 |
default:aFileName |
|
204 |
ok:okText |
|
205 |
abort:abortText |
|
206 |
version:nil |
|
207 |
pattern:nil |
|
208 |
fromDirectory:nil |
|
209 |
ifFail:failBlock |
|
210 |
whenBoxCreatedEvaluate:[:box|box doubleClickAction:[:index|box doAccept]] |
|
211 |
asLoadDialog:nil. |
|
212 |
||
213 |
" |
|
214 |
FileDialog |
|
215 |
requestDirectoryName:'which directory ?' |
|
216 |
default:Filename currentDirectory pathName |
|
217 |
ok:'Yes' |
|
218 |
abort:'No' |
|
219 |
ifFail:'none' |
|
220 |
" |
|
221 |
! |
|
222 |
||
19478 | 223 |
requestDirectoryName:titleString default:aFileName |
224 |
ok:okText abort:abortText |
|
225 |
version:versionSymbol |
|
226 |
pattern:patternArg |
|
227 |
fromDirectory:aDirectoryPath |
|
228 |
ifFail:failBlock |
|
229 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
230 |
asLoadDialog:aBoolean |
|
231 |
||
3892 | 232 |
"same as requestFileName, but only show directories" |
233 |
||
19478 | 234 |
^ self new |
235 |
requestDirectoryName:titleString default:aFileName |
|
236 |
ok:okText abort:abortText |
|
237 |
version:versionSymbol |
|
238 |
pattern:patternArg |
|
239 |
fromDirectory:aDirectoryPath |
|
4795 | 240 |
ifFail:failBlock |
19478 | 241 |
whenBoxCreatedEvaluate:boxCreatedCallback |
4795 | 242 |
asLoadDialog:aBoolean |
19478 | 243 |
|
3892 | 244 |
|
245 |
" |
|
246 |
FileDialog |
|
247 |
requestDirectoryName:'which directory ?' |
|
4627 | 248 |
default:Filename currentDirectory pathName |
3892 | 249 |
ifFail:nil |
250 |
" |
|
19478 | 251 |
|
3956 | 252 |
" |
253 |
FileDialog |
|
254 |
requestDirectoryName:'which directory ?' |
|
4627 | 255 |
default:Filename currentDirectory pathName |
3956 | 256 |
ok:nil |
257 |
abort:nil |
|
258 |
version:nil |
|
259 |
pattern:nil |
|
260 |
fromDirectory:nil |
|
261 |
ifFail:nil |
|
262 |
whenBoxCreatedEvaluate:nil |
|
263 |
asLoadDialog:true |
|
264 |
" |
|
3892 | 265 |
! |
266 |
||
5336 | 267 |
requestDirectoryName:title default:aFileName ok:okText ifFail:failBlock |
268 |
"same as requestFileName, but only show directories" |
|
269 |
||
270 |
^ self |
|
271 |
requestDirectoryName:title |
|
272 |
default:aFileName |
|
273 |
ok:okText |
|
274 |
abort:nil |
|
275 |
version:nil |
|
276 |
pattern:nil |
|
277 |
fromDirectory:nil |
|
278 |
ifFail:failBlock |
|
279 |
whenBoxCreatedEvaluate:nil |
|
280 |
asLoadDialog:nil. |
|
281 |
||
282 |
" |
|
283 |
FileDialog |
|
284 |
requestDirectoryName:'which directory ?' |
|
285 |
default:Filename currentDirectory pathName |
|
286 |
ok:'Yes' |
|
287 |
ifFail:'none' |
|
288 |
" |
|
289 |
! |
|
290 |
||
9765 | 291 |
requestFileName:titleString default:defaultName ok:okText abort:abortText pattern:pattern fromDirectory:aDirectoryPathOrNil |
292 |
"launch a Dialog, which allows user to enter a filename. |
|
293 |
The files presented initially are those in aDirectoryPathOrNil, or the |
|
294 |
last fileBox directory (default: current directory) (if a nil path is given). |
|
295 |
The box will show okText in its okButton, abortText in the abortButton. |
|
296 |
The matchPattern is set to pattern initially. |
|
297 |
Return the string, or nil if cancel was pressed." |
|
298 |
||
299 |
^ self |
|
300 |
requestFileName:titleString |
|
301 |
default:defaultName |
|
302 |
ok:okText |
|
303 |
abort:abortText |
|
304 |
pattern:pattern |
|
305 |
fromDirectory:aDirectoryPathOrNil |
|
306 |
whenBoxCreatedEvaluate:nil |
|
307 |
||
308 |
"Created: / 14-02-2011 / 17:59:21 / cg" |
|
309 |
! |
|
310 |
||
3892 | 311 |
requestFileName:titleString default:defaultName ok:okText abort:abortText pattern:pattern fromDirectory:aDirectoryPathOrNil whenBoxCreatedEvaluate:boxCreatedCallback |
312 |
||
4795 | 313 |
^ self |
314 |
requestFileName:titleString |
|
315 |
default:defaultName |
|
316 |
ok:okText |
|
317 |
abort:abortText |
|
318 |
version:nil |
|
319 |
ifFail:nil |
|
320 |
pattern:pattern |
|
321 |
fromDirectory:aDirectoryPathOrNil |
|
322 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
3892 | 323 |
! |
324 |
||
325 |
requestFileName:titleString default:defaultName ok:okText abort:abortText version:versionSymbol ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPath whenBoxCreatedEvaluate:boxCreatedCallback |
|
326 |
"launch a Dialog, which allows user to enter a filename. |
|
327 |
The files presented initially are those in aDirectoryPathOrNil, or the |
|
328 |
last fileBox directory (default: current directory) (if a nil path is given). |
|
329 |
The box will show okText in its okButton, abortText in the abortButton. |
|
330 |
The matchPattern is set to pattern initially. |
|
331 |
Return the string, or nil if cancel was pressed |
|
332 |
The version argument allows validation of the files existance; |
|
333 |
it may be any of: |
|
334 |
#mustBeNew - fail (return empty string) if the file exists |
|
335 |
#new - confirm if the file exists |
|
336 |
#mustBeOld - fail if the file does not exist |
|
337 |
#old - confirm if the file does not exist |
|
338 |
#any (other) - no validation |
|
339 |
" |
|
340 |
||
4795 | 341 |
^ self |
342 |
requestFileName:titleString |
|
343 |
default:defaultName |
|
344 |
ok:okText |
|
345 |
abort:abortText |
|
346 |
version:versionSymbol |
|
347 |
ifFail:failBlock |
|
348 |
pattern:pattern |
|
349 |
fromDirectory:aDirectoryPath |
|
350 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
351 |
asLoadDialog:nil |
|
3956 | 352 |
! |
353 |
||
19478 | 354 |
requestFileName:titleString default:defaultName ok:okText abort:abortText |
355 |
version:versionSymbol |
|
356 |
ifFail:failBlock |
|
357 |
pattern:patternArg |
|
358 |
fromDirectory:aDirectoryPath |
|
359 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
360 |
asLoadDialog:aBoolean |
|
361 |
||
3956 | 362 |
"launch a Dialog, which allows user to enter a filename. |
363 |
The files presented initially are those in aDirectoryPathOrNil, or the |
|
364 |
last fileBox directory (default: current directory) (if a nil path is given). |
|
365 |
The box will show okText in its okButton, abortText in the abortButton. |
|
366 |
The matchPattern is set to pattern initially. |
|
367 |
Return the string, or nil if cancel was pressed |
|
368 |
The version argument allows validation of the files existance; |
|
369 |
it may be any of: |
|
370 |
#mustBeNew - fail (return empty string) if the file exists |
|
371 |
#new - confirm if the file exists |
|
372 |
#mustBeOld - fail if the file does not exist |
|
373 |
#old - confirm if the file does not exist |
|
374 |
#any (other) - no validation |
|
375 |
" |
|
376 |
||
19478 | 377 |
^ self new |
378 |
requestFileName:titleString default:defaultName ok:okText abort:abortText |
|
379 |
version:versionSymbol |
|
4795 | 380 |
ifFail:failBlock |
19478 | 381 |
pattern:patternArg |
4795 | 382 |
fromDirectory:aDirectoryPath |
19478 | 383 |
whenBoxCreatedEvaluate:boxCreatedCallback |
4795 | 384 |
asLoadDialog:aBoolean |
19478 | 385 |
|
386 |
"/ |patternUsed instance enteredFileName enteredFileNameString| |
|
387 |
"/ |
|
388 |
"/ patternUsed := FileSelectionBox lastSuffixPatternUsedForDefault:patternArg. |
|
389 |
"/ |
|
390 |
"/ instance := self |
|
391 |
"/ startApplicationFor:titleString |
|
392 |
"/ default:defaultName |
|
393 |
"/ ok:okText |
|
394 |
"/ abort:abortText |
|
395 |
"/ ifFail:failBlock |
|
396 |
"/ pattern:patternUsed |
|
397 |
"/ fromDirectory:aDirectoryPath |
|
398 |
"/ whenBoxCreatedEvaluate:boxCreatedCallback |
|
399 |
"/ asLoadDialog:aBoolean |
|
400 |
"/ viewFiles:true |
|
401 |
"/ multipleSelect:false. |
|
402 |
"/ |
|
403 |
"/ enteredFileNameString := instance result. |
|
404 |
"/ enteredFileNameString isEmptyOrNil ifTrue:[ |
|
405 |
"/ ^ failBlock value |
|
406 |
"/ ]. |
|
407 |
"/ |
|
408 |
"/ enteredFileName := enteredFileNameString asFilename. |
|
409 |
"/ enteredFileName isRelative ifTrue:[ |
|
410 |
"/ (versionSymbol isNil and:[#(http https ftp) includes:(enteredFileNameString upToAll:'://')]) ifTrue:[ |
|
411 |
"/ ^ enteredFileNameString. |
|
412 |
"/ ] ifFalse:[ |
|
413 |
"/ enteredFileName := instance directory construct:enteredFileNameString. |
|
414 |
"/ enteredFileNameString := enteredFileName asString. |
|
415 |
"/ ]. |
|
416 |
"/ ]. |
|
417 |
"/ |
|
418 |
"/ FileSelectionBox lastFileSelectionDirectory:(enteredFileName directoryName). |
|
419 |
"/ (patternArg notEmptyOrNil and:[instance pattern ~= patternArg]) ifTrue:[ |
|
420 |
"/ FileSelectionBox lastSuffixPatternUsedForDefault:patternArg is:instance pattern |
|
421 |
"/ ]. |
|
422 |
"/ |
|
423 |
"/ versionSymbol isNil ifTrue:[ ^ enteredFileNameString]. |
|
424 |
"/ versionSymbol == #mustBeNew ifTrue:[ |
|
425 |
"/ "/ file must not exist |
|
426 |
"/ enteredFileName exists ifTrue:[^ failBlock value]. |
|
427 |
"/ ]. |
|
428 |
"/ versionSymbol == #new ifTrue:[ |
|
429 |
"/ "/ file should not exist |
|
430 |
"/ enteredFileName exists ifTrue:[ |
|
431 |
"/ (Dialog confirm:(self classResources stringWithCRs:'''%1'' exists.\\Continue anyway ?' with:enteredFileNameString)) |
|
432 |
"/ ifFalse:[^ failBlock value]. |
|
433 |
"/ ]. |
|
434 |
"/ ]. |
|
435 |
"/ versionSymbol == #mustBeOld ifTrue:[ |
|
436 |
"/ "/ file must exist |
|
437 |
"/ enteredFileName exists ifFalse:[^ failBlock value]. |
|
438 |
"/ ]. |
|
439 |
"/ versionSymbol == #old ifTrue:[ |
|
440 |
"/ "/ file should exist |
|
441 |
"/ enteredFileName exists ifFalse:[ |
|
442 |
"/ (self confirm:(self classResources stringWithCRs:'''%1'' does not exist yet.\\Continue anyway ?' with:enteredFileNameString)) |
|
443 |
"/ ifFalse:[^ failBlock value]. |
|
444 |
"/ ]. |
|
445 |
"/ ]. |
|
446 |
"/ |
|
447 |
"/ ^ enteredFileNameString |
|
448 |
||
449 |
" |
|
3956 | 450 |
FileDialog |
451 |
requestFileName:'enter a fileName:' |
|
452 |
default:'' |
|
453 |
ok:nil |
|
454 |
abort:nil |
|
455 |
version:nil |
|
456 |
ifFail:['none'] |
|
5858
d5648b365b8d
returns construct with defaultName if directory selected on requestFilename
penk
parents:
5853
diff
changeset
|
457 |
pattern:'*' |
4627 | 458 |
fromDirectory:Filename currentDirectory pathName |
3956 | 459 |
whenBoxCreatedEvaluate:nil |
460 |
asLoadDialog:true |
|
19478 | 461 |
" |
3892 | 462 |
! |
463 |
||
9765 | 464 |
requestFileName:titleString default:defaultName pattern:pattern fromDirectory:aDirectory |
465 |
"launch a Dialog, which allows user to enter a filename. |
|
466 |
The files presented initially are those from the current directory. |
|
467 |
The box will show ok/cancel in its buttons. |
|
468 |
The matchPattern is set to pattern initially. |
|
469 |
Return the string or nil if cancel was pressed." |
|
470 |
||
471 |
|resources| |
|
472 |
||
473 |
resources := self classResources. |
|
474 |
^ self |
|
475 |
requestFileName:titleString |
|
476 |
default:defaultName |
|
477 |
ok:(resources string:'OK') |
|
478 |
abort:(resources string:'Cancel') |
|
479 |
pattern:pattern |
|
480 |
fromDirectory:aDirectory |
|
481 |
||
482 |
"Created: / 14-02-2011 / 17:59:14 / cg" |
|
483 |
! |
|
484 |
||
3892 | 485 |
requestFileName:titleString default:defaultName version:versionSymbol ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPathOrNil whenBoxCreatedEvaluate:boxCreatedCallback |
486 |
||
4795 | 487 |
^ self |
488 |
requestFileName:titleString |
|
489 |
default:defaultName |
|
490 |
ok:nil |
|
491 |
abort:nil |
|
492 |
version:versionSymbol |
|
493 |
ifFail:failBlock |
|
494 |
pattern:pattern |
|
495 |
fromDirectory:aDirectoryPathOrNil |
|
496 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
3892 | 497 |
|
498 |
" |
|
499 |
FileDialog |
|
500 |
requestFileName:'enter a fileName:' |
|
501 |
default:'' |
|
502 |
version:nil |
|
503 |
ifFail:['none'] |
|
504 |
pattern:'*.conf' |
|
4627 | 505 |
fromDirectory:Filename currentDirectory pathName |
3892 | 506 |
whenBoxCreatedEvaluate:nil. |
507 |
Dialog |
|
508 |
requestFileName:'enter a fileName:' |
|
509 |
default:'' |
|
510 |
version:nil |
|
511 |
ifFail:['none'] |
|
512 |
pattern:'*.conf' |
|
4627 | 513 |
fromDirectory:Filename currentDirectory pathName |
3892 | 514 |
whenBoxCreatedEvaluate:nil |
515 |
" |
|
516 |
" |
|
517 |
FileDialog |
|
518 |
requestFileName:'enter a fileName:' |
|
519 |
default:'' |
|
520 |
version:#old |
|
521 |
ifFail:['none'] |
|
522 |
pattern:'*.conf' |
|
4627 | 523 |
fromDirectory:Filename currentDirectory pathName |
3892 | 524 |
whenBoxCreatedEvaluate:nil |
525 |
" |
|
526 |
" |
|
527 |
FileDialog |
|
528 |
requestFileName:'enter a fileName:' |
|
529 |
default:'' |
|
530 |
version:#mustBeNew |
|
531 |
ifFail:['none'] |
|
532 |
pattern:'*.conf' |
|
4627 | 533 |
fromDirectory:Filename currentDirectory pathName |
3892 | 534 |
whenBoxCreatedEvaluate:nil |
535 |
" |
|
3904 | 536 |
! |
537 |
||
538 |
requestFileNames:titleString default:defaultName ok:okText abort:abortText ifFail:failBlock pattern:pattern fromDirectory:aDirectoryPath whenBoxCreatedEvaluate:boxCreatedCallback |
|
539 |
"launch a Dialog, which allows user to enter a filename. |
|
540 |
The files presented initially are those in aDirectoryPathOrNil, or the |
|
541 |
last fileBox directory (default: current directory) (if a nil path is given). |
|
542 |
The box will show okText in its okButton, abortText in the abortButton. |
|
543 |
The matchPattern is set to pattern initially. |
|
3905 | 544 |
Return all selected Filenames as filenames in a collection, or nil if cancel was pressed |
3904 | 545 |
" |
546 |
||
547 |
||
4795 | 548 |
^ self |
549 |
requestFileNames:titleString |
|
550 |
default:defaultName |
|
551 |
ok:okText |
|
552 |
abort:abortText |
|
553 |
ifFail:failBlock |
|
554 |
pattern:pattern |
|
555 |
fromDirectory:aDirectoryPath |
|
556 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
557 |
asLoadDialog:nil. |
|
3956 | 558 |
|
559 |
||
560 |
" |
|
561 |
FileDialog |
|
562 |
requestFileNames:'enter a fileName:' |
|
563 |
default:'' |
|
564 |
ok:nil |
|
565 |
abort:nil |
|
566 |
ifFail:['none'] |
|
567 |
pattern:'*.conf' |
|
4627 | 568 |
fromDirectory:Filename currentDirectory pathName |
3956 | 569 |
whenBoxCreatedEvaluate:nil. |
570 |
" |
|
571 |
! |
|
572 |
||
19478 | 573 |
requestFileNames:titleString default:defaultName |
574 |
ok:okText abort:abortText |
|
575 |
ifFail:failBlock |
|
576 |
pattern:patternArg |
|
577 |
fromDirectory:aDirectoryPath |
|
578 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
579 |
asLoadDialog:asLoadDialog |
|
580 |
||
3956 | 581 |
"launch a Dialog, which allows user to enter a filename. |
582 |
The files presented initially are those in aDirectoryPathOrNil, or the |
|
583 |
last fileBox directory (default: current directory) (if a nil path is given). |
|
584 |
The box will show okText in its okButton, abortText in the abortButton. |
|
585 |
The matchPattern is set to pattern initially. |
|
586 |
Return all selected Filenames as filenames in a collection, or nil if cancel was pressed |
|
587 |
" |
|
588 |
||
19478 | 589 |
^ self new |
590 |
requestFileNames:titleString default:defaultName |
|
591 |
ok:okText abort:abortText |
|
4795 | 592 |
ifFail:failBlock |
19478 | 593 |
pattern:patternArg |
4795 | 594 |
fromDirectory:aDirectoryPath |
19478 | 595 |
whenBoxCreatedEvaluate:boxCreatedCallback |
596 |
asLoadDialog:asLoadDialog |
|
597 |
||
598 |
" |
|
3904 | 599 |
FileDialog |
600 |
requestFileNames:'enter a fileName:' |
|
601 |
default:'' |
|
602 |
ok:nil |
|
603 |
abort:nil |
|
604 |
ifFail:['none'] |
|
605 |
pattern:'*.conf' |
|
4627 | 606 |
fromDirectory:Filename currentDirectory pathName |
3956 | 607 |
whenBoxCreatedEvaluate:nil |
608 |
asLoadDialog:true. |
|
19478 | 609 |
" |
3904 | 610 |
! |
611 |
||
19478 | 612 |
startApplicationFor:titleString default:initialDefaultFileNameArg |
613 |
ok:okTextArg abort:abortTextArg |
|
614 |
ifFail:failBlock |
|
615 |
pattern:patternArg |
|
616 |
fromDirectory:aDirectoryPath |
|
617 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
618 |
asLoadDialog:asLoadDialog |
|
619 |
viewFiles:viewFilesArg |
|
620 |
multipleSelect:multipleSelectArg |
|
621 |
||
3904 | 622 |
"launch a Dialog, which allows user to enter a filename. |
623 |
The files presented initially are those in aDirectoryPathOrNil, or the |
|
624 |
last fileBox directory (default: current directory) (if a nil path is given). |
|
625 |
The box will show okText in its okButton, abortText in the abortButton. |
|
626 |
The matchPattern is set to pattern initially. |
|
627 |
Return the string, or nil if cancel was pressed |
|
628 |
The version argument allows validation of the files existance; |
|
629 |
it may be any of: |
|
630 |
#mustBeNew - fail (return empty string) if the file exists |
|
631 |
#new - confirm if the file exists |
|
632 |
#mustBeOld - fail if the file does not exist |
|
633 |
#old - confirm if the file does not exist |
|
634 |
#any (other) - no validation |
|
635 |
" |
|
636 |
||
19478 | 637 |
^ self new |
638 |
startApplicationFor:titleString default:initialDefaultFileNameArg |
|
639 |
ok:okTextArg abort:abortTextArg |
|
640 |
ifFail:failBlock |
|
641 |
pattern:patternArg |
|
642 |
fromDirectory:aDirectoryPath |
|
643 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
644 |
asLoadDialog:asLoadDialog |
|
645 |
viewFiles:viewFilesArg |
|
646 |
multipleSelect:multipleSelectArg |
|
647 |
"/ |
|
648 |
"/ |defaultDir instance defaultFile okText abortText initialDefaultFileName| |
|
649 |
"/ |
|
650 |
"/ initialDefaultFileName := initialDefaultFileNameArg. |
|
651 |
"/ initialDefaultFileName notNil ifTrue:[ |
|
652 |
"/ initialDefaultFileName := initialDefaultFileName asFilename. |
|
653 |
"/ ]. |
|
654 |
"/ |
|
655 |
"/ okText := okTextArg. |
|
656 |
"/ okText isNil ifTrue:[ okText := self resources string:'OK' ]. |
|
657 |
"/ abortText := abortTextArg. |
|
658 |
"/ abortText isNil ifTrue:[ abortText := self resources string:'Cancel' ]. |
|
659 |
"/ |
|
660 |
"/ defaultDir := aDirectoryPath. |
|
661 |
"/"/ defaultDir isNil ifTrue:[ |
|
662 |
"/"/ (initialDefaultFileName size > 0 and:[initialDefaultFileName exists]) ifTrue:[ |
|
663 |
"/"/ defaultDir := initialDefaultFileName asAbsoluteFilename directory. |
|
664 |
"/"/ ] ifFalse:[ |
|
665 |
"/"/ defaultDir := FileSelectionBox lastFileSelectionDirectory. |
|
666 |
"/"/ defaultDir isNil ifTrue:[ |
|
667 |
"/"/ defaultDir := Filename currentDirectory asAbsoluteFilename. |
|
668 |
"/"/ ]. |
|
669 |
"/"/ defaultDir asFilename exists ifFalse:[ |
|
670 |
"/"/ defaultDir := nil |
|
671 |
"/"/ ]. |
|
672 |
"/"/ ] |
|
673 |
"/"/ ]. |
|
674 |
"/ (initialDefaultFileName notNil |
|
675 |
"/ and:[initialDefaultFileName isAbsolute |
|
676 |
"/ and:[true "initialDefaultFileName asFilename exists"]]) ifTrue:[ |
|
677 |
"/ defaultDir := initialDefaultFileName asAbsoluteFilename. |
|
678 |
"/ true "viewFiles" ifTrue:[ |
|
679 |
"/ defaultFile := defaultDir asAbsoluteFilename. |
|
680 |
"/ defaultDir := defaultDir directory. |
|
681 |
"/ ]. |
|
682 |
"/ ] ifFalse:[ |
|
683 |
"/ defaultDir isNil ifTrue:[ |
|
5220
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
684 |
"/ defaultDir := FileSelectionBox lastFileSelectionDirectory. |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
685 |
"/ defaultDir isNil ifTrue:[ |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
686 |
"/ defaultDir := Filename currentDirectory asAbsoluteFilename. |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
687 |
"/ ]. |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
688 |
"/ defaultDir asFilename exists ifFalse:[ |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
689 |
"/ defaultDir := nil |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
690 |
"/ ]. |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
691 |
"/ ] |
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
692 |
"/ ]. |
19478 | 693 |
"/ defaultDir := defaultDir asFilename asAbsoluteFilename. |
694 |
"/"/ [defaultDir exists] whileFalse:[ |
|
695 |
"/"/ defaultDir := defaultDir directory. |
|
696 |
"/"/ ]. |
|
697 |
"/ |
|
698 |
"/ defaultFile isNil ifTrue:[ |
|
699 |
"/ viewFiles ifFalse:[ |
|
700 |
"/ defaultFile := defaultDir asAbsoluteFilename. |
|
701 |
"/ ] ifTrue:[ |
|
702 |
"/ (initialDefaultFileName notNil and:[initialDefaultFileName withoutSuffix baseName ~= '*']) ifTrue:[ |
|
703 |
"/ defaultFile := defaultDir construct:initialDefaultFileName baseName. |
|
704 |
"/ ] ifFalse:[ |
|
705 |
"/ defaultFile := defaultDir. |
|
706 |
"/ ]. |
|
707 |
"/ ]. |
|
5220
1de409e5ea52
initial text overwrites given directoryPath
Claus Gittinger <cg@exept.de>
parents:
5193
diff
changeset
|
708 |
"/ ]. |
19478 | 709 |
"/ |
710 |
"/ instance := self new. |
|
711 |
"/ defaultDir notNil ifTrue:[instance directory:defaultDir]. |
|
712 |
"/ instance |
|
713 |
"/ multipleSelect:multipleSelect ? false; |
|
714 |
"/ startFilename:defaultFile; |
|
715 |
"/ pattern:(pattern isEmptyOrNil ifTrue:['*'] ifFalse:[pattern]); |
|
716 |
"/ initialText:titleString; |
|
717 |
"/ beLoadDialog:asLoadDialog ? false; |
|
718 |
"/ viewFiles:viewFiles ? true. |
|
719 |
"/ |
|
720 |
"/ instance okLabelHolder value:okText. |
|
721 |
"/ instance cancelLabelHolder value:abortText. |
|
722 |
"/ |
|
723 |
"/ self setDoubleClickActionFor:instance. |
|
724 |
"/ instance allButOpenInterface:#windowSpec. |
|
725 |
"/ boxCreatedCallback notNil ifTrue:[boxCreatedCallback value:instance]. |
|
726 |
"/ |
|
727 |
"/ "/ Dialog aboutToOpenBoxNotificationSignal raiseRequestWith:instance. |
|
728 |
"/ instance treeBrowser sortCaseless value: (Filename isCaseSensitive not). |
|
729 |
"/ instance openWindowModal. |
|
730 |
"/ ^ instance |
|
731 |
"/ |
|
732 |
"/ "Modified: / 23-08-2006 / 12:24:54 / cg" |
|
733 |
"/ "Modified: / 13-12-2006 / 16:25:42 / User" |
|
734 |
"/ "Modified (format): / 14-02-2017 / 12:49:34 / cg" |
|
3892 | 735 |
! ! |
736 |
||
737 |
!FileDialog class methodsFor:'accessing'! |
|
738 |
||
19267 | 739 |
additionalFolderItemsInMenu |
740 |
"any additional folders to be shown in the 'File' menu; |
|
741 |
each element can be either a filename or a pair with filename and menu-item-label." |
|
742 |
||
743 |
"/ FileDialog additionalFolderItemsInMenu:#('/Users/exept' ('/Users/exept/cg_work' 'WorkDir')) |
|
744 |
^ AdditionalFolderItemsInMenu |
|
745 |
! |
|
746 |
||
747 |
additionalFolderItemsInMenu:aCollectionOfFoldernames |
|
19478 | 748 |
"any additional folders to be shown in every 'File' menu; |
749 |
each element can be either a filename or a pair with filename and menu-item-label, |
|
750 |
or an assoc, with key=filename and value=label." |
|
19267 | 751 |
|
752 |
"/ FileDialog additionalFolderItemsInMenu:#('/Users/exept' ('/Users/exept/cg_work' 'WorkDir')) |
|
753 |
AdditionalFolderItemsInMenu := aCollectionOfFoldernames |
|
754 |
! |
|
755 |
||
6650 | 756 |
classResources |
9110 | 757 |
^ (FileBrowserV2 ? AbstractFileBrowser) classResources |
6650 | 758 |
! |
759 |
||
5931 | 760 |
lastExtent |
761 |
^ LastExtent |
|
762 |
! |
|
763 |
||
764 |
lastExtent:anExtent |
|
765 |
LastExtent := anExtent |
|
766 |
! |
|
767 |
||
3953 | 768 |
setDoubleClickActionFor:instance |
769 |
||
770 |
instance doubleClickAction:[:anIndex| |
|
771 |
| item | |
|
772 |
item := instance treeBrowser fileList at:anIndex ifAbsent:nil. |
|
773 |
item notNil ifTrue:[ |
|
5329 | 774 |
(instance viewFiles and:[item isDirectory not]) ifTrue:[ |
3953 | 775 |
instance doAccept. |
776 |
] |
|
777 |
] |
|
778 |
]. |
|
3892 | 779 |
! ! |
780 |
||
8585 | 781 |
!FileDialog class methodsFor:'help specs'! |
4603
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
782 |
|
17919 | 783 |
helpSpec |
8585 | 784 |
"This resource specification was automatically generated |
785 |
by the UIHelpTool of ST/X." |
|
786 |
||
787 |
"Do not manually edit this!! If it is corrupted, |
|
788 |
the UIHelpTool may not be able to read the specification." |
|
789 |
||
790 |
" |
|
791 |
UIHelpTool openOnClass:FileDialog |
|
792 |
" |
|
793 |
||
4603
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
794 |
<resource: #help> |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
795 |
|
17919 | 796 |
^ FileBrowserV2 helpSpec addPairsFrom:#( |
4603
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
797 |
|
8585 | 798 |
#openFileBrowser |
13003 | 799 |
'Open a FileBrowser on the selected directory' |
4603
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
800 |
|
8585 | 801 |
) |
4603
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
802 |
! ! |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
803 |
|
3892 | 804 |
!FileDialog class methodsFor:'interface specs'! |
805 |
||
806 |
windowSpec |
|
807 |
"This resource specification was automatically generated |
|
808 |
by the UIPainter of ST/X." |
|
809 |
||
810 |
"Do not manually edit this!! If it is corrupted, |
|
811 |
the UIPainter may not be able to read the specification." |
|
812 |
||
813 |
" |
|
814 |
UIPainter new openOnClass:FileDialog andSelector:#windowSpec |
|
815 |
FileDialog new openInterface:#windowSpec |
|
816 |
FileDialog open |
|
817 |
" |
|
818 |
||
819 |
<resource: #canvas> |
|
820 |
||
821 |
^ |
|
13741 | 822 |
#(FullSpec |
823 |
name: windowSpec |
|
19012 | 824 |
uuid: 'b13cef1a-c417-11e9-a4e5-10ddb1cc5928' |
13741 | 825 |
window: |
826 |
(WindowSpec |
|
827 |
label: 'FileDialog' |
|
828 |
name: 'FileDialog' |
|
18527 | 829 |
uuid: '686277b6-e9f6-11e8-8cdd-b8f6b1108e05' |
19012 | 830 |
min: (Point 10 10) bounds: (Rectangle 0 0 460 482) menu: mainMenu |
13741 | 831 |
performer: treeBrowser |
19012 | 832 |
) component: |
13741 | 833 |
(SpecCollection |
834 |
collection: ( |
|
835 |
(VerticalPanelViewSpec |
|
836 |
name: 'FilePanel' |
|
19012 | 837 |
layout: (LayoutFrame 0 0 0 0 0 1 -40 1) uuid: '6862e00c-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 838 |
horizontalLayout: fit |
839 |
verticalLayout: bottomFit |
|
840 |
horizontalSpace: 0 |
|
841 |
verticalSpace: 3 |
|
842 |
elementsChangeSize: true |
|
843 |
component: |
|
844 |
(SpecCollection |
|
845 |
collection: ( |
|
846 |
(ViewSpec |
|
847 |
name: 'FilePart' |
|
18527 | 848 |
uuid: '6862e340-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 849 |
component: |
850 |
(SpecCollection |
|
851 |
collection: ( |
|
852 |
(MenuPanelSpec |
|
853 |
name: 'ToolBar1' |
|
19012 | 854 |
layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 40 0) uuid: '6862e46c-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 855 |
tabable: true |
856 |
menu: toolBarMenu |
|
857 |
textDefault: true |
|
19012 | 858 |
) |
13741 | 859 |
(VariableHorizontalPanelSpec |
860 |
name: 'DeviceAndFilterPanel' |
|
19012 | 861 |
layout: (LayoutFrame 0 0 40 0 0 1 70 0) uuid: '6862e674-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 862 |
level: 1 |
863 |
showHandle: true |
|
864 |
component: |
|
865 |
(SpecCollection |
|
866 |
collection: ( |
|
867 |
(ViewSpec |
|
868 |
name: 'Box1' |
|
18527 | 869 |
uuid: '6862e7f0-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 870 |
component: |
871 |
(SpecCollection |
|
872 |
collection: ( |
|
873 |
(ComboListSpec |
|
874 |
name: 'ComboList1' |
|
19012 | 875 |
layout: (LayoutFrame 1 0 1 0.0 -1 1 -1 1) uuid: '6862e9e4-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 876 |
visibilityChannel: driveSelectorVisible |
877 |
model: selectedDeviceDrive |
|
878 |
comboList: listOfDeviceDrives |
|
879 |
useIndex: false |
|
880 |
hidePullDownMenuButton: false |
|
881 |
) |
|
19012 | 882 |
) |
883 |
) |
|
884 |
) |
|
13741 | 885 |
(ViewSpec |
886 |
name: 'Box2' |
|
18527 | 887 |
uuid: '6862ec82-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 888 |
component: |
889 |
(SpecCollection |
|
890 |
collection: ( |
|
891 |
(LabelSpec |
|
892 |
label: 'Filter:' |
|
893 |
name: 'FilterLabel' |
|
19012 | 894 |
layout: (LayoutFrame 1 0 2 0 59 0 -2 1) uuid: '6862ed9a-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 895 |
translateLabel: true |
896 |
adjust: right |
|
19012 | 897 |
) |
13741 | 898 |
(InputFieldSpec |
899 |
name: 'FilterEntryField' |
|
19012 | 900 |
layout: (LayoutFrame 60 0 -27 1 -2 1 -2 1) uuid: '6862ef8e-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 901 |
model: filterHolder |
902 |
immediateAccept: true |
|
903 |
acceptOnReturn: true |
|
904 |
acceptOnTab: true |
|
905 |
acceptOnLostFocus: true |
|
906 |
acceptOnPointerLeave: false |
|
907 |
postBuildCallback: postBuildFilterField: |
|
908 |
) |
|
19012 | 909 |
) |
910 |
) |
|
13741 | 911 |
) |
19012 | 912 |
) |
913 |
) handles: (Any 0.29999999999999999 1.0) |
|
914 |
) |
|
13741 | 915 |
(SubCanvasSpec |
916 |
name: 'DirectoryTreeBrowser' |
|
19012 | 917 |
layout: (LayoutFrame 0 0.0 70 0 0 1.0 -34 1) uuid: '6862f1d2-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 918 |
tabable: true |
919 |
hasHorizontalScrollBar: false |
|
920 |
hasVerticalScrollBar: false |
|
921 |
majorKey: DirectoryTreeBrowser |
|
922 |
subAspectHolders: |
|
19012 | 923 |
(Array |
13741 | 924 |
(SubChannelInfoSpec |
925 |
subAspect: filterModel |
|
926 |
aspect: filterHolder |
|
19012 | 927 |
) |
13741 | 928 |
(SubChannelInfoSpec |
929 |
subAspect: rootHolder |
|
930 |
aspect: rootDirectoryHolder |
|
19012 | 931 |
) |
13741 | 932 |
(SubChannelInfoSpec |
933 |
subAspect: showHiddenFiles |
|
934 |
aspect: showHiddenFiles |
|
19012 | 935 |
) |
936 |
) createNewApplication: true |
|
13741 | 937 |
createNewBuilder: true |
938 |
postBuildCallback: postBuildTreeBrowser: |
|
19012 | 939 |
) |
13741 | 940 |
(LabelSpec |
941 |
label: 'Filename:' |
|
942 |
name: 'FilenameLabel' |
|
19012 | 943 |
layout: (LayoutFrame 3 0 -28 1 110 0 -1 1) uuid: '6862f5b0-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 944 |
translateLabel: true |
945 |
labelChannel: filenameLabelHolder |
|
946 |
adjust: left |
|
19012 | 947 |
) |
13741 | 948 |
(FilenameInputFieldSpec |
949 |
name: 'FilenameEntryField' |
|
19012 | 950 |
layout: (LayoutFrame 110 0 -28 1 -2 1 -1 1) uuid: '6862f6be-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 951 |
tabable: true |
952 |
model: filenameHolder |
|
953 |
immediateAccept: false |
|
954 |
acceptOnPointerLeave: true |
|
955 |
hasKeyboardFocusInitially: true |
|
956 |
postBuildCallback: postBuildFileNameField: |
|
957 |
) |
|
19012 | 958 |
(ViewSpec |
959 |
name: 'SearchInfoBox' |
|
960 |
layout: (LayoutFrame 0 0 -30 1 0 1 0 1) uuid: 'efe63378-c414-11e9-a4e5-10ddb1cc5928' |
|
961 |
visibilityChannel: searchInfoBoxVisibleHolder |
|
962 |
component: |
|
963 |
(SpecCollection |
|
964 |
collection: ( |
|
965 |
(LabelSpec |
|
966 |
label: 'Searching:' |
|
967 |
name: 'Label1' |
|
968 |
layout: (LayoutFrame 3 0 -28 1 110 0 -1 1) uuid: '6862f5b0-e9f6-11e8-8cdd-b8f6b1108e05' |
|
969 |
translateLabel: true |
|
970 |
adjust: left |
|
971 |
) |
|
972 |
(LabelSpec |
|
973 |
name: 'Label2' |
|
974 |
layout: (LayoutFrame 110 0 -28 1 0 1 -1 1) uuid: '6862f5b0-e9f6-11e8-8cdd-b8f6b1108e05' |
|
975 |
translateLabel: false |
|
976 |
labelChannel: searchedDirectoryInfoHolder |
|
977 |
adjust: left |
|
978 |
) |
|
979 |
) |
|
980 |
) |
|
981 |
) |
|
982 |
) |
|
983 |
) extent: (Point 460 442) |
|
13741 | 984 |
) |
19012 | 985 |
) |
986 |
) postBuildCallback: postBuildVerticalPanelView: |
|
987 |
) |
|
13741 | 988 |
(HorizontalPanelViewSpec |
989 |
name: 'ButtonPanel' |
|
19012 | 990 |
layout: (LayoutFrame 0 0.0 -34 1 -16 1 0 1) uuid: '6862f89e-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 991 |
visibilityChannel: buttonPanelVisibleHolder |
992 |
horizontalLayout: fitSpace |
|
993 |
verticalLayout: center |
|
994 |
horizontalSpace: 3 |
|
995 |
verticalSpace: 3 |
|
996 |
reverseOrderIfOKAtLeft: true |
|
997 |
component: |
|
998 |
(SpecCollection |
|
999 |
collection: ( |
|
1000 |
(ActionButtonSpec |
|
1001 |
label: 'Cancel' |
|
1002 |
name: 'cancelButton' |
|
18527 | 1003 |
uuid: '6862f9e8-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 1004 |
translateLabel: true |
1005 |
labelChannel: cancelLabelHolder |
|
1006 |
tabable: true |
|
1007 |
model: doCancel |
|
18527 | 1008 |
extent: (Point 143 30) |
19012 | 1009 |
) |
13741 | 1010 |
(ActionButtonSpec |
1011 |
label: 'Append' |
|
1012 |
name: 'appendButton' |
|
18527 | 1013 |
uuid: '6862fba0-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 1014 |
visibilityChannel: appendButtonVisibleHolder |
1015 |
translateLabel: true |
|
1016 |
labelChannel: appendLabelHolder |
|
1017 |
tabable: true |
|
1018 |
model: appendPressed |
|
18527 | 1019 |
extent: (Point 144 30) |
19012 | 1020 |
) |
13741 | 1021 |
(ActionButtonSpec |
1022 |
label: 'OK' |
|
1023 |
name: 'okButton' |
|
18527 | 1024 |
uuid: '6862fce0-e9f6-11e8-8cdd-b8f6b1108e05' |
13741 | 1025 |
translateLabel: true |
1026 |
labelChannel: okLabelHolder |
|
1027 |
tabable: true |
|
1028 |
model: okPressed |
|
15766 | 1029 |
enableChannel: okLabelEnabled |
13741 | 1030 |
isDefault: true |
18527 | 1031 |
extent: (Point 144 30) |
13741 | 1032 |
) |
19012 | 1033 |
) |
1034 |
) keepSpaceForOSXResizeHandleH: true |
|
13741 | 1035 |
) |
19012 | 1036 |
) |
1037 |
) |
|
1038 |
) |
|
3892 | 1039 |
! ! |
1040 |
||
1041 |
!FileDialog class methodsFor:'menu specs'! |
|
1042 |
||
19478 | 1043 |
directoryMenu |
1044 |
"This resource specification was automatically generated |
|
1045 |
by the MenuEditor of ST/X." |
|
1046 |
||
1047 |
"Do not manually edit this!! If it is corrupted, |
|
1048 |
the MenuEditor may not be able to read the specification." |
|
1049 |
||
1050 |
||
1051 |
" |
|
1052 |
MenuEditor new openOnClass:FileDialog andSelector:#mainMenu |
|
1053 |
(Menu new fromLiteralArrayEncoding:(FileDialog mainMenu)) startUp |
|
1054 |
" |
|
1055 |
||
1056 |
<resource: #menu> |
|
1057 |
||
1058 |
^ |
|
1059 |
#(Menu |
|
1060 |
(MenuItem |
|
1061 |
label: 'Up' |
|
1062 |
itemValue: doGoDirectoryUp |
|
1063 |
) |
|
1064 |
(MenuItem |
|
1065 |
label: '-' |
|
1066 |
) |
|
1067 |
(MenuItem |
|
1068 |
activeHelpKey: directoryBack |
|
1069 |
enabled: enableBack |
|
1070 |
label: 'Back' |
|
1071 |
itemValue: doBack |
|
1072 |
) |
|
1073 |
(MenuItem |
|
1074 |
activeHelpKey: directoryBack |
|
1075 |
enabled: enableForward |
|
1076 |
label: 'Forward' |
|
1077 |
itemValue: doForward |
|
1078 |
) |
|
1079 |
(MenuItem |
|
1080 |
label: '-' |
|
1081 |
) |
|
1082 |
(MenuItem |
|
1083 |
enabled: enableHome |
|
1084 |
label: 'Home Directory' |
|
1085 |
itemValue: doGotoHomeDirectory |
|
1086 |
labelImage: (ResourceRetriever ToolbarIconLibrary homeIcon16x16 'Home Directory') |
|
1087 |
) |
|
1088 |
(MenuItem |
|
1089 |
enabled: enableGotoDesktopDirectory |
|
1090 |
label: 'Desktop Directory' |
|
1091 |
itemValue: doGotoDesktopDirectory |
|
1092 |
labelImage: (ResourceRetriever ToolbarIconLibrary desktop16x16Icon 'Desktop Directory') |
|
1093 |
) |
|
1094 |
(MenuItem |
|
1095 |
enabled: enableGotoDocuments |
|
1096 |
label: 'Documents Directory' |
|
1097 |
itemValue: doGotoDocumentsDirectory |
|
1098 |
) |
|
1099 |
(MenuItem |
|
1100 |
enabled: enableGotoDownloads |
|
1101 |
label: 'Downloads Directory' |
|
1102 |
itemValue: doGotoDownloadsDirectory |
|
1103 |
) |
|
1104 |
(MenuItem |
|
1105 |
label: 'Menu Slice' |
|
1106 |
submenuChannel: additionalFoldersMenuSliceHolder |
|
1107 |
isMenuSlice: true |
|
1108 |
) |
|
1109 |
(MenuItem |
|
1110 |
label: '-' |
|
1111 |
) |
|
1112 |
(MenuItem |
|
1113 |
label: 'Bookmarks' |
|
1114 |
submenuChannel: bookmarksMenu |
|
1115 |
labelImage: (ResourceRetriever ToolbarIconLibrary bookmarks14x14 'Bookmarks') |
|
1116 |
) |
|
1117 |
(MenuItem |
|
1118 |
label: 'Visited Directories' |
|
1119 |
submenuChannel: visitedDirectoriesMenu |
|
1120 |
) |
|
1121 |
) |
|
1122 |
! |
|
1123 |
||
9113 | 1124 |
mainMenu |
1125 |
"This resource specification was automatically generated |
|
1126 |
by the MenuEditor of ST/X." |
|
1127 |
||
1128 |
"Do not manually edit this!! If it is corrupted, |
|
1129 |
the MenuEditor may not be able to read the specification." |
|
1130 |
||
18749 | 1131 |
|
9113 | 1132 |
" |
1133 |
MenuEditor new openOnClass:FileDialog andSelector:#mainMenu |
|
1134 |
(Menu new fromLiteralArrayEncoding:(FileDialog mainMenu)) startUp |
|
1135 |
" |
|
1136 |
||
1137 |
<resource: #menu> |
|
1138 |
||
1139 |
^ |
|
19012 | 1140 |
#(Menu |
1141 |
(MenuItem |
|
1142 |
label: 'Directory' |
|
19478 | 1143 |
submenuChannel: directoryMenu |
1144 |
) |
|
1145 |
(MenuItem |
|
1146 |
label: 'Directory' |
|
19012 | 1147 |
submenu: |
1148 |
(Menu |
|
1149 |
(MenuItem |
|
1150 |
label: 'Up' |
|
1151 |
itemValue: doGoDirectoryUp |
|
1152 |
) |
|
1153 |
(MenuItem |
|
1154 |
label: '-' |
|
1155 |
) |
|
1156 |
(MenuItem |
|
1157 |
activeHelpKey: directoryBack |
|
1158 |
enabled: enableBack |
|
1159 |
label: 'Back' |
|
1160 |
itemValue: doBack |
|
1161 |
) |
|
1162 |
(MenuItem |
|
1163 |
activeHelpKey: directoryBack |
|
1164 |
enabled: enableForward |
|
1165 |
label: 'Forward' |
|
1166 |
itemValue: doForward |
|
1167 |
) |
|
1168 |
(MenuItem |
|
1169 |
label: '-' |
|
1170 |
) |
|
1171 |
(MenuItem |
|
1172 |
enabled: enableHome |
|
1173 |
label: 'Home Directory' |
|
1174 |
itemValue: doGotoHomeDirectory |
|
1175 |
labelImage: (ResourceRetriever ToolbarIconLibrary homeIcon16x16 'Home Directory') |
|
1176 |
) |
|
1177 |
(MenuItem |
|
1178 |
enabled: enableGotoDesktopDirectory |
|
1179 |
label: 'Desktop Directory' |
|
1180 |
itemValue: doGotoDesktopDirectory |
|
1181 |
labelImage: (ResourceRetriever ToolbarIconLibrary desktop16x16Icon 'Desktop Directory') |
|
1182 |
) |
|
1183 |
(MenuItem |
|
1184 |
enabled: enableGotoDocuments |
|
1185 |
label: 'Documents Directory' |
|
1186 |
itemValue: doGotoDocumentsDirectory |
|
1187 |
) |
|
1188 |
(MenuItem |
|
1189 |
enabled: enableGotoDownloads |
|
1190 |
label: 'Downloads Directory' |
|
1191 |
itemValue: doGotoDownloadsDirectory |
|
1192 |
) |
|
1193 |
(MenuItem |
|
19267 | 1194 |
label: 'Menu Slice' |
19478 | 1195 |
submenuChannel: additionalFoldersMenuSliceHolder |
19267 | 1196 |
isMenuSlice: true |
1197 |
) |
|
1198 |
(MenuItem |
|
1199 |
label: '-' |
|
1200 |
) |
|
1201 |
(MenuItem |
|
19012 | 1202 |
label: 'Bookmarks' |
1203 |
submenuChannel: bookmarksMenu |
|
1204 |
labelImage: (ResourceRetriever ToolbarIconLibrary bookmarks14x14 'Bookmarks') |
|
1205 |
) |
|
1206 |
(MenuItem |
|
1207 |
label: 'Visited Directories' |
|
1208 |
submenuChannel: visitedDirectoriesMenu |
|
1209 |
) |
|
9113 | 1210 |
) |
19012 | 1211 |
) |
1212 |
(MenuItem |
|
1213 |
label: 'View' |
|
1214 |
submenu: |
|
1215 |
(Menu |
|
1216 |
(MenuItem |
|
1217 |
label: 'Sort' |
|
1218 |
submenuChannel: sortMenu |
|
1219 |
) |
|
1220 |
(MenuItem |
|
1221 |
label: 'Show' |
|
1222 |
submenuChannel: showMenuSpecForDialog |
|
1223 |
) |
|
1224 |
(MenuItem |
|
1225 |
label: '-' |
|
1226 |
) |
|
1227 |
(MenuItem |
|
1228 |
label: 'Update' |
|
1229 |
itemValue: updateCurrentDirectory |
|
1230 |
) |
|
1231 |
) |
|
1232 |
) |
|
1233 |
(MenuItem |
|
1234 |
label: 'Tools' |
|
1235 |
submenu: |
|
1236 |
(Menu |
|
1237 |
(MenuItem |
|
1238 |
label: 'Terminal' |
|
1239 |
itemValue: openTerminal |
|
1240 |
labelImage: (ResourceRetriever ToolbarIconLibrary terminal16x16Icon 'Terminal') |
|
1241 |
) |
|
1242 |
) |
|
1243 |
) |
|
1244 |
(MenuItem |
|
1245 |
label: 'Find' |
|
1246 |
submenu: |
|
1247 |
(Menu |
|
1248 |
(MenuItem |
|
1249 |
label: 'File...' |
|
1250 |
itemValue: doFindAndSelectFile |
|
1251 |
labelImage: (ResourceRetriever ToolbarIconLibrary search16x16Icon 'File...') |
|
1252 |
) |
|
1253 |
(MenuItem |
|
19265 | 1254 |
enabled: findAndSelectNextFileEnabledHolder |
19012 | 1255 |
label: 'Next...' |
1256 |
itemValue: doFindAndSelectNextFile |
|
1257 |
shortcutKey: FindNext |
|
1258 |
) |
|
1259 |
) |
|
1260 |
) |
|
1261 |
) |
|
9113 | 1262 |
! |
1263 |
||
3892 | 1264 |
toolBarMenu |
1265 |
"This resource specification was automatically generated |
|
1266 |
by the MenuEditor of ST/X." |
|
1267 |
||
1268 |
"Do not manually edit this!! If it is corrupted, |
|
1269 |
the MenuEditor may not be able to read the specification." |
|
1270 |
||
1271 |
" |
|
1272 |
MenuEditor new openOnClass:FileDialog andSelector:#toolBarMenu |
|
1273 |
(Menu new fromLiteralArrayEncoding:(FileDialog toolBarMenu)) startUp |
|
1274 |
" |
|
1275 |
||
1276 |
<resource: #menu> |
|
1277 |
||
1278 |
^ |
|
5873 | 1279 |
#(Menu |
1280 |
( |
|
1281 |
(MenuItem |
|
1282 |
activeHelpKey: directoryBack |
|
1283 |
enabled: enableBack |
|
1284 |
label: 'Back' |
|
1285 |
itemValue: doBack |
|
1286 |
translateLabel: true |
|
1287 |
isButton: true |
|
1288 |
submenuChannel: menuDirHistoryBack |
|
6087 | 1289 |
labelImage: (ResourceRetriever AbstractFileBrowser historyBackIcon) |
5873 | 1290 |
keepLinkedMenu: true |
3892 | 1291 |
) |
5873 | 1292 |
(MenuItem |
1293 |
label: '' |
|
3892 | 1294 |
) |
5873 | 1295 |
(MenuItem |
1296 |
activeHelpKey: directoryForward |
|
1297 |
enabled: enableForward |
|
1298 |
label: 'Forward' |
|
1299 |
itemValue: doForward |
|
1300 |
translateLabel: true |
|
1301 |
isButton: true |
|
1302 |
submenuChannel: menuDirHistoryForward |
|
6087 | 1303 |
labelImage: (ResourceRetriever AbstractFileBrowser historyForwardIcon) |
5873 | 1304 |
keepLinkedMenu: true |
3892 | 1305 |
) |
5873 | 1306 |
(MenuItem |
6462 | 1307 |
label: '-' |
1308 |
) |
|
1309 |
(MenuItem |
|
1310 |
activeHelpKey: directoryUp |
|
1311 |
enabled: enableDirectoryUp |
|
1312 |
label: 'DirectoryUp' |
|
1313 |
itemValue: doGoDirectoryUp |
|
1314 |
translateLabel: true |
|
1315 |
isButton: true |
|
1316 |
labelImage: (ResourceRetriever AbstractFileBrowser directoryUpIcon) |
|
3892 | 1317 |
) |
5873 | 1318 |
(MenuItem |
1319 |
activeHelpKey: fileHome |
|
1320 |
enabled: enableHome |
|
1321 |
label: 'Home' |
|
1322 |
itemValue: doGotoHomeDirectory |
|
1323 |
translateLabel: true |
|
1324 |
isButton: true |
|
6096 | 1325 |
labelImage: (ResourceRetriever ToolbarIconLibrary homeIcon) |
3892 | 1326 |
) |
5873 | 1327 |
(MenuItem |
8092 | 1328 |
activeHelpKey: fileDesktop |
18512 | 1329 |
enabled: enableGotoDesktopDirectory |
8092 | 1330 |
label: 'Desktop' |
1331 |
itemValue: doGotoDesktopDirectory |
|
1332 |
translateLabel: true |
|
1333 |
isButton: true |
|
1334 |
labelImage: (ResourceRetriever ToolbarIconLibrary desktopIcon) |
|
1335 |
) |
|
1336 |
(MenuItem |
|
6098 | 1337 |
activeHelpKey: fileGotoBookmark |
1338 |
label: 'Bookmarks' |
|
1339 |
translateLabel: true |
|
1340 |
isButton: true |
|
9113 | 1341 |
submenuChannel: gotoBookmarksMenu |
6098 | 1342 |
labelImage: (ResourceRetriever ToolbarIconLibrary directoryBookmarksIcon) |
1343 |
) |
|
1344 |
(MenuItem |
|
5873 | 1345 |
label: '-' |
1346 |
isVisible: newDirectoryVisibilityHolder |
|
3923 | 1347 |
) |
5873 | 1348 |
(MenuItem |
6122 | 1349 |
label: 'New Directory...' |
5873 | 1350 |
itemValue: newDirectory |
1351 |
translateLabel: true |
|
1352 |
isButton: true |
|
1353 |
isVisible: newDirectoryVisibilityHolder |
|
6088 | 1354 |
labelImage: (ResourceRetriever AbstractFileBrowser newDirectoryIcon) |
3923 | 1355 |
) |
8585 | 1356 |
(MenuItem |
1357 |
label: '-' |
|
19174 | 1358 |
isVisible: browseMenuItemVisibleHolder |
8585 | 1359 |
) |
1360 |
(MenuItem |
|
1361 |
activeHelpKey: openFileBrowser |
|
1362 |
label: 'Browse' |
|
1363 |
itemValue: doBrowseDirectory |
|
1364 |
translateLabel: true |
|
1365 |
isButton: true |
|
15725 | 1366 |
isVisible: browseMenuItemVisibleHolder |
8585 | 1367 |
labelImage: (ResourceRetriever ToolbarIconLibrary startFileBrowserIcon) |
1368 |
) |
|
3892 | 1369 |
) |
1370 |
nil |
|
1371 |
nil |
|
1372 |
) |
|
19174 | 1373 |
|
1374 |
"Modified: / 10-09-2019 / 18:41:59 / Stefan Vogel" |
|
9113 | 1375 |
! |
1376 |
||
1377 |
viewInContentsBrowserMenu |
|
1378 |
^ DirectoryContentsBrowser showMenuSpec |
|
3892 | 1379 |
! ! |
1380 |
||
8182 | 1381 |
!FileDialog class methodsFor:'plugIn spec'! |
1382 |
||
1383 |
aspectSelectors |
|
1384 |
"This resource specification was automatically generated |
|
1385 |
by the UIPainter of ST/X." |
|
1386 |
||
1387 |
"Do not manually edit this. If it is corrupted, |
|
1388 |
the UIPainter may not be able to read the specification." |
|
1389 |
||
1390 |
"Return a description of exported aspects; |
|
1391 |
these can be connected to aspects of an embedding application |
|
1392 |
(if this app is embedded in a subCanvas)." |
|
1393 |
||
1394 |
^ #( |
|
1395 |
#filenameHolder |
|
1396 |
#filterHolder |
|
8191
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
1397 |
#rootDirectoryHolder |
8182 | 1398 |
). |
1399 |
||
1400 |
! ! |
|
1401 |
||
19478 | 1402 |
!FileDialog methodsFor:'API'! |
1403 |
||
1404 |
requestDirectoryName:titleString default:aFileName |
|
1405 |
ok:okText abort:abortText |
|
1406 |
version:versionSymbol |
|
1407 |
pattern:patternArg |
|
1408 |
fromDirectory:aDirectoryPath |
|
1409 |
ifFail:failBlock |
|
1410 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
1411 |
asLoadDialog:aBoolean |
|
1412 |
||
1413 |
"same as requestFileName, but only show directories" |
|
1414 |
||
1415 |
|enteredFileName enteredFileNameString| |
|
1416 |
||
1417 |
self |
|
1418 |
startApplicationFor:titleString |
|
1419 |
default:aFileName |
|
1420 |
ok:okText |
|
1421 |
abort:abortText |
|
1422 |
ifFail:failBlock |
|
1423 |
pattern:patternArg |
|
1424 |
fromDirectory:aDirectoryPath |
|
1425 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
1426 |
asLoadDialog:aBoolean |
|
1427 |
viewFiles:false |
|
1428 |
multipleSelect:false. |
|
1429 |
||
1430 |
enteredFileNameString := self result. |
|
1431 |
enteredFileNameString isNil ifTrue:[ |
|
1432 |
^ failBlock value |
|
1433 |
]. |
|
1434 |
enteredFileName := enteredFileNameString asFilename. |
|
1435 |
enteredFileName isRelative ifTrue:[ |
|
1436 |
enteredFileName := self directory construct:enteredFileNameString |
|
1437 |
]. |
|
1438 |
||
1439 |
enteredFileNameString := enteredFileName asString. |
|
1440 |
(enteredFileName notNil |
|
1441 |
and:[enteredFileNameString notEmpty]) ifTrue:[ |
|
1442 |
versionSymbol isNil ifTrue:[ ^ enteredFileNameString]. |
|
1443 |
versionSymbol == #mustBeNew ifTrue:[ |
|
1444 |
"/ file may not exist |
|
1445 |
enteredFileName exists ifTrue:[^ '']. |
|
1446 |
]. |
|
1447 |
versionSymbol == #new ifTrue:[ |
|
1448 |
"/ file may not exist |
|
1449 |
enteredFileName exists ifTrue:[ |
|
1450 |
(Dialog confirm:(resources stringWithCRs:'''%1'' exists.\\Continue anyway ?' with:enteredFileNameString)) |
|
1451 |
ifFalse:[^ '']. |
|
1452 |
]. |
|
1453 |
]. |
|
1454 |
versionSymbol == #mustBeOld ifTrue:[ |
|
1455 |
enteredFileName exists ifFalse:[^ '']. |
|
1456 |
]. |
|
1457 |
versionSymbol == #old ifTrue:[ |
|
1458 |
"/ file may not exist |
|
1459 |
enteredFileName exists ifFalse:[ |
|
1460 |
(self confirm:(resources stringWithCRs:'''%1'' does not exist yet.\\Continue anyway ?' with:enteredFileNameString)) |
|
1461 |
ifFalse:[^ '']. |
|
1462 |
]. |
|
1463 |
]. |
|
1464 |
FileSelectionBox lastFileSelectionDirectory:(enteredFileNameString). |
|
1465 |
]. |
|
1466 |
^ enteredFileNameString |
|
1467 |
||
1468 |
" |
|
1469 |
FileDialog |
|
1470 |
requestDirectoryName:'which directory ?' |
|
1471 |
default:Filename currentDirectory pathName |
|
1472 |
ifFail:nil |
|
1473 |
" |
|
1474 |
" |
|
1475 |
FileDialog |
|
1476 |
requestDirectoryName:'which directory ?' |
|
1477 |
default:Filename currentDirectory pathName |
|
1478 |
ok:nil |
|
1479 |
abort:nil |
|
1480 |
version:nil |
|
1481 |
pattern:nil |
|
1482 |
fromDirectory:nil |
|
1483 |
ifFail:nil |
|
1484 |
whenBoxCreatedEvaluate:nil |
|
1485 |
asLoadDialog:true |
|
1486 |
" |
|
1487 |
! |
|
1488 |
||
1489 |
requestFileName:titleString default:defaultName ok:okText abort:abortText |
|
1490 |
version:versionSymbol |
|
1491 |
ifFail:failBlock |
|
1492 |
pattern:patternArg |
|
1493 |
fromDirectory:aDirectoryPath |
|
1494 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
1495 |
asLoadDialog:aBoolean |
|
1496 |
||
1497 |
"launch a Dialog, which allows user to enter a filename. |
|
1498 |
The files presented initially are those in aDirectoryPathOrNil, or the |
|
1499 |
last fileBox directory (default: current directory) (if a nil path is given). |
|
1500 |
The box will show okText in its okButton, abortText in the abortButton. |
|
1501 |
The matchPattern is set to pattern initially. |
|
1502 |
Return the string, or nil if cancel was pressed |
|
1503 |
The version argument allows validation of the files existance; |
|
1504 |
it may be any of: |
|
1505 |
#mustBeNew - fail (return empty string) if the file exists |
|
1506 |
#new - confirm if the file exists |
|
1507 |
#mustBeOld - fail if the file does not exist |
|
1508 |
#old - confirm if the file does not exist |
|
1509 |
#any (other) - no validation |
|
1510 |
" |
|
1511 |
||
1512 |
||
1513 |
|patternUsed enteredFileName enteredFileNameString| |
|
1514 |
||
1515 |
patternUsed := FileSelectionBox lastSuffixPatternUsedForDefault:patternArg. |
|
1516 |
||
1517 |
self |
|
1518 |
startApplicationFor:titleString |
|
1519 |
default:defaultName |
|
1520 |
ok:okText |
|
1521 |
abort:abortText |
|
1522 |
ifFail:failBlock |
|
1523 |
pattern:patternUsed |
|
1524 |
fromDirectory:aDirectoryPath |
|
1525 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
1526 |
asLoadDialog:aBoolean |
|
1527 |
viewFiles:true |
|
1528 |
multipleSelect:false. |
|
1529 |
||
1530 |
enteredFileNameString := self result. |
|
1531 |
enteredFileNameString isEmptyOrNil ifTrue:[ |
|
1532 |
^ failBlock value |
|
1533 |
]. |
|
1534 |
||
1535 |
enteredFileName := enteredFileNameString asFilename. |
|
1536 |
enteredFileName isRelative ifTrue:[ |
|
1537 |
(versionSymbol isNil and:[#(http https ftp) includes:(enteredFileNameString upToAll:'://')]) ifTrue:[ |
|
1538 |
^ enteredFileNameString. |
|
1539 |
] ifFalse:[ |
|
1540 |
enteredFileName := self directory construct:enteredFileNameString. |
|
1541 |
enteredFileNameString := enteredFileName asString. |
|
1542 |
]. |
|
1543 |
]. |
|
1544 |
||
1545 |
FileSelectionBox lastFileSelectionDirectory:(enteredFileName directoryName). |
|
1546 |
(patternArg notEmptyOrNil and:[self pattern ~= patternArg]) ifTrue:[ |
|
1547 |
FileSelectionBox lastSuffixPatternUsedForDefault:patternArg is:self pattern |
|
1548 |
]. |
|
1549 |
||
1550 |
versionSymbol isNil ifTrue:[ ^ enteredFileNameString]. |
|
1551 |
versionSymbol == #mustBeNew ifTrue:[ |
|
1552 |
"/ file must not exist |
|
1553 |
enteredFileName exists ifTrue:[^ failBlock value]. |
|
1554 |
]. |
|
1555 |
versionSymbol == #new ifTrue:[ |
|
1556 |
"/ file should not exist |
|
1557 |
enteredFileName exists ifTrue:[ |
|
1558 |
(Dialog confirm:(resources stringWithCRs:'''%1'' exists.\\Continue anyway ?' with:enteredFileNameString)) |
|
1559 |
ifFalse:[^ failBlock value]. |
|
1560 |
]. |
|
1561 |
]. |
|
1562 |
versionSymbol == #mustBeOld ifTrue:[ |
|
1563 |
"/ file must exist |
|
1564 |
enteredFileName exists ifFalse:[^ failBlock value]. |
|
1565 |
]. |
|
1566 |
versionSymbol == #old ifTrue:[ |
|
1567 |
"/ file should exist |
|
1568 |
enteredFileName exists ifFalse:[ |
|
1569 |
(self confirm:(resources stringWithCRs:'''%1'' does not exist yet.\\Continue anyway ?' with:enteredFileNameString)) |
|
1570 |
ifFalse:[^ failBlock value]. |
|
1571 |
]. |
|
1572 |
]. |
|
1573 |
||
1574 |
^ enteredFileNameString |
|
1575 |
" |
|
1576 |
FileDialog |
|
1577 |
requestFileName:'enter a fileName:' |
|
1578 |
default:'' |
|
1579 |
ok:nil |
|
1580 |
abort:nil |
|
1581 |
version:nil |
|
1582 |
ifFail:['none'] |
|
1583 |
pattern:'*' |
|
1584 |
fromDirectory:Filename currentDirectory pathName |
|
1585 |
whenBoxCreatedEvaluate:nil |
|
1586 |
asLoadDialog:true |
|
1587 |
" |
|
1588 |
! |
|
1589 |
||
1590 |
requestFileNames:titleString default:defaultName |
|
1591 |
ok:okText abort:abortText |
|
1592 |
ifFail:failBlock |
|
1593 |
pattern:patternArg |
|
1594 |
fromDirectory:aDirectoryPath |
|
1595 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
1596 |
asLoadDialog:asLoadDialog |
|
1597 |
||
1598 |
"launch a Dialog, which allows user to enter a filename. |
|
1599 |
The files presented initially are those in aDirectoryPathOrNil, or the |
|
1600 |
last fileBox directory (default: current directory) (if a nil path is given). |
|
1601 |
The box will show okText in its okButton, abortText in the abortButton. |
|
1602 |
The matchPattern is set to pattern initially. |
|
1603 |
Return all selected Filenames as filenames in a collection, or nil if cancel was pressed |
|
1604 |
" |
|
1605 |
||
1606 |
||
1607 |
| enteredFileNames lastDirectory| |
|
1608 |
||
1609 |
self |
|
1610 |
startApplicationFor:titleString |
|
1611 |
default:defaultName |
|
1612 |
ok:okText |
|
1613 |
abort:abortText |
|
1614 |
ifFail:failBlock |
|
1615 |
pattern:patternArg |
|
1616 |
fromDirectory:aDirectoryPath |
|
1617 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
1618 |
asLoadDialog:asLoadDialog |
|
1619 |
viewFiles:true |
|
1620 |
multipleSelect:true. |
|
1621 |
||
1622 |
enteredFileNames := self currentSelectedFiles. |
|
1623 |
(enteredFileNames isEmpty or:[self result isNil]) ifTrue:[ |
|
1624 |
^ failBlock value |
|
1625 |
]. |
|
1626 |
lastDirectory := enteredFileNames first. |
|
1627 |
lastDirectory := lastDirectory isFilename ifTrue:[lastDirectory directory] ifFalse:[lastDirectory]. |
|
1628 |
FileSelectionBox lastFileSelectionDirectory:(lastDirectory directoryName). |
|
1629 |
^ enteredFileNames |
|
1630 |
||
1631 |
" |
|
1632 |
FileDialog |
|
1633 |
requestFileNames:'enter a fileName:' |
|
1634 |
default:'' |
|
1635 |
ok:nil |
|
1636 |
abort:nil |
|
1637 |
ifFail:['none'] |
|
1638 |
pattern:'*.conf' |
|
1639 |
fromDirectory:Filename currentDirectory pathName |
|
1640 |
whenBoxCreatedEvaluate:nil |
|
1641 |
asLoadDialog:true. |
|
1642 |
" |
|
1643 |
! |
|
1644 |
||
1645 |
startApplicationFor:titleString default:initialDefaultFileNameArg |
|
1646 |
ok:okTextArg abort:abortTextArg |
|
1647 |
ifFail:failBlock |
|
1648 |
pattern:patternArg |
|
1649 |
fromDirectory:aDirectoryPath |
|
1650 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
1651 |
asLoadDialog:asLoadDialog |
|
1652 |
viewFiles:viewFilesArg |
|
1653 |
multipleSelect:multipleSelectArg |
|
1654 |
||
1655 |
"launch a Dialog, which allows user to enter a filename. |
|
1656 |
The files presented initially are those in aDirectoryPathOrNil, or the |
|
1657 |
last fileBox directory (default: current directory) (if a nil path is given). |
|
1658 |
The box will show okText in its okButton, abortText in the abortButton. |
|
1659 |
The matchPattern is set to patternArg initially. |
|
1660 |
Return the string, or nil if cancel was pressed |
|
1661 |
The version argument allows validation of the files existance; |
|
1662 |
it may be any of: |
|
1663 |
#mustBeNew - fail (return empty string) if the file exists |
|
1664 |
#new - confirm if the file exists |
|
1665 |
#mustBeOld - fail if the file does not exist |
|
1666 |
#old - confirm if the file does not exist |
|
1667 |
#any (other) - no validation |
|
1668 |
" |
|
1669 |
||
1670 |
||
1671 |
|defaultDir defaultFile okText abortText initialDefaultFileName| |
|
1672 |
||
1673 |
initialDefaultFileName := initialDefaultFileNameArg. |
|
1674 |
initialDefaultFileName notNil ifTrue:[ |
|
1675 |
initialDefaultFileName := initialDefaultFileName asFilename. |
|
1676 |
]. |
|
1677 |
||
1678 |
okText := okTextArg. |
|
1679 |
okText isNil ifTrue:[ okText := self resources string:'OK' ]. |
|
1680 |
abortText := abortTextArg. |
|
1681 |
abortText isNil ifTrue:[ abortText := self resources string:'Cancel' ]. |
|
1682 |
||
1683 |
defaultDir := aDirectoryPath. |
|
1684 |
"/ defaultDir isNil ifTrue:[ |
|
1685 |
"/ (initialDefaultFileName size > 0 and:[initialDefaultFileName exists]) ifTrue:[ |
|
1686 |
"/ defaultDir := initialDefaultFileName asAbsoluteFilename directory. |
|
1687 |
"/ ] ifFalse:[ |
|
1688 |
"/ defaultDir := FileSelectionBox lastFileSelectionDirectory. |
|
1689 |
"/ defaultDir isNil ifTrue:[ |
|
1690 |
"/ defaultDir := Filename currentDirectory asAbsoluteFilename. |
|
1691 |
"/ ]. |
|
1692 |
"/ defaultDir asFilename exists ifFalse:[ |
|
1693 |
"/ defaultDir := nil |
|
1694 |
"/ ]. |
|
1695 |
"/ ] |
|
1696 |
"/ ]. |
|
1697 |
(initialDefaultFileName notNil |
|
1698 |
and:[initialDefaultFileName isAbsolute |
|
1699 |
and:[true "initialDefaultFileName asFilename exists"]]) ifTrue:[ |
|
1700 |
defaultDir := initialDefaultFileName asAbsoluteFilename. |
|
1701 |
true "viewFilesArg" ifTrue:[ |
|
1702 |
defaultFile := defaultDir asAbsoluteFilename. |
|
1703 |
defaultDir := defaultDir directory. |
|
1704 |
]. |
|
1705 |
] ifFalse:[ |
|
1706 |
defaultDir isNil ifTrue:[ |
|
1707 |
defaultDir := FileSelectionBox lastFileSelectionDirectory. |
|
1708 |
defaultDir isNil ifTrue:[ |
|
1709 |
defaultDir := Filename currentDirectory asAbsoluteFilename. |
|
1710 |
]. |
|
1711 |
defaultDir asFilename exists ifFalse:[ |
|
1712 |
defaultDir := nil |
|
1713 |
]. |
|
1714 |
] |
|
1715 |
]. |
|
1716 |
defaultDir := defaultDir asFilename asAbsoluteFilename. |
|
1717 |
"/ [defaultDir exists] whileFalse:[ |
|
1718 |
"/ defaultDir := defaultDir directory. |
|
1719 |
"/ ]. |
|
1720 |
||
1721 |
defaultFile isNil ifTrue:[ |
|
1722 |
viewFilesArg ifFalse:[ |
|
1723 |
defaultFile := defaultDir asAbsoluteFilename. |
|
1724 |
] ifTrue:[ |
|
1725 |
(initialDefaultFileName notNil and:[initialDefaultFileName withoutSuffix baseName ~= '*']) ifTrue:[ |
|
1726 |
defaultFile := defaultDir construct:initialDefaultFileName baseName. |
|
1727 |
] ifFalse:[ |
|
1728 |
defaultFile := defaultDir. |
|
1729 |
]. |
|
1730 |
]. |
|
1731 |
]. |
|
1732 |
||
1733 |
defaultDir notNil ifTrue:[self directory:defaultDir]. |
|
1734 |
self multipleSelect:(multipleSelectArg ? false). |
|
1735 |
self startFilename:defaultFile. |
|
1736 |
self pattern:(patternArg isEmptyOrNil ifTrue:['*'] ifFalse:[patternArg]). |
|
1737 |
self initialText:titleString. |
|
1738 |
self beLoadDialog:asLoadDialog ? false. |
|
1739 |
self viewFiles:(viewFilesArg ? true). |
|
1740 |
||
1741 |
self okLabelHolder value:okText. |
|
1742 |
self cancelLabelHolder value:abortText. |
|
1743 |
||
1744 |
self doubleClickAction:[:anIndex| |
|
1745 |
| item | |
|
1746 |
item := self treeBrowser fileList at:anIndex ifAbsent:nil. |
|
1747 |
item notNil ifTrue:[ |
|
1748 |
(self viewFiles and:[item isDirectory not]) ifTrue:[ |
|
1749 |
self doAccept. |
|
1750 |
] |
|
1751 |
] |
|
1752 |
]. |
|
1753 |
self allButOpenInterface:#windowSpec. |
|
1754 |
boxCreatedCallback notNil ifTrue:[boxCreatedCallback value:self]. |
|
1755 |
||
1756 |
"/ Dialog aboutToOpenBoxNotificationSignal raiseRequestWith:instance. |
|
1757 |
self treeBrowser sortCaseless value: (Filename isCaseSensitive not). |
|
1758 |
self openWindowModal. |
|
1759 |
||
1760 |
"Modified: / 23-08-2006 / 12:24:54 / cg" |
|
1761 |
"Modified: / 13-12-2006 / 16:25:42 / User" |
|
1762 |
"Modified (format): / 14-02-2017 / 12:49:34 / cg" |
|
1763 |
! ! |
|
1764 |
||
3892 | 1765 |
!FileDialog methodsFor:'accessing'! |
1766 |
||
19478 | 1767 |
additionalFolderItemsInMenu:aCollectionOfFoldernames |
1768 |
"any additional folders to be shown in this 'File' menu; |
|
1769 |
each element can be either a filename or a pair with filename and menu-item-label, |
|
1770 |
or an assoc, with key=filename and value=label." |
|
1771 |
||
1772 |
additionalFolderItemsInMenu := aCollectionOfFoldernames. |
|
1773 |
! |
|
1774 |
||
18749 | 1775 |
appendWasPressed |
1776 |
"valid after the dialog has been closed: true if append was pressed" |
|
1777 |
||
1778 |
^ appendWasPressed |
|
1779 |
! |
|
1780 |
||
3996 | 1781 |
currentSelectedFiles |
1782 |
||
1783 |
| selectedFiles| |
|
1784 |
||
1785 |
selectedFiles := treeBrowser currentFileNameHolder value. |
|
12828 | 1786 |
^ selectedFiles reject:[:aFile| aFile isDirectory ]. |
3996 | 1787 |
! |
1788 |
||
18015 | 1789 |
defaultWindowExtent |
1790 |
"return my default window extent or nil. |
|
1791 |
Return nil if the defaul extent should be computed by other means." |
|
1792 |
||
1793 |
^ LastExtent |
|
1794 |
||
1795 |
"Created: / 20-03-2018 / 11:26:14 / stefan" |
|
1796 |
! |
|
1797 |
||
3892 | 1798 |
directory |
1799 |
"return the value of the instance variable 'directory' (automatically generated)" |
|
1800 |
||
1801 |
^ directory |
|
1802 |
! |
|
1803 |
||
1804 |
directory:something |
|
1805 |
"set the value of the instance variable 'directory' (automatically generated)" |
|
1806 |
||
1807 |
directory := something. |
|
1808 |
! |
|
1809 |
||
1810 |
initialText |
|
13090 | 1811 |
^ resources string:(initialText ? 'File Dialog') |
3892 | 1812 |
! |
1813 |
||
1814 |
initialText:something |
|
1815 |
initialText := something. |
|
1816 |
! |
|
1817 |
||
1818 |
pattern |
|
1819 |
"return the value of the instance variable 'pattern' (automatically generated)" |
|
1820 |
||
1821 |
^ pattern |
|
1822 |
! |
|
1823 |
||
1824 |
pattern:something |
|
1825 |
"set the value of the instance variable 'pattern' (automatically generated)" |
|
1826 |
||
1827 |
pattern := something. |
|
1828 |
! |
|
1829 |
||
1830 |
result |
|
1831 |
"return the value of the instance variable 'result' (automatically generated)" |
|
1832 |
||
1833 |
^ result |
|
1834 |
! |
|
1835 |
||
1836 |
result:something |
|
1837 |
"set the value of the instance variable 'result' (automatically generated)" |
|
1838 |
||
1839 |
result := something. |
|
1840 |
! |
|
1841 |
||
3904 | 1842 |
selectedDirectories |
1843 |
||
1844 |
| selectedFiles| |
|
1845 |
||
1846 |
selectedFiles := treeBrowser currentFileNameHolder value. |
|
1847 |
^ selectedFiles select:[:aFile| aFile isDirectory]. |
|
1848 |
! |
|
1849 |
||
3892 | 1850 |
startFilename |
1851 |
startFilename isNil ifTrue:[ |
|
1852 |
startFilename := Filename currentDirectory asAbsoluteFilename. |
|
1853 |
]. |
|
1854 |
^ startFilename |
|
1855 |
! |
|
1856 |
||
1857 |
startFilename:something |
|
1858 |
startFilename := something. |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1859 |
! ! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1860 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1861 |
!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
|
1862 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1863 |
asLoadDialog |
4804 | 1864 |
^ self isLoadDialog |
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1865 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1866 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1867 |
asLoadDialog:aBoolean |
4804 | 1868 |
self beLoadDialog:aBoolean |
1869 |
! |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1870 |
|
4804 | 1871 |
beLoadDialog:aBoolean |
1872 |
||
1873 |
isLoadDialog := aBoolean |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1874 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1875 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1876 |
doubleClickAction |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1877 |
"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
|
1878 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1879 |
^ doubleClickAction |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1880 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1881 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1882 |
doubleClickAction:something |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1883 |
"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
|
1884 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1885 |
doubleClickAction := something. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1886 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1887 |
|
4804 | 1888 |
isLoadDialog |
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1889 |
|
4804 | 1890 |
^ isLoadDialog ? true |
1891 |
! |
|
1892 |
||
1893 |
multipleSelect |
|
1894 |
^ multipleSelect ? false |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1895 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1896 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1897 |
multipleSelect:aBoolean |
4804 | 1898 |
multipleSelect := aBoolean. |
1899 |
treeBrowser notNil ifTrue:[ |
|
1900 |
treeBrowser multipleSelect:aBoolean. |
|
1901 |
]. |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1902 |
! ! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1903 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1904 |
!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
|
1905 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1906 |
addButton:aButton |
6068 | 1907 |
|buttonPanel okButton| |
1908 |
||
1909 |
buttonPanel := self componentAt:#ButtonPanel. |
|
1910 |
okButton := self okButton. |
|
1911 |
||
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1912 |
DialogBox defaultOKButtonAtLeft ifTrue:[ |
6068 | 1913 |
buttonPanel addSubView:aButton before:okButton |
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1914 |
] ifFalse:[ |
6068 | 1915 |
buttonPanel addSubView:aButton after:okButton |
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1916 |
]. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1917 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1918 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1919 |
okButton |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1920 |
^ (self componentAt:#okButton) |
3892 | 1921 |
! |
1922 |
||
3904 | 1923 |
treeBrowser |
1924 |
"return the value of the instance variable 'treeBrowser' (automatically generated)" |
|
1925 |
||
1926 |
^ treeBrowser |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1927 |
! ! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1928 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1929 |
!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
|
1930 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1931 |
hideButtonPanel |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1932 |
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
|
1933 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1934 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1935 |
newDirectoryVisibilityHolder |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1936 |
newDirectoryVisibilityHolder isNil ifTrue:[ |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1937 |
newDirectoryVisibilityHolder := true asValue. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1938 |
]. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1939 |
^ newDirectoryVisibilityHolder |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1940 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1941 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1942 |
showButtonPanel |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1943 |
self buttonPanelVisibleHolder value:true |
3904 | 1944 |
! |
1945 |
||
3892 | 1946 |
viewFiles |
19166 | 1947 |
"if true, files can be selected; if false, only directories" |
3892 | 1948 |
|
1949 |
^ viewFiles |
|
1950 |
! |
|
1951 |
||
19174 | 1952 |
viewFiles:aBoolean |
19166 | 1953 |
"if true, files can be selected; if false, only directories" |
3892 | 1954 |
|
19174 | 1955 |
viewFiles := aBoolean. |
1956 |
||
1957 |
"Modified (comment): / 10-09-2019 / 18:36:08 / Stefan Vogel" |
|
3892 | 1958 |
! ! |
1959 |
||
1960 |
!FileDialog methodsFor:'aspects'! |
|
1961 |
||
4603
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1962 |
appendButtonVisibleHolder |
15451 | 1963 |
"if set, an additional 'append' button is shown |
1964 |
(to let user append to a file, instead of overwriting the file)" |
|
1965 |
||
4603
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1966 |
appendButtonVisibleHolder isNil ifTrue:[ |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1967 |
appendButtonVisibleHolder := false asValue. |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1968 |
]. |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1969 |
^ appendButtonVisibleHolder |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1970 |
! |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1971 |
|
5193 | 1972 |
appendLabelHolder |
1973 |
appendLabelHolder isNil ifTrue:[ |
|
1974 |
appendLabelHolder := 'Append' asValue. |
|
1975 |
]. |
|
1976 |
^ appendLabelHolder |
|
1977 |
! |
|
1978 |
||
4804 | 1979 |
aspectOrNil:aKey forSubApplication:aSubApp |
1980 |
"this hook provides an aspect for a subApp" |
|
1981 |
||
1982 |
aKey == #currentFileNameHolder ifTrue:[ |
|
1983 |
directory notNil ifTrue:[ |
|
1984 |
^ (OrderedCollection with:directory) asValue |
|
1985 |
] |
|
1986 |
]. |
|
1987 |
^ nil |
|
1988 |
! |
|
1989 |
||
15451 | 1990 |
browseMenuItemVisible:aBoolean |
1991 |
"controls if an 'open filebrowser' menu item is to be shown in the toolbar" |
|
1992 |
||
1993 |
self browseMenuItemVisibleHolder value:aBoolean |
|
1994 |
! |
|
1995 |
||
1996 |
browseMenuItemVisibleHolder |
|
1997 |
"controls if an 'open filebrowser' menu item is to be shown in the toolbar" |
|
1998 |
||
19174 | 1999 |
browseMenuItemVisibleHolder isNil ifTrue:[ |
2000 |
browseMenuItemVisibleHolder := true "false" asValue. |
|
5969 | 2001 |
]. |
19174 | 2002 |
^ browseMenuItemVisibleHolder. |
15451 | 2003 |
! |
2004 |
||
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
2005 |
buttonPanelVisibleHolder |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
2006 |
buttonPanelVisibleHolder isNil ifTrue:[ |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
2007 |
buttonPanelVisibleHolder := true asValue. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
2008 |
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
|
2009 |
]. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
2010 |
^ buttonPanelVisibleHolder. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
2011 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
2012 |
|
3892 | 2013 |
cancelLabelHolder |
2014 |
||
2015 |
cancelLabelHolder isNil ifTrue:[ |
|
2016 |
cancelLabelHolder := 'Cancel' asValue. |
|
2017 |
]. |
|
2018 |
^ cancelLabelHolder. |
|
2019 |
! |
|
2020 |
||
2021 |
enableBack |
|
4804 | 2022 |
^ treeBrowser enableBack. |
3892 | 2023 |
! |
2024 |
||
2025 |
enableDirectoryUp |
|
4804 | 2026 |
^ treeBrowser enableDirectoryUp. |
3892 | 2027 |
! |
2028 |
||
2029 |
enableForward |
|
4804 | 2030 |
^ treeBrowser enableForward. |
3892 | 2031 |
! |
2032 |
||
18533 | 2033 |
enableGotoDesktopDirectory |
18512 | 2034 |
^ treeBrowser enableGotoDesktopDirectory. |
18533 | 2035 |
|
2036 |
"Created: / 30-11-2018 / 17:05:19 / Stefan Vogel" |
|
18512 | 2037 |
! |
2038 |
||
2039 |
enableGotoDocuments |
|
2040 |
^ treeBrowser enableGotoDocumentsDirectory. |
|
2041 |
! |
|
2042 |
||
2043 |
enableGotoDownloads |
|
2044 |
^ treeBrowser enableGotoDownloadsDirectory. |
|
8169 | 2045 |
! |
2046 |
||
3892 | 2047 |
enableHome |
4804 | 2048 |
^ treeBrowser enableHome. |
3892 | 2049 |
! |
2050 |
||
9269
4d09efee3752
added: #fileEntryFieldHolder
Claus Gittinger <cg@exept.de>
parents:
9113
diff
changeset
|
2051 |
fileEntryFieldHolder |
4d09efee3752
added: #fileEntryFieldHolder
Claus Gittinger <cg@exept.de>
parents:
9113
diff
changeset
|
2052 |
"for directoryTreeBrowser" |
4d09efee3752
added: #fileEntryFieldHolder
Claus Gittinger <cg@exept.de>
parents:
9113
diff
changeset
|
2053 |
|
4d09efee3752
added: #fileEntryFieldHolder
Claus Gittinger <cg@exept.de>
parents:
9113
diff
changeset
|
2054 |
^ self filenameHolder |
4d09efee3752
added: #fileEntryFieldHolder
Claus Gittinger <cg@exept.de>
parents:
9113
diff
changeset
|
2055 |
! |
4d09efee3752
added: #fileEntryFieldHolder
Claus Gittinger <cg@exept.de>
parents:
9113
diff
changeset
|
2056 |
|
3892 | 2057 |
filenameHolder |
2058 |
"Return a value holder with the filename. |
|
2059 |
Shown in the filename input-field. |
|
9514
c818ca8969f7
comment/format in: #filenameHolder
Claus Gittinger <cg@exept.de>
parents:
9476
diff
changeset
|
2060 |
Being the selection in the tree." |
c818ca8969f7
comment/format in: #filenameHolder
Claus Gittinger <cg@exept.de>
parents:
9476
diff
changeset
|
2061 |
|
3892 | 2062 |
|holder| |
7581 | 2063 |
|
3892 | 2064 |
holder := builder bindingAt:#filenameHolder. |
2065 |
||
7581 | 2066 |
holder isNil ifTrue:[ |
13001 | 2067 |
holder := startFilename asValue. |
3892 | 2068 |
holder addDependent:self. |
9514
c818ca8969f7
comment/format in: #filenameHolder
Claus Gittinger <cg@exept.de>
parents:
9476
diff
changeset
|
2069 |
builder aspectAt:#filenameHolder put:holder. |
3892 | 2070 |
]. |
2071 |
||
2072 |
^ holder. |
|
9514
c818ca8969f7
comment/format in: #filenameHolder
Claus Gittinger <cg@exept.de>
parents:
9476
diff
changeset
|
2073 |
|
c818ca8969f7
comment/format in: #filenameHolder
Claus Gittinger <cg@exept.de>
parents:
9476
diff
changeset
|
2074 |
"Modified: / 09-07-2010 / 19:25:15 / cg" |
3892 | 2075 |
! |
2076 |
||
8183 | 2077 |
filenameHolder:aHolder |
8182 | 2078 |
"needed when used as subcanvas" |
8183 | 2079 |
|
2080 |
|holder| |
|
8182 | 2081 |
|
8183 | 2082 |
holder := builder aspectAt:#filenameHolder. |
2083 |
holder notNil ifTrue:[ |
|
2084 |
holder removeDependent:self |
|
2085 |
]. |
|
8182 | 2086 |
builder aspectAt:#filenameHolder put:aHolder. |
8183 | 2087 |
aHolder addDependent:self |
8182 | 2088 |
! |
2089 |
||
3904 | 2090 |
filenameLabelHolder |
2091 |
"Return a value holder for the input string. |
|
2092 |
" |
|
2093 |
filenameLabelHolder isNil ifTrue:[ |
|
2094 |
filenameLabelHolder := 'Filename:' asValue. |
|
2095 |
]. |
|
2096 |
^ filenameLabelHolder |
|
2097 |
! |
|
2098 |
||
3892 | 2099 |
filterHolder |
8183 | 2100 |
"Return a value holder for filter" |
3892 | 2101 |
|
2102 |
filterHolder isNil ifTrue:[ |
|
8191
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2103 |
filterHolder := (self pattern ? '*') asValue. |
3892 | 2104 |
]. |
2105 |
^ filterHolder |
|
2106 |
! |
|
2107 |
||
8183 | 2108 |
filterHolder:aHolder |
2109 |
"needed when used as subcanvas" |
|
2110 |
||
2111 |
filterHolder := aHolder. |
|
2112 |
! |
|
2113 |
||
9113 | 2114 |
gotoBookmarksMenu |
6098 | 2115 |
<resource: #programMenu> |
2116 |
||
9113 | 2117 |
^ treeBrowser gotoBookmarksMenu |
7567
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2118 |
"/ |menu bookmarks| |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2119 |
"/ |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2120 |
"/ menu := treeBrowser class emptyMenuSpec decodeAsLiteralArray. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2121 |
"/ menu findGuiResourcesIn:self. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2122 |
"/ menu receiver:self. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2123 |
"/ |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2124 |
"/ "/ add the bookmark items ... |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2125 |
"/ bookmarks := treeBrowser class directoryBookmarks. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2126 |
"/ bookmarks notEmptyOrNil ifTrue:[ |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2127 |
"/ bookmarks do:[:dirName | |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2128 |
"/ menu addItem:((MenuItem label:dirName asString value:[ |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2129 |
"/ (treeBrowser currentSelectedDirectories includes:dirName) ifFalse:[ |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2130 |
"/ treeBrowser setCurrentFileName:dirName. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2131 |
"/ ]. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2132 |
"/ ])). |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2133 |
"/ ]. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2134 |
"/ ]. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2135 |
"/ ^ menu |
6098 | 2136 |
|
7567
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2137 |
"Modified: / 06-12-2006 / 12:05:06 / cg" |
6098 | 2138 |
! |
2139 |
||
6065 | 2140 |
listOfDeviceDrives |
2141 |
||
2142 |
listOfDeviceDrives isNil ifTrue:[ |
|
2143 |
listOfDeviceDrives := Filename volumes. |
|
2144 |
]. |
|
2145 |
^ listOfDeviceDrives |
|
2146 |
! |
|
2147 |
||
15766 | 2148 |
okLabelEnabled |
2149 |
<resource: #uiAspect> |
|
2150 |
||
2151 |
okLabelEnabled isNil ifTrue:[ |
|
2152 |
isLoadDialog ifTrue:[ |
|
17410 | 2153 |
okLabelEnabled := |
2154 |
BlockValue |
|
2155 |
with:[:filename| |
|
2156 |
|ok| |
|
2157 |
||
2158 |
ok := true. |
|
2159 |
||
2160 |
multipleSelect ifTrue:[ |
|
2161 |
ok := treeBrowser selectedFiles notEmpty |
|
2162 |
and:[ treeBrowser selectedFiles conform:[:each | each isRegularFile] ] |
|
2163 |
] ifFalse:[ |
|
2164 |
filename isEmptyOrNil ifTrue:[ |
|
2165 |
ok := false |
|
2166 |
] ifFalse:[ |
|
2167 |
|physicalFilename| |
|
2168 |
||
2169 |
physicalFilename := filename asFilename physicalFilename. |
|
2170 |
physicalFilename isNil ifTrue:[ |
|
2171 |
ok := false |
|
2172 |
] ifFalse:[ |
|
2173 |
viewFiles |
|
2174 |
ifTrue:[ ok := physicalFilename isRegularFile ] |
|
2175 |
ifFalse:[ ok := physicalFilename isDirectory ] |
|
2176 |
]. |
|
2177 |
] |
|
2178 |
]. |
|
2179 |
ok |
|
2180 |
] |
|
2181 |
argument:self filenameHolder. |
|
15766 | 2182 |
] ifFalse:[ |
2183 |
okLabelEnabled := true. |
|
2184 |
]. |
|
2185 |
]. |
|
2186 |
^ okLabelEnabled. |
|
17410 | 2187 |
|
2188 |
"Modified: / 14-02-2017 / 13:00:40 / cg" |
|
15766 | 2189 |
! |
2190 |
||
3892 | 2191 |
okLabelHolder |
16185 | 2192 |
<resource: #uiAspect> |
3892 | 2193 |
|
2194 |
okLabelHolder isNil ifTrue:[ |
|
2195 |
okLabelHolder := 'OK' asValue. |
|
2196 |
]. |
|
2197 |
^ okLabelHolder. |
|
6065 | 2198 |
! |
2199 |
||
8191
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2200 |
rootDirectoryHolder |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2201 |
"Return a value holder for filter" |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2202 |
|
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2203 |
rootDirectoryHolder isNil ifTrue:[ |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2204 |
rootDirectoryHolder := self initialRootDirectory asValue. |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2205 |
]. |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2206 |
^ rootDirectoryHolder |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2207 |
! |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2208 |
|
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2209 |
rootDirectoryHolder:aHolder |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2210 |
"Return a value holder for filter" |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2211 |
|
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2212 |
rootDirectoryHolder := aHolder. |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2213 |
! |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2214 |
|
19012 | 2215 |
searchInfoBoxVisibleHolder |
2216 |
"set during search-file operation" |
|
2217 |
||
2218 |
searchInfoBoxVisibleHolder isNil ifTrue:[ |
|
2219 |
searchInfoBoxVisibleHolder := false asValue. |
|
2220 |
]. |
|
2221 |
^ searchInfoBoxVisibleHolder |
|
2222 |
! |
|
2223 |
||
2224 |
searchedDirectoryInfoHolder |
|
2225 |
"updated during search-file operation" |
|
2226 |
||
2227 |
searchedDirectoryInfoHolder isNil ifTrue:[ |
|
2228 |
searchedDirectoryInfoHolder := nil asValue. |
|
2229 |
]. |
|
2230 |
^ searchedDirectoryInfoHolder |
|
2231 |
! |
|
2232 |
||
6065 | 2233 |
selectedDeviceDrive |
2234 |
||
2235 |
selectedDeviceDrive isNil ifTrue:[ |
|
2236 |
selectedDeviceDrive := self listOfDeviceDrives first asValue. |
|
2237 |
selectedDeviceDrive addDependent:self. |
|
2238 |
]. |
|
2239 |
^ selectedDeviceDrive |
|
9110 | 2240 |
! |
2241 |
||
9113 | 2242 |
showDirectoryTree |
2243 |
^ false |
|
2244 |
! |
|
2245 |
||
2246 |
showDiskUsageHolder |
|
2247 |
^ treeBrowser showDiskUsageHolder |
|
2248 |
! |
|
2249 |
||
9110 | 2250 |
showHiddenFiles |
9113 | 2251 |
^ treeBrowser showHiddenFiles |
2252 |
! |
|
2253 |
||
2254 |
shownFiles |
|
2255 |
^ treeBrowser shownFiles |
|
2256 |
! |
|
2257 |
||
19357 | 2258 |
sortCaseless |
2259 |
^ treeBrowser sortCaseless |
|
2260 |
! |
|
2261 |
||
9113 | 2262 |
sortCaselessInTreeBrowser |
19357 | 2263 |
<resource: #obsolete> |
2264 |
||
2265 |
"only for backward compat. |
|
2266 |
We do not need two such flags" |
|
2267 |
||
9113 | 2268 |
^ treeBrowser sortCaselessInTreeBrowser |
2269 |
! |
|
2270 |
||
2271 |
sortInTreeVisibilityHolder |
|
2272 |
^ true |
|
2273 |
! |
|
2274 |
||
2275 |
sortPropertyInTree |
|
2276 |
^ treeBrowser sortBlockProperty |
|
2277 |
! |
|
2278 |
||
2279 |
viewDirsInContentsBrowser |
|
2280 |
^ false |
|
2281 |
! |
|
2282 |
||
2283 |
viewFilesInDirectoryTree |
|
2284 |
^ false |
|
2285 |
! |
|
2286 |
||
2287 |
viewNoteBookApplicationHolder |
|
9110 | 2288 |
^ false |
3892 | 2289 |
! ! |
2290 |
||
2291 |
!FileDialog methodsFor:'change & update'! |
|
2292 |
||
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
2293 |
buttonPanelVisibilityChanged |
12848
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2294 |
|panel filePart partAbove| |
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
2295 |
|
12848
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2296 |
panel := builder componentAt:#FilePanel. |
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2297 |
panel isNil ifTrue:[ |
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2298 |
filePart := builder componentAt:#FilePart. |
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2299 |
]. |
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2300 |
partAbove := panel ? filePart. |
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2301 |
partAbove notNil ifTrue:[ |
5598 | 2302 |
buttonPanelVisibleHolder value ifTrue:[ |
12848
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2303 |
partAbove layout bottomOffset:-40 |
5598 | 2304 |
] ifFalse:[ |
12848
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2305 |
partAbove layout bottomOffset:0 |
5598 | 2306 |
]. |
12848
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2307 |
partAbove containerChangedSize "/ force resize |
5598 | 2308 |
] |
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
2309 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
2310 |
|
9765 | 2311 |
fileSelectionChanged |
19120 | 2312 |
|files singleSelectedFileOrDirectory newFile entryFieldFilename filenameHolder| |
9765 | 2313 |
|
19120 | 2314 |
"/ the name in the entry field |
9765 | 2315 |
filenameHolder := self filenameHolder. |
2316 |
||
19120 | 2317 |
"/ the selection in the tree |
9765 | 2318 |
files := treeBrowser currentFileNameHolder value. |
19120 | 2319 |
files size == 1 ifTrue:[ |
2320 |
singleSelectedFileOrDirectory := files first. |
|
2321 |
]. |
|
2322 |
singleSelectedFileOrDirectory isNil ifTrue:[ |
|
2323 |
"/ self halt. |
|
2324 |
^ self. |
|
2325 |
]. |
|
2326 |
singleSelectedFileOrDirectory := singleSelectedFileOrDirectory asFilename. |
|
9765 | 2327 |
|
19178 | 2328 |
"/ (viewFiles and:[singleSelectedFileOrDirectory isDirectory]) ifTrue:[ |
2329 |
"/ entryFieldFilename := filenameHolder value. |
|
2330 |
"/ (entryFieldFilename isEmptyOrNil or:[(entryFieldFilename := entryFieldFilename asFilename) isDirectory]) ifTrue:[ |
|
2331 |
"/ "currently no plain file is selected. Replace the currently selected nothing or directory" |
|
2332 |
"/ newFile := singleSelectedFileOrDirectory. |
|
2333 |
"/ ] ifFalse:[ |
|
2334 |
"/ self startFilename asFilename baseName = entryFieldFilename baseName ifTrue:[ |
|
2335 |
"/ newFile := singleSelectedFileOrDirectory construct:entryFieldFilename baseName. |
|
2336 |
"/ ]. |
|
2337 |
"/ ]. |
|
2338 |
||
2339 |
viewFiles ifFalse:[ |
|
2340 |
newFile := singleSelectedFileOrDirectory. |
|
2341 |
] ifTrue:[ |
|
2342 |
singleSelectedFileOrDirectory isDirectory ifFalse:[ |
|
2343 |
"/ user clicked on a file |
|
19166 | 2344 |
newFile := singleSelectedFileOrDirectory. |
19178 | 2345 |
] ifTrue:[ |
2346 |
"/ user clicked on a directory; |
|
2347 |
"/ if the entry field holds a file, keep the basename |
|
2348 |
(entryFieldFilename := filenameHolder value) notEmptyOrNil ifTrue:[ |
|
2349 |
entryFieldFilename := entryFieldFilename asFilename. |
|
2350 |
entryFieldFilename isDirectory ifFalse:[ |
|
2351 |
self startFilename asFilename baseName = entryFieldFilename baseName ifTrue:[ |
|
2352 |
newFile := singleSelectedFileOrDirectory construct:entryFieldFilename baseName. |
|
2353 |
]. |
|
2354 |
] ifTrue:[ |
|
2355 |
newFile := singleSelectedFileOrDirectory. |
|
2356 |
]. |
|
2357 |
] ifFalse:[ |
|
2358 |
newFile := singleSelectedFileOrDirectory. |
|
2359 |
"/ self halt. |
|
19120 | 2360 |
]. |
9765 | 2361 |
]. |
2362 |
]. |
|
19120 | 2363 |
newFile notNil ifTrue:[ |
2364 |
filenameHolder value:newFile withoutNotifying:self. |
|
2365 |
||
2366 |
OperatingSystem supportsVolumes ifTrue:[ |
|
2367 |
| volume | |
|
2368 |
||
2369 |
volume := newFile volume. |
|
2370 |
self selectedDeviceDrive value:volume withoutNotifying:self. |
|
9765 | 2371 |
]. |
2372 |
]. |
|
2373 |
||
2374 |
"Created: / 14-02-2011 / 17:54:08 / cg" |
|
17410 | 2375 |
"Modified (format): / 14-02-2017 / 12:50:11 / cg" |
19174 | 2376 |
"Modified: / 10-09-2019 / 18:56:59 / Stefan Vogel" |
9765 | 2377 |
! |
2378 |
||
6065 | 2379 |
selectedDeviceDriveChanged |
9683
83fb945b7a5a
changed: #selectedDeviceDriveChanged
Claus Gittinger <cg@exept.de>
parents:
9678
diff
changeset
|
2380 |
|newDrive curSel newFile| |
6065 | 2381 |
|
2382 |
newDrive := self selectedDeviceDrive value. |
|
2383 |
curSel := treeBrowser currentFileNameHolder value. |
|
2384 |
curSel notEmpty ifTrue:[ |
|
2385 |
curSel first volume = newDrive ifTrue:[ ^self]. |
|
2386 |
]. |
|
9683
83fb945b7a5a
changed: #selectedDeviceDriveChanged
Claus Gittinger <cg@exept.de>
parents:
9678
diff
changeset
|
2387 |
|
6065 | 2388 |
newDrive notNil ifTrue:[ |
2389 |
newFile := newDrive asFilename. |
|
2390 |
newFile isReadable ifTrue:[ |
|
2391 |
treeBrowser gotoFile:newFile. |
|
2392 |
^self. |
|
2393 |
]. |
|
9683
83fb945b7a5a
changed: #selectedDeviceDriveChanged
Claus Gittinger <cg@exept.de>
parents:
9678
diff
changeset
|
2394 |
self warn:'Cannot open drive %1' with:newFile asFilename volume. |
6065 | 2395 |
]. |
9683
83fb945b7a5a
changed: #selectedDeviceDriveChanged
Claus Gittinger <cg@exept.de>
parents:
9678
diff
changeset
|
2396 |
|
16477 | 2397 |
newDrive := curSel notEmpty |
2398 |
ifTrue:[ curSel first volume ] |
|
2399 |
ifFalse:[ |
|
2400 |
OperatingSystem isMSWINDOWSlike ifTrue:['C:'] ifFalse:['/'] |
|
2401 |
"/ Filename defaultVolumeName. |
|
2402 |
]. |
|
9683
83fb945b7a5a
changed: #selectedDeviceDriveChanged
Claus Gittinger <cg@exept.de>
parents:
9678
diff
changeset
|
2403 |
self selectedDeviceDrive value:newDrive. |
6065 | 2404 |
! |
2405 |
||
3892 | 2406 |
update:something with:aParameter from:changedObject |
9765 | 2407 |
|newLabel fn| |
3892 | 2408 |
|
2409 |
changedObject == treeBrowser currentFileNameHolder ifTrue:[ |
|
9765 | 2410 |
self fileSelectionChanged. |
2411 |
^ self. |
|
3892 | 2412 |
]. |
4804 | 2413 |
|
6065 | 2414 |
changedObject == self selectedDeviceDrive ifTrue:[ |
2415 |
self selectedDeviceDriveChanged. |
|
2416 |
^ self. |
|
2417 |
]. |
|
3904 | 2418 |
changedObject == treeBrowser viewFilesInDirectoryTree ifTrue:[ |
2419 |
changedObject value ifTrue:[ |
|
4804 | 2420 |
newLabel := 'Filename:'. |
3904 | 2421 |
] ifFalse:[ |
4804 | 2422 |
newLabel := 'Directory:'. |
2423 |
]. |
|
2424 |
self filenameLabelHolder value:(resources string:newLabel) |
|
3904 | 2425 |
]. |
9765 | 2426 |
changedObject == self filenameHolder ifTrue:[ |
4804 | 2427 |
fn := changedObject value asFilename. |
2428 |
(fn exists) ifFalse:[^ self]. |
|
17410 | 2429 |
treeBrowser currentFileNameHolder value:(OrderedCollection with:fn) withoutNotifying:self. |
5949 | 2430 |
fn isDirectory ifTrue:[ |
2431 |
treeBrowser expandEnforceSelectedItems. |
|
2432 |
]. |
|
3892 | 2433 |
]. |
2434 |
^ super update:something with:aParameter from:changedObject |
|
9514
c818ca8969f7
comment/format in: #filenameHolder
Claus Gittinger <cg@exept.de>
parents:
9476
diff
changeset
|
2435 |
|
9765 | 2436 |
"Modified: / 14-02-2011 / 17:54:35 / cg" |
17410 | 2437 |
"Modified (format): / 14-02-2017 / 12:50:30 / cg" |
3892 | 2438 |
! ! |
2439 |
||
12816 | 2440 |
!FileDialog methodsFor:'construction-adding'! |
2441 |
||
2442 |
addComponent: aView |
|
12875 | 2443 |
verticalPanelView addComponent: aView |
12816 | 2444 |
|
2445 |
"Created: / 03-06-2013 / 17:47:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2446 |
! ! |
|
2447 |
||
3892 | 2448 |
!FileDialog methodsFor:'event handling'! |
2449 |
||
18749 | 2450 |
processEvent:anEvent |
2451 |
"filter keyboard edit-events typed into the listOfItemsView. |
|
2452 |
Return true, if I have eaten the event" |
|
2453 |
||
2454 |
<resource: #keyboard (#FindNext)> |
|
2455 |
||
2456 |
anEvent isKeyPressEvent ifFalse:[^ false]. |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
2457 |
|
18749 | 2458 |
anEvent key == #FindNext ifTrue:[ |
2459 |
self doFindAndSelectNextFile. |
|
2460 |
^ true |
|
2461 |
]. |
|
2462 |
^ false |
|
2463 |
||
2464 |
"Created: / 02-05-2019 / 21:17:15 / Claus Gittinger" |
|
3892 | 2465 |
! ! |
2466 |
||
2467 |
!FileDialog methodsFor:'initialization & release'! |
|
2468 |
||
5932 | 2469 |
closeDownViews |
9765 | 2470 |
self rememberExtent. |
5932 | 2471 |
super closeDownViews. |
9765 | 2472 |
|
2473 |
"Modified: / 14-02-2011 / 17:55:14 / cg" |
|
5932 | 2474 |
! |
2475 |
||
2476 |
closeWindow |
|
9765 | 2477 |
self rememberExtent. |
5932 | 2478 |
super closeWindow. |
9765 | 2479 |
|
2480 |
"Modified: / 14-02-2011 / 17:55:55 / cg" |
|
5932 | 2481 |
! |
2482 |
||
5903
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2483 |
commonPostOpen |
8182 | 2484 |
|selection| |
3892 | 2485 |
|
17316 | 2486 |
super commonPostOpen. |
2487 |
||
3892 | 2488 |
"/ 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
|
2489 |
|
19062 | 2490 |
treeBrowser rootHolder value:(self initialRootDirectory). |
2491 |
||
3892 | 2492 |
treeBrowser currentFileNameHolder addDependent:self. |
5598 | 2493 |
treeBrowser doubleClickAction:self doubleClickAction. |
3904 | 2494 |
treeBrowser viewFilesInDirectoryTree addDependent:self. |
5863
e31e066a41d9
root is one up (showing containing directory)
Claus Gittinger <cg@exept.de>
parents:
5858
diff
changeset
|
2495 |
|
4804 | 2496 |
treeBrowser viewFilesInDirectoryTree setValue:(self viewFiles ? true). |
4796 | 2497 |
treeBrowser viewFilesInDirectoryTree changed. |
4804 | 2498 |
|
2499 |
self isLoadDialog ifTrue:[ |
|
4796 | 2500 |
treeBrowser newVisibilityHolder value:false. |
2501 |
treeBrowser allowFileOperations value:false. |
|
2502 |
self newDirectoryVisibilityHolder value:false. |
|
2503 |
]. |
|
5927 | 2504 |
treeBrowser expandEnforceSelectedItems. |
5929 | 2505 |
|
2506 |
selection := treeBrowser treeSelectionHolder value. |
|
2507 |
selection notEmptyOrNil ifTrue:[ |
|
5930 | 2508 |
selection := selection asCollection first. |
5929 | 2509 |
selection enforcedExpand. |
2510 |
treeBrowser browser makeItemVisible:selection withMinimumLines:5. |
|
2511 |
]. |
|
18749 | 2512 |
self windowGroup addPreEventHook:self. |
2513 |
||
2514 |
"Modified: / 02-05-2019 / 21:15:18 / Claus Gittinger" |
|
4796 | 2515 |
! |
2516 |
||
6409 | 2517 |
initialRootDirectory |
2518 |
"returns the directory the browser is open on |
|
2519 |
" |
|
2520 |
|root| |
|
2521 |
||
9678 | 2522 |
initialRoot isNil ifTrue:[ |
6409 | 2523 |
|
9678 | 2524 |
(root := self directory) notNil ifTrue:[ |
2525 |
root := root asFilename. |
|
6409 | 2526 |
|
2527 |
root isDirectory ifFalse:[ |
|
9678 | 2528 |
root := root directory. |
2529 |
root isDirectory ifFalse:[ |
|
2530 |
root := nil. |
|
2531 |
] |
|
6409 | 2532 |
] |
9678 | 2533 |
]. |
2534 |
root isNil ifTrue:[ |
|
2535 |
root := Filename currentDirectory. |
|
2536 |
]. |
|
2537 |
initialRoot := root asAbsoluteFilename. |
|
6409 | 2538 |
]. |
9678 | 2539 |
^ initialRoot |
2540 |
||
2541 |
"Modified: / 27-12-2010 / 09:56:30 / cg" |
|
6409 | 2542 |
! |
2543 |
||
15767 | 2544 |
initialize |
15768 | 2545 |
super initialize. |
15767 | 2546 |
isLoadDialog := false. |
19174 | 2547 |
viewFiles := true. |
2548 |
multipleSelect := false. |
|
2549 |
||
2550 |
"Modified: / 10-09-2019 / 18:40:07 / Stefan Vogel" |
|
15767 | 2551 |
! |
2552 |
||
5903
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2553 |
postBuildFileNameField:aWidget |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2554 |
|
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2555 |
filenameField := aWidget. |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2556 |
! |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2557 |
|
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2558 |
postBuildFilterField:aWidget |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2559 |
|
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2560 |
filterField := aWidget. |
4796 | 2561 |
! |
2562 |
||
5903
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2563 |
postBuildTreeBrowser:aSubCanvasView |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2564 |
treeBrowser := aSubCanvasView client. |
6409 | 2565 |
treeBrowser rootHolder value:(self initialRootDirectory value). |
9113 | 2566 |
treeBrowser sortPropertyInTree:(treeBrowser sortBlockProperty). |
9553 | 2567 |
treeBrowser showHiddenFiles value:true. |
2568 |
||
2569 |
"Modified: / 24-08-2010 / 16:07:16 / sr" |
|
5903
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2570 |
! |
4796 | 2571 |
|
12875 | 2572 |
postBuildVerticalPanelView:aView |
2573 |
verticalPanelView := aView. |
|
12816 | 2574 |
|
2575 |
"Created: / 03-06-2013 / 17:41:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2576 |
! |
|
2577 |
||
13004 | 2578 |
postBuildWith:aBuilder |
2579 |
|win hMin| |
|
2580 |
||
5903
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2581 |
treeBrowser multipleSelect:multipleSelect. |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2582 |
appendWasPressed := false. |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2583 |
|
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2584 |
(aBuilder componentAt:'cancelButton') cursor:(Cursor thumbsDown). |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2585 |
(aBuilder componentAt:'appendButton') cursor:(Cursor thumbsUp). |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2586 |
(aBuilder componentAt:'okButton') cursor:(Cursor thumbsUp). |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2587 |
|
13004 | 2588 |
win := aBuilder window . |
13187 | 2589 |
win minExtent notNil ifTrue:[ |
2590 |
"minExtent is nil if window is not a TopView" |
|
2591 |
hMin := (win margin * 2) |
|
2592 |
+ (aBuilder menuBar isNil ifTrue:[0] ifFalse:[aBuilder menuBar preferredHeight]) |
|
2593 |
+ (aBuilder componentAt:#FilenameEntryField) height |
|
2594 |
+ (aBuilder componentAt:#ToolBar1) preferredHeight |
|
2595 |
+ (aBuilder componentAt:#ButtonPanel) preferredHeight. |
|
13004 | 2596 |
|
13187 | 2597 |
win minExtent:(win minExtent x @ hMin). |
2598 |
]. |
|
13090 | 2599 |
win topView label:self initialText. |
13004 | 2600 |
|
6632 | 2601 |
super postBuildWith:aBuilder |
5932 | 2602 |
! |
2603 |
||
8182 | 2604 |
postOpenAsSubcanvasWith:aBuilder |
2605 |
super postOpenAsSubcanvasWith:aBuilder. |
|
2606 |
||
2607 |
"No ok and cancel buttons, when dialog is part of a larger dialog" |
|
8191
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2608 |
self hideButtonPanel. |
8183 | 2609 |
|
9809
fa5280b1259f
changed: #postOpenAsSubcanvasWith:
Stefan Vogel <sv@exept.de>
parents:
9769
diff
changeset
|
2610 |
"filenameHolder contains the initial file name, or nil" |
8191
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2611 |
self startFilename:self filenameHolder value. |
9809
fa5280b1259f
changed: #postOpenAsSubcanvasWith:
Stefan Vogel <sv@exept.de>
parents:
9769
diff
changeset
|
2612 |
treeBrowser currentFileNameHolder value:(Array with:self startFilename). |
8182 | 2613 |
! |
2614 |
||
12816 | 2615 |
preOpenWith:aBuilder |
12883 | 2616 |
"called right before being opened" |
2617 |
||
18015 | 2618 |
verticalPanelView notNil ifTrue:[ |
2619 |
"/ SV: disabled, because dialogs where opened full height: |
|
2620 |
"/ "Increase height of the window so height of the file part |
|
2621 |
"/ remains the same. This cares for any components added by a hook" |
|
2622 |
"/ |
|
2623 |
"/ |delta| |
|
2624 |
"/ |
|
2625 |
"/ delta := verticalPanelView preferredHeight - verticalPanelView height. |
|
2626 |
"/ delta > 0 ifTrue:[ |
|
2627 |
"/ "/ components where added (possibly in the aboutToOpenBoxNotifiction |
|
2628 |
"/ aBuilder window height: (aBuilder window height + delta). |
|
2629 |
"/ ]. |
|
12875 | 2630 |
|
18015 | 2631 |
"/ This code was disabled without comment: |
12883 | 2632 |
"/ sumH := 0. |
2633 |
"/ verticalPanelView subViews from:2 do:[:view| |
|
2634 |
"/ sumH := sumH + view preferredHeight. |
|
2635 |
"/ ]. |
|
2636 |
"/ sumH ~~ 0 ifTrue:[ |
|
18015 | 2637 |
"/ newVPanelHeight := verticalPanelView preferredHeight. |
12883 | 2638 |
"/ aBuilder window height: aBuilder window height + sumH. |
2639 |
"/ ]. |
|
8182 | 2640 |
]. |
12816 | 2641 |
|
14151 | 2642 |
treeBrowser currentFileNameHolder value:(Array with:self startFilename). |
2643 |
||
12816 | 2644 |
"Created: / 03-06-2013 / 18:19:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
18015 | 2645 |
"Modified (format): / 20-03-2018 / 11:34:26 / stefan" |
8182 | 2646 |
! |
2647 |
||
9765 | 2648 |
rememberExtent |
18015 | 2649 |
"if the user changed the size of the dialog, the next time the dialog |
2650 |
is opened with this size. |
|
2651 |
But ignore height changes < 40 pixels. On some systems the height of the title bar |
|
2652 |
is added to the height. (https://expeccoalm.exept.de/D160693)" |
|
2653 |
||
2654 |
|currentExtent| |
|
2655 |
||
2656 |
currentExtent := self window topView extent. |
|
2657 |
(LastExtent isNil or:[(LastExtent y - currentExtent y) abs > 40]) ifTrue:[ |
|
2658 |
self class lastExtent:currentExtent. |
|
2659 |
]. |
|
9765 | 2660 |
|
2661 |
"Created: / 14-02-2011 / 17:55:11 / cg" |
|
18015 | 2662 |
"Modified: / 20-03-2018 / 11:44:06 / stefan" |
4796 | 2663 |
! ! |
2664 |
||
9113 | 2665 |
!FileDialog methodsFor:'menus'! |
2666 |
||
19478 | 2667 |
additionalFoldersMenuSlice |
2668 |
|slice| |
|
2669 |
||
2670 |
"/ AdditionalFolderItemsInMenu := #('/foo' '/etc' '/Users') |
|
2671 |
"/ AdditionalFolderItemsInMenu := #('/foo' ('/etc' 'Other') '/Users') |
|
2672 |
||
2673 |
{ additionalFolderItemsInMenu . AdditionalFolderItemsInMenu } do:[:moreOrEmpty | |
|
2674 |
moreOrEmpty notEmptyOrNil ifTrue:[ |
|
2675 |
slice isNil ifTrue:[ |
|
2676 |
slice := Menu new. |
|
2677 |
slice addSeparator. |
|
2678 |
]. |
|
2679 |
moreOrEmpty do:[:eachFolderNameOrPair | |
|
2680 |
|item fn label| |
|
2681 |
||
2682 |
eachFolderNameOrPair isArray ifTrue:[ |
|
2683 |
fn := eachFolderNameOrPair first. |
|
2684 |
label := eachFolderNameOrPair second. |
|
2685 |
] ifFalse:[ |
|
2686 |
eachFolderNameOrPair isAssociation ifTrue:[ |
|
2687 |
fn := eachFolderNameOrPair key. |
|
2688 |
label := eachFolderNameOrPair value. |
|
2689 |
] ifFalse:[ |
|
2690 |
fn := eachFolderNameOrPair. |
|
2691 |
label := eachFolderNameOrPair. |
|
2692 |
]. |
|
2693 |
]. |
|
2694 |
fn := fn asFilename. |
|
2695 |
||
2696 |
item := MenuItem new. |
|
2697 |
item label:label asString. |
|
2698 |
item itemValue:[ self gotoFile:fn ]. |
|
2699 |
item enabled:[ fn exists and:[fn isDirectory and:[fn isExecutable]]]. |
|
2700 |
slice addItem:item. |
|
2701 |
]. |
|
2702 |
]. |
|
2703 |
]. |
|
2704 |
^ slice |
|
2705 |
! |
|
2706 |
||
2707 |
additionalFoldersMenuSliceHolder |
|
2708 |
^ [ self additionalFoldersMenuSlice ] |
|
2709 |
||
2710 |
! |
|
2711 |
||
9113 | 2712 |
bookmarksMenu |
2713 |
^ treeBrowser bookmarksMenu |
|
2714 |
! |
|
2715 |
||
2716 |
directoryMenu |
|
2717 |
^ treeBrowser directoryMenu |
|
2718 |
! |
|
2719 |
||
2720 |
showMenuSpecForDialog |
|
2721 |
^ treeBrowser class showMenuSpecForDialog |
|
2722 |
! |
|
2723 |
||
2724 |
sortMenu |
|
2725 |
^ treeBrowser class sortInTreeMenu |
|
2726 |
! |
|
2727 |
||
2728 |
visitedDirectoriesMenu |
|
2729 |
^ treeBrowser visitedDirectoriesMenu |
|
2730 |
! ! |
|
2731 |
||
4796 | 2732 |
!FileDialog methodsFor:'private'! |
2733 |
||
2734 |
returnWasPressedInFilterField |
|
8663 | 2735 |
|wg ev| |
4796 | 2736 |
|
8663 | 2737 |
((wg := self windowGroup) notNil |
2738 |
and:[ (ev := wg lastEvent) notNil |
|
2739 |
and:[ ev isKeyEvent |
|
2740 |
and:[ ev key == #Return |
|
2741 |
and:[ (ev targetView isSameOrComponentOf:filterField) |
|
2742 |
or:[false "ev targetView isSameOrComponentOf:filenameField"]]]]]) ifTrue:[ |
|
4796 | 2743 |
^ true |
2744 |
]. |
|
2745 |
^ false |
|
2746 |
! |
|
2747 |
||
2748 |
returnWasPressedInFilterOrFilenameField |
|
17990 | 2749 |
|wg ev| |
4796 | 2750 |
|
17990 | 2751 |
((wg := self windowGroup) notNil |
2752 |
and:[(ev := wg lastEvent) notNil |
|
2753 |
and:[ev notNil |
|
4796 | 2754 |
and:[ev isKeyEvent |
2755 |
and:[ev key == #Return |
|
2756 |
and:[( ev targetView isSameOrComponentOf:filterField) |
|
17990 | 2757 |
or:[false "ev targetView isSameOrComponentOf:filenameField"]]]]]]) ifTrue:[ |
4796 | 2758 |
^ true |
2759 |
]. |
|
2760 |
^ false |
|
2761 |
! ! |
|
2762 |
||
6065 | 2763 |
!FileDialog methodsFor:'queries'! |
2764 |
||
2765 |
driveSelectorVisible |
|
2766 |
^ OperatingSystem isMSDOSlike |
|
2767 |
! ! |
|
2768 |
||
4796 | 2769 |
!FileDialog methodsFor:'user actions'! |
2770 |
||
2771 |
appendPressed |
|
2772 |
appendWasPressed := true. |
|
2773 |
self commonAcceptAction. |
|
2774 |
! |
|
2775 |
||
2776 |
commonAcceptAction |
|
2777 |
filenameField accept. |
|
2778 |
self result:(self filenameHolder value asString). |
|
2779 |
||
2780 |
^ super doAccept |
|
2781 |
! |
|
2782 |
||
2783 |
doAccept |
|
2784 |
"force accept - ignore in filterField" |
|
2785 |
||
2786 |
self returnWasPressedInFilterField ifTrue:[ |
|
2787 |
^ self |
|
2788 |
]. |
|
4996
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4824
diff
changeset
|
2789 |
treeBrowser hasOpenEditor ifTrue:[ |
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4824
diff
changeset
|
2790 |
"/ 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
|
2791 |
treeBrowser browser closeEditor. |
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4824
diff
changeset
|
2792 |
^ self |
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4824
diff
changeset
|
2793 |
]. |
4796 | 2794 |
appendWasPressed := false. |
2795 |
self commonAcceptAction. |
|
2796 |
! |
|
2797 |
||
2798 |
doBack |
|
2799 |
||
2800 |
treeBrowser doBack. |
|
2801 |
! |
|
2802 |
||
5966 | 2803 |
doBrowseDirectory |
17651 | 2804 |
FileBrowser default openOn:(treeBrowser currentDirectory ? treeBrowser rootHolder value). |
5966 | 2805 |
|
17651 | 2806 |
"Modified: / 01-09-2017 / 14:05:09 / cg" |
5966 | 2807 |
! |
2808 |
||
4796 | 2809 |
doCancel |
2810 |
||
2811 |
self result:nil. |
|
2812 |
^ super doCancel. |
|
2813 |
! |
|
2814 |
||
18268 | 2815 |
doFindAndSelectFile |
19012 | 2816 |
"search for a file matching a requested pattern" |
2817 |
||
2818 |
|fileNameInEditField initialSearchPattern patternAndTopDirectoryForSearch |
|
2819 |
searchPattern topDirectoryForSearch searchRoot list| |
|
18749 | 2820 |
|
19012 | 2821 |
(fileNameInEditField := filenameField contents) notEmptyOrNil ifTrue:[ |
2822 |
initialSearchPattern := fileNameInEditField asFilename baseName. |
|
2823 |
] ifFalse:[ |
|
2824 |
initialSearchPattern := LastFindPattern ? '*.txt' |
|
2825 |
]. |
|
18268 | 2826 |
|
19012 | 2827 |
patternAndTopDirectoryForSearch := Dialog |
18268 | 2828 |
request:'Filename Pattern (match):' |
19012 | 2829 |
initialAnswer:initialSearchPattern |
2830 |
and:'Search under:' |
|
2831 |
initialAnswer:(directory ? Filename currentDirectory) name |
|
19265 | 2832 |
label:'Search for File (not Folder)'. |
19012 | 2833 |
patternAndTopDirectoryForSearch isEmptyOrNil ifTrue:[^ self]. |
2834 |
||
2835 |
searchPattern := patternAndTopDirectoryForSearch first. |
|
2836 |
topDirectoryForSearch := patternAndTopDirectoryForSearch second. |
|
2837 |
||
2838 |
LastFindPattern := searchPattern. |
|
2839 |
||
2840 |
list := HierarchicalFileList new. |
|
2841 |
searchRoot := HierarchicalFileList::HierarchicalFileItem fileName:topDirectoryForSearch. |
|
2842 |
list root:searchRoot. |
|
18749 | 2843 |
|
18748 | 2844 |
self withWaitCursorDo:[ |
19012 | 2845 |
[ |
2846 |
|dirHolder| |
|
2847 |
||
2848 |
dirHolder := self searchedDirectoryInfoHolder. |
|
2849 |
self searchInfoBoxVisibleHolder value:true. |
|
2850 |
self windowGroup processExposeEvents. |
|
2851 |
||
2852 |
treeBrowser |
|
2853 |
findAndSelectNextFileMatching:searchPattern |
|
2854 |
under:searchRoot |
|
2855 |
searchInfoInto:[:path | dirHolder value:path. self windowGroup processExposeEvents]. |
|
2856 |
] ensure:[ |
|
2857 |
self searchInfoBoxVisibleHolder value:false |
|
2858 |
] |
|
18748 | 2859 |
]. |
18268 | 2860 |
|
2861 |
"Created: / 17-07-2018 / 12:44:20 / Claus Gittinger" |
|
18749 | 2862 |
"Modified (format): / 02-05-2019 / 20:44:14 / Claus Gittinger" |
2863 |
! |
|
2864 |
||
2865 |
doFindAndSelectNextFile |
|
2866 |
"search the next file matching the previous pattern" |
|
2867 |
||
19264 | 2868 |
LastFindPattern isEmptyOrNil ifTrue:[ |
2869 |
self doFindAndSelectFile. |
|
2870 |
^ self. |
|
2871 |
]. |
|
18749 | 2872 |
self withWaitCursorDo:[ |
2873 |
treeBrowser findAndSelectNextFileMatching:LastFindPattern. |
|
2874 |
]. |
|
2875 |
||
2876 |
"Created: / 02-05-2019 / 21:18:13 / Claus Gittinger" |
|
18268 | 2877 |
! |
2878 |
||
4796 | 2879 |
doForward |
2880 |
||
2881 |
treeBrowser doForward. |
|
2882 |
! |
|
2883 |
||
2884 |
doGoDirectoryUp |
|
2885 |
||
2886 |
treeBrowser doGoDirectoryUp. |
|
2887 |
! |
|
2888 |
||
8092 | 2889 |
doGotoDesktopDirectory |
2890 |
||
2891 |
treeBrowser doGotoDesktopDirectory. |
|
2892 |
! |
|
2893 |
||
18037 | 2894 |
doGotoDocumentsDirectory |
2895 |
||
2896 |
treeBrowser doGotoDocumentsDirectory. |
|
2897 |
! |
|
2898 |
||
2899 |
doGotoDownloadsDirectory |
|
2900 |
||
2901 |
treeBrowser doGotoDownloadsDirectory. |
|
2902 |
! |
|
2903 |
||
4796 | 2904 |
doGotoHomeDirectory |
2905 |
||
2906 |
treeBrowser doGotoHomeDirectory. |
|
2907 |
! |
|
2908 |
||
19265 | 2909 |
findAndSelectNextFileEnabledHolder |
2910 |
^ [LastFindPattern notEmptyOrNil]. |
|
2911 |
! |
|
2912 |
||
19267 | 2913 |
gotoFile:fn |
2914 |
treeBrowser gotoFile:fn. |
|
2915 |
! |
|
2916 |
||
4796 | 2917 |
menuDirHistory:backOrForward |
2918 |
||
2919 |
^ treeBrowser menuDirHistory:backOrForward. |
|
2920 |
! |
|
2921 |
||
2922 |
menuDirHistoryBack |
|
2923 |
||
2924 |
^ treeBrowser menuDirHistory:#back. |
|
2925 |
! |
|
2926 |
||
2927 |
menuDirHistoryForward |
|
2928 |
||
2929 |
^ treeBrowser menuDirHistory:#forward. |
|
2930 |
! |
|
2931 |
||
2932 |
newDirectory |
|
17380 | 2933 |
"forward to the treebrowser component, which already has this functionality" |
2934 |
||
2935 |
^ treeBrowser newDirectory |
|
4796 | 2936 |
|
17380 | 2937 |
"Modified (comment): / 04-02-2017 / 14:41:43 / cg" |
4796 | 2938 |
! |
2939 |
||
2940 |
okPressed |
|
2941 |
self doAccept |
|
9113 | 2942 |
! |
2943 |
||
19012 | 2944 |
openTerminal |
2945 |
"forward to the treebrowser component, which already has this functionality" |
|
2946 |
||
2947 |
^ treeBrowser openTerminal |
|
2948 |
! |
|
2949 |
||
9113 | 2950 |
updateCurrentDirectory |
2951 |
treeBrowser updateCurrentDirectory |
|
4796 | 2952 |
! ! |
2953 |
||
2954 |
!FileDialog class methodsFor:'documentation'! |
|
2955 |
||
2956 |
version |
|
15725 | 2957 |
^ '$Header$' |
12883 | 2958 |
! |
2959 |
||
2960 |
version_CVS |
|
15725 | 2961 |
^ '$Header$' |
19195 | 2962 |
! |
2963 |
||
2964 |
version_HG |
|
2965 |
||
2966 |
^ '$Changeset: <not expanded> $' |
|
2967 |
! |
|
2968 |
||
2969 |
version_SVN |
|
2970 |
^ '$Id$' |
|
4796 | 2971 |
! ! |
12816 | 2972 |