author | Claus Gittinger <cg@exept.de> |
Tue, 21 Apr 2020 13:26:33 +0200 | |
changeset 19578 | 088c98423554 |
parent 19511 | 54b119c1dda6 |
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 |
|
19012 | 1146 |
label: 'View' |
1147 |
submenu: |
|
1148 |
(Menu |
|
1149 |
(MenuItem |
|
1150 |
label: 'Sort' |
|
1151 |
submenuChannel: sortMenu |
|
1152 |
) |
|
1153 |
(MenuItem |
|
1154 |
label: 'Show' |
|
1155 |
submenuChannel: showMenuSpecForDialog |
|
1156 |
) |
|
1157 |
(MenuItem |
|
1158 |
label: '-' |
|
1159 |
) |
|
1160 |
(MenuItem |
|
1161 |
label: 'Update' |
|
1162 |
itemValue: updateCurrentDirectory |
|
1163 |
) |
|
1164 |
) |
|
1165 |
) |
|
1166 |
(MenuItem |
|
1167 |
label: 'Tools' |
|
1168 |
submenu: |
|
1169 |
(Menu |
|
1170 |
(MenuItem |
|
1171 |
label: 'Terminal' |
|
1172 |
itemValue: openTerminal |
|
1173 |
labelImage: (ResourceRetriever ToolbarIconLibrary terminal16x16Icon 'Terminal') |
|
1174 |
) |
|
1175 |
) |
|
1176 |
) |
|
1177 |
(MenuItem |
|
1178 |
label: 'Find' |
|
1179 |
submenu: |
|
1180 |
(Menu |
|
1181 |
(MenuItem |
|
1182 |
label: 'File...' |
|
1183 |
itemValue: doFindAndSelectFile |
|
1184 |
labelImage: (ResourceRetriever ToolbarIconLibrary search16x16Icon 'File...') |
|
1185 |
) |
|
1186 |
(MenuItem |
|
19265 | 1187 |
enabled: findAndSelectNextFileEnabledHolder |
19012 | 1188 |
label: 'Next...' |
1189 |
itemValue: doFindAndSelectNextFile |
|
1190 |
shortcutKey: FindNext |
|
1191 |
) |
|
1192 |
) |
|
1193 |
) |
|
1194 |
) |
|
9113 | 1195 |
! |
1196 |
||
3892 | 1197 |
toolBarMenu |
1198 |
"This resource specification was automatically generated |
|
1199 |
by the MenuEditor of ST/X." |
|
1200 |
||
1201 |
"Do not manually edit this!! If it is corrupted, |
|
1202 |
the MenuEditor may not be able to read the specification." |
|
1203 |
||
1204 |
" |
|
1205 |
MenuEditor new openOnClass:FileDialog andSelector:#toolBarMenu |
|
1206 |
(Menu new fromLiteralArrayEncoding:(FileDialog toolBarMenu)) startUp |
|
1207 |
" |
|
1208 |
||
1209 |
<resource: #menu> |
|
1210 |
||
1211 |
^ |
|
5873 | 1212 |
#(Menu |
1213 |
( |
|
1214 |
(MenuItem |
|
1215 |
activeHelpKey: directoryBack |
|
1216 |
enabled: enableBack |
|
1217 |
label: 'Back' |
|
1218 |
itemValue: doBack |
|
1219 |
translateLabel: true |
|
1220 |
isButton: true |
|
1221 |
submenuChannel: menuDirHistoryBack |
|
6087 | 1222 |
labelImage: (ResourceRetriever AbstractFileBrowser historyBackIcon) |
5873 | 1223 |
keepLinkedMenu: true |
3892 | 1224 |
) |
5873 | 1225 |
(MenuItem |
1226 |
label: '' |
|
3892 | 1227 |
) |
5873 | 1228 |
(MenuItem |
1229 |
activeHelpKey: directoryForward |
|
1230 |
enabled: enableForward |
|
1231 |
label: 'Forward' |
|
1232 |
itemValue: doForward |
|
1233 |
translateLabel: true |
|
1234 |
isButton: true |
|
1235 |
submenuChannel: menuDirHistoryForward |
|
6087 | 1236 |
labelImage: (ResourceRetriever AbstractFileBrowser historyForwardIcon) |
5873 | 1237 |
keepLinkedMenu: true |
3892 | 1238 |
) |
5873 | 1239 |
(MenuItem |
6462 | 1240 |
label: '-' |
1241 |
) |
|
1242 |
(MenuItem |
|
1243 |
activeHelpKey: directoryUp |
|
1244 |
enabled: enableDirectoryUp |
|
1245 |
label: 'DirectoryUp' |
|
1246 |
itemValue: doGoDirectoryUp |
|
1247 |
translateLabel: true |
|
1248 |
isButton: true |
|
1249 |
labelImage: (ResourceRetriever AbstractFileBrowser directoryUpIcon) |
|
3892 | 1250 |
) |
5873 | 1251 |
(MenuItem |
1252 |
activeHelpKey: fileHome |
|
1253 |
enabled: enableHome |
|
1254 |
label: 'Home' |
|
1255 |
itemValue: doGotoHomeDirectory |
|
1256 |
translateLabel: true |
|
1257 |
isButton: true |
|
6096 | 1258 |
labelImage: (ResourceRetriever ToolbarIconLibrary homeIcon) |
3892 | 1259 |
) |
5873 | 1260 |
(MenuItem |
8092 | 1261 |
activeHelpKey: fileDesktop |
18512 | 1262 |
enabled: enableGotoDesktopDirectory |
8092 | 1263 |
label: 'Desktop' |
1264 |
itemValue: doGotoDesktopDirectory |
|
1265 |
translateLabel: true |
|
1266 |
isButton: true |
|
1267 |
labelImage: (ResourceRetriever ToolbarIconLibrary desktopIcon) |
|
1268 |
) |
|
1269 |
(MenuItem |
|
6098 | 1270 |
activeHelpKey: fileGotoBookmark |
1271 |
label: 'Bookmarks' |
|
1272 |
translateLabel: true |
|
1273 |
isButton: true |
|
9113 | 1274 |
submenuChannel: gotoBookmarksMenu |
6098 | 1275 |
labelImage: (ResourceRetriever ToolbarIconLibrary directoryBookmarksIcon) |
1276 |
) |
|
1277 |
(MenuItem |
|
5873 | 1278 |
label: '-' |
1279 |
isVisible: newDirectoryVisibilityHolder |
|
3923 | 1280 |
) |
5873 | 1281 |
(MenuItem |
6122 | 1282 |
label: 'New Directory...' |
5873 | 1283 |
itemValue: newDirectory |
1284 |
translateLabel: true |
|
1285 |
isButton: true |
|
1286 |
isVisible: newDirectoryVisibilityHolder |
|
6088 | 1287 |
labelImage: (ResourceRetriever AbstractFileBrowser newDirectoryIcon) |
3923 | 1288 |
) |
8585 | 1289 |
(MenuItem |
1290 |
label: '-' |
|
19174 | 1291 |
isVisible: browseMenuItemVisibleHolder |
8585 | 1292 |
) |
1293 |
(MenuItem |
|
1294 |
activeHelpKey: openFileBrowser |
|
1295 |
label: 'Browse' |
|
1296 |
itemValue: doBrowseDirectory |
|
1297 |
translateLabel: true |
|
1298 |
isButton: true |
|
15725 | 1299 |
isVisible: browseMenuItemVisibleHolder |
8585 | 1300 |
labelImage: (ResourceRetriever ToolbarIconLibrary startFileBrowserIcon) |
1301 |
) |
|
3892 | 1302 |
) |
1303 |
nil |
|
1304 |
nil |
|
1305 |
) |
|
19174 | 1306 |
|
1307 |
"Modified: / 10-09-2019 / 18:41:59 / Stefan Vogel" |
|
9113 | 1308 |
! |
1309 |
||
1310 |
viewInContentsBrowserMenu |
|
1311 |
^ DirectoryContentsBrowser showMenuSpec |
|
3892 | 1312 |
! ! |
1313 |
||
8182 | 1314 |
!FileDialog class methodsFor:'plugIn spec'! |
1315 |
||
1316 |
aspectSelectors |
|
1317 |
"This resource specification was automatically generated |
|
1318 |
by the UIPainter of ST/X." |
|
1319 |
||
1320 |
"Do not manually edit this. If it is corrupted, |
|
1321 |
the UIPainter may not be able to read the specification." |
|
1322 |
||
1323 |
"Return a description of exported aspects; |
|
1324 |
these can be connected to aspects of an embedding application |
|
1325 |
(if this app is embedded in a subCanvas)." |
|
1326 |
||
1327 |
^ #( |
|
1328 |
#filenameHolder |
|
1329 |
#filterHolder |
|
8191
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
1330 |
#rootDirectoryHolder |
8182 | 1331 |
). |
1332 |
||
1333 |
! ! |
|
1334 |
||
19478 | 1335 |
!FileDialog methodsFor:'API'! |
1336 |
||
1337 |
requestDirectoryName:titleString default:aFileName |
|
1338 |
ok:okText abort:abortText |
|
1339 |
version:versionSymbol |
|
1340 |
pattern:patternArg |
|
1341 |
fromDirectory:aDirectoryPath |
|
1342 |
ifFail:failBlock |
|
1343 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
1344 |
asLoadDialog:aBoolean |
|
1345 |
||
1346 |
"same as requestFileName, but only show directories" |
|
1347 |
||
1348 |
|enteredFileName enteredFileNameString| |
|
1349 |
||
1350 |
self |
|
1351 |
startApplicationFor:titleString |
|
1352 |
default:aFileName |
|
1353 |
ok:okText |
|
1354 |
abort:abortText |
|
1355 |
ifFail:failBlock |
|
1356 |
pattern:patternArg |
|
1357 |
fromDirectory:aDirectoryPath |
|
1358 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
1359 |
asLoadDialog:aBoolean |
|
1360 |
viewFiles:false |
|
1361 |
multipleSelect:false. |
|
1362 |
||
1363 |
enteredFileNameString := self result. |
|
1364 |
enteredFileNameString isNil ifTrue:[ |
|
1365 |
^ failBlock value |
|
1366 |
]. |
|
1367 |
enteredFileName := enteredFileNameString asFilename. |
|
1368 |
enteredFileName isRelative ifTrue:[ |
|
1369 |
enteredFileName := self directory construct:enteredFileNameString |
|
1370 |
]. |
|
1371 |
||
1372 |
enteredFileNameString := enteredFileName asString. |
|
1373 |
(enteredFileName notNil |
|
1374 |
and:[enteredFileNameString notEmpty]) ifTrue:[ |
|
1375 |
versionSymbol isNil ifTrue:[ ^ enteredFileNameString]. |
|
1376 |
versionSymbol == #mustBeNew ifTrue:[ |
|
1377 |
"/ file may not exist |
|
1378 |
enteredFileName exists ifTrue:[^ '']. |
|
1379 |
]. |
|
1380 |
versionSymbol == #new ifTrue:[ |
|
1381 |
"/ file may not exist |
|
1382 |
enteredFileName exists ifTrue:[ |
|
1383 |
(Dialog confirm:(resources stringWithCRs:'''%1'' exists.\\Continue anyway ?' with:enteredFileNameString)) |
|
1384 |
ifFalse:[^ '']. |
|
1385 |
]. |
|
1386 |
]. |
|
1387 |
versionSymbol == #mustBeOld ifTrue:[ |
|
1388 |
enteredFileName exists ifFalse:[^ '']. |
|
1389 |
]. |
|
1390 |
versionSymbol == #old ifTrue:[ |
|
1391 |
"/ file may not exist |
|
1392 |
enteredFileName exists ifFalse:[ |
|
1393 |
(self confirm:(resources stringWithCRs:'''%1'' does not exist yet.\\Continue anyway ?' with:enteredFileNameString)) |
|
1394 |
ifFalse:[^ '']. |
|
1395 |
]. |
|
1396 |
]. |
|
1397 |
FileSelectionBox lastFileSelectionDirectory:(enteredFileNameString). |
|
1398 |
]. |
|
1399 |
^ enteredFileNameString |
|
1400 |
||
1401 |
" |
|
1402 |
FileDialog |
|
1403 |
requestDirectoryName:'which directory ?' |
|
1404 |
default:Filename currentDirectory pathName |
|
1405 |
ifFail:nil |
|
1406 |
" |
|
1407 |
" |
|
1408 |
FileDialog |
|
1409 |
requestDirectoryName:'which directory ?' |
|
1410 |
default:Filename currentDirectory pathName |
|
1411 |
ok:nil |
|
1412 |
abort:nil |
|
1413 |
version:nil |
|
1414 |
pattern:nil |
|
1415 |
fromDirectory:nil |
|
1416 |
ifFail:nil |
|
1417 |
whenBoxCreatedEvaluate:nil |
|
1418 |
asLoadDialog:true |
|
1419 |
" |
|
1420 |
! |
|
1421 |
||
1422 |
requestFileName:titleString default:defaultName ok:okText abort:abortText |
|
1423 |
version:versionSymbol |
|
1424 |
ifFail:failBlock |
|
1425 |
pattern:patternArg |
|
1426 |
fromDirectory:aDirectoryPath |
|
1427 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
1428 |
asLoadDialog:aBoolean |
|
1429 |
||
1430 |
"launch a Dialog, which allows user to enter a filename. |
|
1431 |
The files presented initially are those in aDirectoryPathOrNil, or the |
|
1432 |
last fileBox directory (default: current directory) (if a nil path is given). |
|
1433 |
The box will show okText in its okButton, abortText in the abortButton. |
|
1434 |
The matchPattern is set to pattern initially. |
|
1435 |
Return the string, or nil if cancel was pressed |
|
1436 |
The version argument allows validation of the files existance; |
|
1437 |
it may be any of: |
|
1438 |
#mustBeNew - fail (return empty string) if the file exists |
|
1439 |
#new - confirm if the file exists |
|
1440 |
#mustBeOld - fail if the file does not exist |
|
1441 |
#old - confirm if the file does not exist |
|
1442 |
#any (other) - no validation |
|
1443 |
" |
|
1444 |
||
1445 |
||
1446 |
|patternUsed enteredFileName enteredFileNameString| |
|
1447 |
||
1448 |
patternUsed := FileSelectionBox lastSuffixPatternUsedForDefault:patternArg. |
|
1449 |
||
1450 |
self |
|
1451 |
startApplicationFor:titleString |
|
1452 |
default:defaultName |
|
1453 |
ok:okText |
|
1454 |
abort:abortText |
|
1455 |
ifFail:failBlock |
|
1456 |
pattern:patternUsed |
|
1457 |
fromDirectory:aDirectoryPath |
|
1458 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
1459 |
asLoadDialog:aBoolean |
|
1460 |
viewFiles:true |
|
1461 |
multipleSelect:false. |
|
1462 |
||
1463 |
enteredFileNameString := self result. |
|
1464 |
enteredFileNameString isEmptyOrNil ifTrue:[ |
|
1465 |
^ failBlock value |
|
1466 |
]. |
|
1467 |
||
1468 |
enteredFileName := enteredFileNameString asFilename. |
|
1469 |
enteredFileName isRelative ifTrue:[ |
|
1470 |
(versionSymbol isNil and:[#(http https ftp) includes:(enteredFileNameString upToAll:'://')]) ifTrue:[ |
|
1471 |
^ enteredFileNameString. |
|
1472 |
] ifFalse:[ |
|
1473 |
enteredFileName := self directory construct:enteredFileNameString. |
|
1474 |
enteredFileNameString := enteredFileName asString. |
|
1475 |
]. |
|
1476 |
]. |
|
1477 |
||
1478 |
FileSelectionBox lastFileSelectionDirectory:(enteredFileName directoryName). |
|
1479 |
(patternArg notEmptyOrNil and:[self pattern ~= patternArg]) ifTrue:[ |
|
1480 |
FileSelectionBox lastSuffixPatternUsedForDefault:patternArg is:self pattern |
|
1481 |
]. |
|
1482 |
||
1483 |
versionSymbol isNil ifTrue:[ ^ enteredFileNameString]. |
|
1484 |
versionSymbol == #mustBeNew ifTrue:[ |
|
1485 |
"/ file must not exist |
|
1486 |
enteredFileName exists ifTrue:[^ failBlock value]. |
|
1487 |
]. |
|
1488 |
versionSymbol == #new ifTrue:[ |
|
1489 |
"/ file should not exist |
|
1490 |
enteredFileName exists ifTrue:[ |
|
1491 |
(Dialog confirm:(resources stringWithCRs:'''%1'' exists.\\Continue anyway ?' with:enteredFileNameString)) |
|
1492 |
ifFalse:[^ failBlock value]. |
|
1493 |
]. |
|
1494 |
]. |
|
1495 |
versionSymbol == #mustBeOld ifTrue:[ |
|
1496 |
"/ file must exist |
|
1497 |
enteredFileName exists ifFalse:[^ failBlock value]. |
|
1498 |
]. |
|
1499 |
versionSymbol == #old ifTrue:[ |
|
1500 |
"/ file should exist |
|
1501 |
enteredFileName exists ifFalse:[ |
|
1502 |
(self confirm:(resources stringWithCRs:'''%1'' does not exist yet.\\Continue anyway ?' with:enteredFileNameString)) |
|
1503 |
ifFalse:[^ failBlock value]. |
|
1504 |
]. |
|
1505 |
]. |
|
1506 |
||
1507 |
^ enteredFileNameString |
|
1508 |
" |
|
1509 |
FileDialog |
|
1510 |
requestFileName:'enter a fileName:' |
|
1511 |
default:'' |
|
1512 |
ok:nil |
|
1513 |
abort:nil |
|
1514 |
version:nil |
|
1515 |
ifFail:['none'] |
|
1516 |
pattern:'*' |
|
1517 |
fromDirectory:Filename currentDirectory pathName |
|
1518 |
whenBoxCreatedEvaluate:nil |
|
1519 |
asLoadDialog:true |
|
1520 |
" |
|
1521 |
! |
|
1522 |
||
1523 |
requestFileNames:titleString default:defaultName |
|
1524 |
ok:okText abort:abortText |
|
1525 |
ifFail:failBlock |
|
1526 |
pattern:patternArg |
|
1527 |
fromDirectory:aDirectoryPath |
|
1528 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
1529 |
asLoadDialog:asLoadDialog |
|
1530 |
||
1531 |
"launch a Dialog, which allows user to enter a filename. |
|
1532 |
The files presented initially are those in aDirectoryPathOrNil, or the |
|
1533 |
last fileBox directory (default: current directory) (if a nil path is given). |
|
1534 |
The box will show okText in its okButton, abortText in the abortButton. |
|
1535 |
The matchPattern is set to pattern initially. |
|
1536 |
Return all selected Filenames as filenames in a collection, or nil if cancel was pressed |
|
1537 |
" |
|
1538 |
||
1539 |
||
1540 |
| enteredFileNames lastDirectory| |
|
1541 |
||
1542 |
self |
|
1543 |
startApplicationFor:titleString |
|
1544 |
default:defaultName |
|
1545 |
ok:okText |
|
1546 |
abort:abortText |
|
1547 |
ifFail:failBlock |
|
1548 |
pattern:patternArg |
|
1549 |
fromDirectory:aDirectoryPath |
|
1550 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
1551 |
asLoadDialog:asLoadDialog |
|
1552 |
viewFiles:true |
|
1553 |
multipleSelect:true. |
|
1554 |
||
1555 |
enteredFileNames := self currentSelectedFiles. |
|
1556 |
(enteredFileNames isEmpty or:[self result isNil]) ifTrue:[ |
|
1557 |
^ failBlock value |
|
1558 |
]. |
|
1559 |
lastDirectory := enteredFileNames first. |
|
1560 |
lastDirectory := lastDirectory isFilename ifTrue:[lastDirectory directory] ifFalse:[lastDirectory]. |
|
1561 |
FileSelectionBox lastFileSelectionDirectory:(lastDirectory directoryName). |
|
1562 |
^ enteredFileNames |
|
1563 |
||
1564 |
" |
|
1565 |
FileDialog |
|
1566 |
requestFileNames:'enter a fileName:' |
|
1567 |
default:'' |
|
1568 |
ok:nil |
|
1569 |
abort:nil |
|
1570 |
ifFail:['none'] |
|
1571 |
pattern:'*.conf' |
|
1572 |
fromDirectory:Filename currentDirectory pathName |
|
1573 |
whenBoxCreatedEvaluate:nil |
|
1574 |
asLoadDialog:true. |
|
1575 |
" |
|
1576 |
! |
|
1577 |
||
1578 |
startApplicationFor:titleString default:initialDefaultFileNameArg |
|
1579 |
ok:okTextArg abort:abortTextArg |
|
1580 |
ifFail:failBlock |
|
1581 |
pattern:patternArg |
|
1582 |
fromDirectory:aDirectoryPath |
|
1583 |
whenBoxCreatedEvaluate:boxCreatedCallback |
|
1584 |
asLoadDialog:asLoadDialog |
|
1585 |
viewFiles:viewFilesArg |
|
1586 |
multipleSelect:multipleSelectArg |
|
1587 |
||
1588 |
"launch a Dialog, which allows user to enter a filename. |
|
1589 |
The files presented initially are those in aDirectoryPathOrNil, or the |
|
1590 |
last fileBox directory (default: current directory) (if a nil path is given). |
|
1591 |
The box will show okText in its okButton, abortText in the abortButton. |
|
1592 |
The matchPattern is set to patternArg initially. |
|
1593 |
Return the string, or nil if cancel was pressed |
|
1594 |
The version argument allows validation of the files existance; |
|
1595 |
it may be any of: |
|
1596 |
#mustBeNew - fail (return empty string) if the file exists |
|
1597 |
#new - confirm if the file exists |
|
1598 |
#mustBeOld - fail if the file does not exist |
|
1599 |
#old - confirm if the file does not exist |
|
1600 |
#any (other) - no validation |
|
1601 |
" |
|
1602 |
||
1603 |
||
1604 |
|defaultDir defaultFile okText abortText initialDefaultFileName| |
|
1605 |
||
1606 |
initialDefaultFileName := initialDefaultFileNameArg. |
|
1607 |
initialDefaultFileName notNil ifTrue:[ |
|
1608 |
initialDefaultFileName := initialDefaultFileName asFilename. |
|
1609 |
]. |
|
1610 |
||
1611 |
okText := okTextArg. |
|
1612 |
okText isNil ifTrue:[ okText := self resources string:'OK' ]. |
|
1613 |
abortText := abortTextArg. |
|
1614 |
abortText isNil ifTrue:[ abortText := self resources string:'Cancel' ]. |
|
1615 |
||
1616 |
defaultDir := aDirectoryPath. |
|
1617 |
"/ defaultDir isNil ifTrue:[ |
|
1618 |
"/ (initialDefaultFileName size > 0 and:[initialDefaultFileName exists]) ifTrue:[ |
|
1619 |
"/ defaultDir := initialDefaultFileName asAbsoluteFilename directory. |
|
1620 |
"/ ] ifFalse:[ |
|
1621 |
"/ defaultDir := FileSelectionBox lastFileSelectionDirectory. |
|
1622 |
"/ defaultDir isNil ifTrue:[ |
|
1623 |
"/ defaultDir := Filename currentDirectory asAbsoluteFilename. |
|
1624 |
"/ ]. |
|
1625 |
"/ defaultDir asFilename exists ifFalse:[ |
|
1626 |
"/ defaultDir := nil |
|
1627 |
"/ ]. |
|
1628 |
"/ ] |
|
1629 |
"/ ]. |
|
1630 |
(initialDefaultFileName notNil |
|
1631 |
and:[initialDefaultFileName isAbsolute |
|
1632 |
and:[true "initialDefaultFileName asFilename exists"]]) ifTrue:[ |
|
1633 |
defaultDir := initialDefaultFileName asAbsoluteFilename. |
|
1634 |
true "viewFilesArg" ifTrue:[ |
|
1635 |
defaultFile := defaultDir asAbsoluteFilename. |
|
1636 |
defaultDir := defaultDir directory. |
|
1637 |
]. |
|
1638 |
] ifFalse:[ |
|
1639 |
defaultDir isNil ifTrue:[ |
|
1640 |
defaultDir := FileSelectionBox lastFileSelectionDirectory. |
|
1641 |
defaultDir isNil ifTrue:[ |
|
1642 |
defaultDir := Filename currentDirectory asAbsoluteFilename. |
|
1643 |
]. |
|
1644 |
defaultDir asFilename exists ifFalse:[ |
|
1645 |
defaultDir := nil |
|
1646 |
]. |
|
1647 |
] |
|
1648 |
]. |
|
1649 |
defaultDir := defaultDir asFilename asAbsoluteFilename. |
|
1650 |
"/ [defaultDir exists] whileFalse:[ |
|
1651 |
"/ defaultDir := defaultDir directory. |
|
1652 |
"/ ]. |
|
1653 |
||
1654 |
defaultFile isNil ifTrue:[ |
|
1655 |
viewFilesArg ifFalse:[ |
|
1656 |
defaultFile := defaultDir asAbsoluteFilename. |
|
1657 |
] ifTrue:[ |
|
1658 |
(initialDefaultFileName notNil and:[initialDefaultFileName withoutSuffix baseName ~= '*']) ifTrue:[ |
|
1659 |
defaultFile := defaultDir construct:initialDefaultFileName baseName. |
|
1660 |
] ifFalse:[ |
|
1661 |
defaultFile := defaultDir. |
|
1662 |
]. |
|
1663 |
]. |
|
1664 |
]. |
|
1665 |
||
1666 |
defaultDir notNil ifTrue:[self directory:defaultDir]. |
|
1667 |
self multipleSelect:(multipleSelectArg ? false). |
|
1668 |
self startFilename:defaultFile. |
|
1669 |
self pattern:(patternArg isEmptyOrNil ifTrue:['*'] ifFalse:[patternArg]). |
|
1670 |
self initialText:titleString. |
|
1671 |
self beLoadDialog:asLoadDialog ? false. |
|
1672 |
self viewFiles:(viewFilesArg ? true). |
|
1673 |
||
19511 | 1674 |
okLabelHolder value:okText. |
1675 |
cancelLabelHolder value:abortText. |
|
19478 | 1676 |
|
1677 |
self doubleClickAction:[:anIndex| |
|
1678 |
| item | |
|
1679 |
item := self treeBrowser fileList at:anIndex ifAbsent:nil. |
|
1680 |
item notNil ifTrue:[ |
|
1681 |
(self viewFiles and:[item isDirectory not]) ifTrue:[ |
|
1682 |
self doAccept. |
|
1683 |
] |
|
1684 |
] |
|
1685 |
]. |
|
1686 |
self allButOpenInterface:#windowSpec. |
|
1687 |
boxCreatedCallback notNil ifTrue:[boxCreatedCallback value:self]. |
|
1688 |
||
1689 |
"/ Dialog aboutToOpenBoxNotificationSignal raiseRequestWith:instance. |
|
1690 |
self treeBrowser sortCaseless value: (Filename isCaseSensitive not). |
|
1691 |
self openWindowModal. |
|
1692 |
||
1693 |
"Modified: / 23-08-2006 / 12:24:54 / cg" |
|
1694 |
"Modified: / 13-12-2006 / 16:25:42 / User" |
|
1695 |
"Modified (format): / 14-02-2017 / 12:49:34 / cg" |
|
1696 |
! ! |
|
1697 |
||
3892 | 1698 |
!FileDialog methodsFor:'accessing'! |
1699 |
||
19478 | 1700 |
additionalFolderItemsInMenu:aCollectionOfFoldernames |
1701 |
"any additional folders to be shown in this 'File' menu; |
|
1702 |
each element can be either a filename or a pair with filename and menu-item-label, |
|
1703 |
or an assoc, with key=filename and value=label." |
|
1704 |
||
1705 |
additionalFolderItemsInMenu := aCollectionOfFoldernames. |
|
1706 |
! |
|
1707 |
||
18749 | 1708 |
appendWasPressed |
1709 |
"valid after the dialog has been closed: true if append was pressed" |
|
1710 |
||
1711 |
^ appendWasPressed |
|
1712 |
! |
|
1713 |
||
3996 | 1714 |
currentSelectedFiles |
1715 |
||
1716 |
| selectedFiles| |
|
1717 |
||
1718 |
selectedFiles := treeBrowser currentFileNameHolder value. |
|
12828 | 1719 |
^ selectedFiles reject:[:aFile| aFile isDirectory ]. |
3996 | 1720 |
! |
1721 |
||
18015 | 1722 |
defaultWindowExtent |
1723 |
"return my default window extent or nil. |
|
1724 |
Return nil if the defaul extent should be computed by other means." |
|
1725 |
||
1726 |
^ LastExtent |
|
1727 |
||
1728 |
"Created: / 20-03-2018 / 11:26:14 / stefan" |
|
1729 |
! |
|
1730 |
||
3892 | 1731 |
directory |
1732 |
"return the value of the instance variable 'directory' (automatically generated)" |
|
1733 |
||
1734 |
^ directory |
|
1735 |
! |
|
1736 |
||
1737 |
directory:something |
|
1738 |
"set the value of the instance variable 'directory' (automatically generated)" |
|
1739 |
||
1740 |
directory := something. |
|
1741 |
! |
|
1742 |
||
1743 |
initialText |
|
13090 | 1744 |
^ resources string:(initialText ? 'File Dialog') |
3892 | 1745 |
! |
1746 |
||
1747 |
initialText:something |
|
1748 |
initialText := something. |
|
1749 |
! |
|
1750 |
||
1751 |
pattern |
|
1752 |
"return the value of the instance variable 'pattern' (automatically generated)" |
|
1753 |
||
1754 |
^ pattern |
|
1755 |
! |
|
1756 |
||
1757 |
pattern:something |
|
1758 |
"set the value of the instance variable 'pattern' (automatically generated)" |
|
1759 |
||
1760 |
pattern := something. |
|
1761 |
! |
|
1762 |
||
1763 |
result |
|
1764 |
"return the value of the instance variable 'result' (automatically generated)" |
|
1765 |
||
1766 |
^ result |
|
1767 |
! |
|
1768 |
||
1769 |
result:something |
|
1770 |
"set the value of the instance variable 'result' (automatically generated)" |
|
1771 |
||
1772 |
result := something. |
|
1773 |
! |
|
1774 |
||
3904 | 1775 |
selectedDirectories |
1776 |
||
1777 |
| selectedFiles| |
|
1778 |
||
1779 |
selectedFiles := treeBrowser currentFileNameHolder value. |
|
1780 |
^ selectedFiles select:[:aFile| aFile isDirectory]. |
|
1781 |
! |
|
1782 |
||
3892 | 1783 |
startFilename |
1784 |
startFilename isNil ifTrue:[ |
|
1785 |
startFilename := Filename currentDirectory asAbsoluteFilename. |
|
1786 |
]. |
|
1787 |
^ startFilename |
|
1788 |
! |
|
1789 |
||
1790 |
startFilename:something |
|
1791 |
startFilename := something. |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1792 |
! ! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1793 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1794 |
!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
|
1795 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1796 |
asLoadDialog |
4804 | 1797 |
^ self isLoadDialog |
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1798 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1799 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1800 |
asLoadDialog:aBoolean |
4804 | 1801 |
self beLoadDialog:aBoolean |
1802 |
! |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1803 |
|
4804 | 1804 |
beLoadDialog:aBoolean |
1805 |
||
1806 |
isLoadDialog := aBoolean |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1807 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1808 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1809 |
doubleClickAction |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1810 |
"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
|
1811 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1812 |
^ doubleClickAction |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1813 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1814 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1815 |
doubleClickAction:something |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1816 |
"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
|
1817 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1818 |
doubleClickAction := something. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1819 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1820 |
|
4804 | 1821 |
isLoadDialog |
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1822 |
|
4804 | 1823 |
^ isLoadDialog ? true |
1824 |
! |
|
1825 |
||
1826 |
multipleSelect |
|
1827 |
^ multipleSelect ? false |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1828 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1829 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1830 |
multipleSelect:aBoolean |
4804 | 1831 |
multipleSelect := aBoolean. |
1832 |
treeBrowser notNil ifTrue:[ |
|
1833 |
treeBrowser multipleSelect:aBoolean. |
|
1834 |
]. |
|
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1835 |
! ! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1836 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1837 |
!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
|
1838 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1839 |
addButton:aButton |
6068 | 1840 |
|buttonPanel okButton| |
1841 |
||
1842 |
buttonPanel := self componentAt:#ButtonPanel. |
|
1843 |
okButton := self okButton. |
|
1844 |
||
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1845 |
DialogBox defaultOKButtonAtLeft ifTrue:[ |
6068 | 1846 |
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
|
1847 |
] ifFalse:[ |
6068 | 1848 |
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
|
1849 |
]. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1850 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1851 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1852 |
okButton |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1853 |
^ (self componentAt:#okButton) |
3892 | 1854 |
! |
1855 |
||
3904 | 1856 |
treeBrowser |
1857 |
"return the value of the instance variable 'treeBrowser' (automatically generated)" |
|
1858 |
||
1859 |
^ treeBrowser |
|
4728
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 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1862 |
!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
|
1863 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1864 |
hideButtonPanel |
19511 | 1865 |
buttonPanelVisibleHolder value:false |
4728
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 |
|
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1868 |
newDirectoryVisibilityHolder |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1869 |
newDirectoryVisibilityHolder isNil ifTrue:[ |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1870 |
newDirectoryVisibilityHolder := true asValue. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1871 |
]. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1872 |
^ newDirectoryVisibilityHolder |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1873 |
! |
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 |
showButtonPanel |
19511 | 1876 |
buttonPanelVisibleHolder value:true |
3904 | 1877 |
! |
1878 |
||
3892 | 1879 |
viewFiles |
19166 | 1880 |
"if true, files can be selected; if false, only directories" |
3892 | 1881 |
|
1882 |
^ viewFiles |
|
1883 |
! |
|
1884 |
||
19174 | 1885 |
viewFiles:aBoolean |
19166 | 1886 |
"if true, files can be selected; if false, only directories" |
3892 | 1887 |
|
19174 | 1888 |
viewFiles := aBoolean. |
1889 |
||
1890 |
"Modified (comment): / 10-09-2019 / 18:36:08 / Stefan Vogel" |
|
3892 | 1891 |
! ! |
1892 |
||
1893 |
!FileDialog methodsFor:'aspects'! |
|
1894 |
||
4603
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1895 |
appendButtonVisibleHolder |
15451 | 1896 |
"if set, an additional 'append' button is shown |
1897 |
(to let user append to a file, instead of overwriting the file)" |
|
1898 |
||
4603
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1899 |
^ appendButtonVisibleHolder |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1900 |
! |
49cca8deebde
support an additional "append" button
Claus Gittinger <cg@exept.de>
parents:
4562
diff
changeset
|
1901 |
|
5193 | 1902 |
appendLabelHolder |
1903 |
^ appendLabelHolder |
|
1904 |
! |
|
1905 |
||
4804 | 1906 |
aspectOrNil:aKey forSubApplication:aSubApp |
1907 |
"this hook provides an aspect for a subApp" |
|
1908 |
||
1909 |
aKey == #currentFileNameHolder ifTrue:[ |
|
1910 |
directory notNil ifTrue:[ |
|
1911 |
^ (OrderedCollection with:directory) asValue |
|
1912 |
] |
|
1913 |
]. |
|
1914 |
^ nil |
|
1915 |
! |
|
1916 |
||
15451 | 1917 |
browseMenuItemVisible:aBoolean |
1918 |
"controls if an 'open filebrowser' menu item is to be shown in the toolbar" |
|
1919 |
||
19511 | 1920 |
browseMenuItemVisibleHolder value:aBoolean |
15451 | 1921 |
! |
1922 |
||
1923 |
browseMenuItemVisibleHolder |
|
1924 |
"controls if an 'open filebrowser' menu item is to be shown in the toolbar" |
|
1925 |
||
19174 | 1926 |
^ browseMenuItemVisibleHolder. |
15451 | 1927 |
! |
1928 |
||
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1929 |
buttonPanelVisibleHolder |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1930 |
^ buttonPanelVisibleHolder. |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1931 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
1932 |
|
3892 | 1933 |
cancelLabelHolder |
1934 |
^ cancelLabelHolder. |
|
1935 |
! |
|
1936 |
||
1937 |
enableBack |
|
4804 | 1938 |
^ treeBrowser enableBack. |
3892 | 1939 |
! |
1940 |
||
1941 |
enableDirectoryUp |
|
4804 | 1942 |
^ treeBrowser enableDirectoryUp. |
3892 | 1943 |
! |
1944 |
||
1945 |
enableForward |
|
4804 | 1946 |
^ treeBrowser enableForward. |
3892 | 1947 |
! |
1948 |
||
18533 | 1949 |
enableGotoDesktopDirectory |
18512 | 1950 |
^ treeBrowser enableGotoDesktopDirectory. |
18533 | 1951 |
|
1952 |
"Created: / 30-11-2018 / 17:05:19 / Stefan Vogel" |
|
18512 | 1953 |
! |
1954 |
||
1955 |
enableGotoDocuments |
|
1956 |
^ treeBrowser enableGotoDocumentsDirectory. |
|
1957 |
! |
|
1958 |
||
1959 |
enableGotoDownloads |
|
1960 |
^ treeBrowser enableGotoDownloadsDirectory. |
|
8169 | 1961 |
! |
1962 |
||
3892 | 1963 |
enableHome |
4804 | 1964 |
^ treeBrowser enableHome. |
3892 | 1965 |
! |
1966 |
||
9269
4d09efee3752
added: #fileEntryFieldHolder
Claus Gittinger <cg@exept.de>
parents:
9113
diff
changeset
|
1967 |
fileEntryFieldHolder |
4d09efee3752
added: #fileEntryFieldHolder
Claus Gittinger <cg@exept.de>
parents:
9113
diff
changeset
|
1968 |
"for directoryTreeBrowser" |
4d09efee3752
added: #fileEntryFieldHolder
Claus Gittinger <cg@exept.de>
parents:
9113
diff
changeset
|
1969 |
|
4d09efee3752
added: #fileEntryFieldHolder
Claus Gittinger <cg@exept.de>
parents:
9113
diff
changeset
|
1970 |
^ self filenameHolder |
4d09efee3752
added: #fileEntryFieldHolder
Claus Gittinger <cg@exept.de>
parents:
9113
diff
changeset
|
1971 |
! |
4d09efee3752
added: #fileEntryFieldHolder
Claus Gittinger <cg@exept.de>
parents:
9113
diff
changeset
|
1972 |
|
3892 | 1973 |
filenameHolder |
1974 |
"Return a value holder with the filename. |
|
1975 |
Shown in the filename input-field. |
|
9514
c818ca8969f7
comment/format in: #filenameHolder
Claus Gittinger <cg@exept.de>
parents:
9476
diff
changeset
|
1976 |
Being the selection in the tree." |
c818ca8969f7
comment/format in: #filenameHolder
Claus Gittinger <cg@exept.de>
parents:
9476
diff
changeset
|
1977 |
|
3892 | 1978 |
|holder| |
7581 | 1979 |
|
3892 | 1980 |
holder := builder bindingAt:#filenameHolder. |
1981 |
||
7581 | 1982 |
holder isNil ifTrue:[ |
13001 | 1983 |
holder := startFilename asValue. |
3892 | 1984 |
holder addDependent:self. |
9514
c818ca8969f7
comment/format in: #filenameHolder
Claus Gittinger <cg@exept.de>
parents:
9476
diff
changeset
|
1985 |
builder aspectAt:#filenameHolder put:holder. |
3892 | 1986 |
]. |
1987 |
||
1988 |
^ holder. |
|
9514
c818ca8969f7
comment/format in: #filenameHolder
Claus Gittinger <cg@exept.de>
parents:
9476
diff
changeset
|
1989 |
|
c818ca8969f7
comment/format in: #filenameHolder
Claus Gittinger <cg@exept.de>
parents:
9476
diff
changeset
|
1990 |
"Modified: / 09-07-2010 / 19:25:15 / cg" |
3892 | 1991 |
! |
1992 |
||
8183 | 1993 |
filenameHolder:aHolder |
8182 | 1994 |
"needed when used as subcanvas" |
8183 | 1995 |
|
1996 |
|holder| |
|
8182 | 1997 |
|
8183 | 1998 |
holder := builder aspectAt:#filenameHolder. |
1999 |
holder notNil ifTrue:[ |
|
2000 |
holder removeDependent:self |
|
2001 |
]. |
|
8182 | 2002 |
builder aspectAt:#filenameHolder put:aHolder. |
8183 | 2003 |
aHolder addDependent:self |
8182 | 2004 |
! |
2005 |
||
3904 | 2006 |
filenameLabelHolder |
2007 |
"Return a value holder for the input string. |
|
2008 |
" |
|
2009 |
^ filenameLabelHolder |
|
2010 |
! |
|
2011 |
||
3892 | 2012 |
filterHolder |
8183 | 2013 |
"Return a value holder for filter" |
3892 | 2014 |
|
2015 |
^ filterHolder |
|
2016 |
! |
|
2017 |
||
8183 | 2018 |
filterHolder:aHolder |
2019 |
"needed when used as subcanvas" |
|
2020 |
||
2021 |
filterHolder := aHolder. |
|
2022 |
! |
|
2023 |
||
9113 | 2024 |
gotoBookmarksMenu |
6098 | 2025 |
<resource: #programMenu> |
2026 |
||
9113 | 2027 |
^ treeBrowser gotoBookmarksMenu |
7567
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2028 |
"/ |menu bookmarks| |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2029 |
"/ |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2030 |
"/ menu := treeBrowser class emptyMenuSpec decodeAsLiteralArray. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2031 |
"/ menu findGuiResourcesIn:self. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2032 |
"/ menu receiver:self. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2033 |
"/ |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2034 |
"/ "/ add the bookmark items ... |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2035 |
"/ bookmarks := treeBrowser class directoryBookmarks. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2036 |
"/ bookmarks notEmptyOrNil ifTrue:[ |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2037 |
"/ bookmarks do:[:dirName | |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2038 |
"/ menu addItem:((MenuItem label:dirName asString value:[ |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2039 |
"/ (treeBrowser currentSelectedDirectories includes:dirName) ifFalse:[ |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2040 |
"/ treeBrowser setCurrentFileName:dirName. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2041 |
"/ ]. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2042 |
"/ ])). |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2043 |
"/ ]. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2044 |
"/ ]. |
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2045 |
"/ ^ menu |
6098 | 2046 |
|
7567
9896e794a220
share the bookmarks-menu with the fileBrowser.
Claus Gittinger <cg@exept.de>
parents:
6953
diff
changeset
|
2047 |
"Modified: / 06-12-2006 / 12:05:06 / cg" |
6098 | 2048 |
! |
2049 |
||
6065 | 2050 |
listOfDeviceDrives |
2051 |
||
2052 |
listOfDeviceDrives isNil ifTrue:[ |
|
2053 |
listOfDeviceDrives := Filename volumes. |
|
2054 |
]. |
|
2055 |
^ listOfDeviceDrives |
|
2056 |
! |
|
2057 |
||
15766 | 2058 |
okLabelEnabled |
2059 |
<resource: #uiAspect> |
|
2060 |
||
2061 |
okLabelEnabled isNil ifTrue:[ |
|
2062 |
isLoadDialog ifTrue:[ |
|
17410 | 2063 |
okLabelEnabled := |
2064 |
BlockValue |
|
2065 |
with:[:filename| |
|
2066 |
|ok| |
|
2067 |
||
2068 |
ok := true. |
|
2069 |
||
2070 |
multipleSelect ifTrue:[ |
|
2071 |
ok := treeBrowser selectedFiles notEmpty |
|
2072 |
and:[ treeBrowser selectedFiles conform:[:each | each isRegularFile] ] |
|
2073 |
] ifFalse:[ |
|
2074 |
filename isEmptyOrNil ifTrue:[ |
|
2075 |
ok := false |
|
2076 |
] ifFalse:[ |
|
2077 |
|physicalFilename| |
|
2078 |
||
2079 |
physicalFilename := filename asFilename physicalFilename. |
|
2080 |
physicalFilename isNil ifTrue:[ |
|
2081 |
ok := false |
|
2082 |
] ifFalse:[ |
|
2083 |
viewFiles |
|
2084 |
ifTrue:[ ok := physicalFilename isRegularFile ] |
|
2085 |
ifFalse:[ ok := physicalFilename isDirectory ] |
|
2086 |
]. |
|
2087 |
] |
|
2088 |
]. |
|
2089 |
ok |
|
2090 |
] |
|
2091 |
argument:self filenameHolder. |
|
15766 | 2092 |
] ifFalse:[ |
2093 |
okLabelEnabled := true. |
|
2094 |
]. |
|
2095 |
]. |
|
2096 |
^ okLabelEnabled. |
|
17410 | 2097 |
|
2098 |
"Modified: / 14-02-2017 / 13:00:40 / cg" |
|
15766 | 2099 |
! |
2100 |
||
3892 | 2101 |
okLabelHolder |
2102 |
^ okLabelHolder. |
|
6065 | 2103 |
! |
2104 |
||
8191
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2105 |
rootDirectoryHolder |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2106 |
"Return a value holder for filter" |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2107 |
|
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2108 |
rootDirectoryHolder isNil ifTrue:[ |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2109 |
rootDirectoryHolder := self initialRootDirectory asValue. |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2110 |
]. |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2111 |
^ rootDirectoryHolder |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2112 |
! |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2113 |
|
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2114 |
rootDirectoryHolder:aHolder |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2115 |
"Return a value holder for filter" |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2116 |
|
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2117 |
rootDirectoryHolder := aHolder. |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2118 |
! |
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2119 |
|
19012 | 2120 |
searchInfoBoxVisibleHolder |
2121 |
"set during search-file operation" |
|
2122 |
||
2123 |
^ searchInfoBoxVisibleHolder |
|
2124 |
! |
|
2125 |
||
2126 |
searchedDirectoryInfoHolder |
|
2127 |
"updated during search-file operation" |
|
2128 |
||
2129 |
^ searchedDirectoryInfoHolder |
|
2130 |
! |
|
2131 |
||
6065 | 2132 |
selectedDeviceDrive |
2133 |
||
2134 |
selectedDeviceDrive isNil ifTrue:[ |
|
2135 |
selectedDeviceDrive := self listOfDeviceDrives first asValue. |
|
2136 |
selectedDeviceDrive addDependent:self. |
|
2137 |
]. |
|
2138 |
^ selectedDeviceDrive |
|
9110 | 2139 |
! |
2140 |
||
9113 | 2141 |
showDirectoryTree |
2142 |
^ false |
|
2143 |
! |
|
2144 |
||
2145 |
showDiskUsageHolder |
|
2146 |
^ treeBrowser showDiskUsageHolder |
|
2147 |
! |
|
2148 |
||
9110 | 2149 |
showHiddenFiles |
9113 | 2150 |
^ treeBrowser showHiddenFiles |
2151 |
! |
|
2152 |
||
2153 |
shownFiles |
|
2154 |
^ treeBrowser shownFiles |
|
2155 |
! |
|
2156 |
||
19357 | 2157 |
sortCaseless |
2158 |
^ treeBrowser sortCaseless |
|
2159 |
! |
|
2160 |
||
9113 | 2161 |
sortCaselessInTreeBrowser |
19357 | 2162 |
<resource: #obsolete> |
2163 |
||
2164 |
"only for backward compat. |
|
2165 |
We do not need two such flags" |
|
2166 |
||
9113 | 2167 |
^ treeBrowser sortCaselessInTreeBrowser |
2168 |
! |
|
2169 |
||
2170 |
sortInTreeVisibilityHolder |
|
2171 |
^ true |
|
2172 |
! |
|
2173 |
||
2174 |
sortPropertyInTree |
|
2175 |
^ treeBrowser sortBlockProperty |
|
2176 |
! |
|
2177 |
||
2178 |
viewDirsInContentsBrowser |
|
2179 |
^ false |
|
2180 |
! |
|
2181 |
||
2182 |
viewFilesInDirectoryTree |
|
2183 |
^ false |
|
2184 |
! |
|
2185 |
||
2186 |
viewNoteBookApplicationHolder |
|
9110 | 2187 |
^ false |
3892 | 2188 |
! ! |
2189 |
||
2190 |
!FileDialog methodsFor:'change & update'! |
|
2191 |
||
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
2192 |
buttonPanelVisibilityChanged |
12848
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2193 |
|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
|
2194 |
|
12848
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2195 |
panel := builder componentAt:#FilePanel. |
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2196 |
panel isNil ifTrue:[ |
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2197 |
filePart := builder componentAt:#FilePart. |
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2198 |
]. |
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2199 |
partAbove := panel ? filePart. |
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2200 |
partAbove notNil ifTrue:[ |
5598 | 2201 |
buttonPanelVisibleHolder value ifTrue:[ |
12848
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2202 |
partAbove layout bottomOffset:-40 |
5598 | 2203 |
] ifFalse:[ |
12848
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2204 |
partAbove layout bottomOffset:0 |
5598 | 2205 |
]. |
12848
90fde21c7de4
class: Expecco::ExpeccoDebugView
Claus Gittinger <cg@exept.de>
parents:
12828
diff
changeset
|
2206 |
partAbove containerChangedSize "/ force resize |
5598 | 2207 |
] |
4728
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
2208 |
! |
545cd2c65dfa
hooks to allow use as component in a non-modal subcanvas
Claus Gittinger <cg@exept.de>
parents:
4666
diff
changeset
|
2209 |
|
9765 | 2210 |
fileSelectionChanged |
19120 | 2211 |
|files singleSelectedFileOrDirectory newFile entryFieldFilename filenameHolder| |
9765 | 2212 |
|
19120 | 2213 |
"/ the name in the entry field |
9765 | 2214 |
filenameHolder := self filenameHolder. |
2215 |
||
19120 | 2216 |
"/ the selection in the tree |
9765 | 2217 |
files := treeBrowser currentFileNameHolder value. |
19120 | 2218 |
files size == 1 ifTrue:[ |
2219 |
singleSelectedFileOrDirectory := files first. |
|
2220 |
]. |
|
2221 |
singleSelectedFileOrDirectory isNil ifTrue:[ |
|
2222 |
"/ self halt. |
|
2223 |
^ self. |
|
2224 |
]. |
|
2225 |
singleSelectedFileOrDirectory := singleSelectedFileOrDirectory asFilename. |
|
9765 | 2226 |
|
19178 | 2227 |
"/ (viewFiles and:[singleSelectedFileOrDirectory isDirectory]) ifTrue:[ |
2228 |
"/ entryFieldFilename := filenameHolder value. |
|
2229 |
"/ (entryFieldFilename isEmptyOrNil or:[(entryFieldFilename := entryFieldFilename asFilename) isDirectory]) ifTrue:[ |
|
2230 |
"/ "currently no plain file is selected. Replace the currently selected nothing or directory" |
|
2231 |
"/ newFile := singleSelectedFileOrDirectory. |
|
2232 |
"/ ] ifFalse:[ |
|
2233 |
"/ self startFilename asFilename baseName = entryFieldFilename baseName ifTrue:[ |
|
2234 |
"/ newFile := singleSelectedFileOrDirectory construct:entryFieldFilename baseName. |
|
2235 |
"/ ]. |
|
2236 |
"/ ]. |
|
2237 |
||
2238 |
viewFiles ifFalse:[ |
|
2239 |
newFile := singleSelectedFileOrDirectory. |
|
2240 |
] ifTrue:[ |
|
2241 |
singleSelectedFileOrDirectory isDirectory ifFalse:[ |
|
2242 |
"/ user clicked on a file |
|
19166 | 2243 |
newFile := singleSelectedFileOrDirectory. |
19178 | 2244 |
] ifTrue:[ |
2245 |
"/ user clicked on a directory; |
|
2246 |
"/ if the entry field holds a file, keep the basename |
|
2247 |
(entryFieldFilename := filenameHolder value) notEmptyOrNil ifTrue:[ |
|
2248 |
entryFieldFilename := entryFieldFilename asFilename. |
|
2249 |
entryFieldFilename isDirectory ifFalse:[ |
|
2250 |
self startFilename asFilename baseName = entryFieldFilename baseName ifTrue:[ |
|
2251 |
newFile := singleSelectedFileOrDirectory construct:entryFieldFilename baseName. |
|
2252 |
]. |
|
2253 |
] ifTrue:[ |
|
2254 |
newFile := singleSelectedFileOrDirectory. |
|
2255 |
]. |
|
2256 |
] ifFalse:[ |
|
2257 |
newFile := singleSelectedFileOrDirectory. |
|
2258 |
"/ self halt. |
|
19120 | 2259 |
]. |
9765 | 2260 |
]. |
2261 |
]. |
|
19120 | 2262 |
newFile notNil ifTrue:[ |
2263 |
filenameHolder value:newFile withoutNotifying:self. |
|
2264 |
||
2265 |
OperatingSystem supportsVolumes ifTrue:[ |
|
2266 |
| volume | |
|
2267 |
||
2268 |
volume := newFile volume. |
|
2269 |
self selectedDeviceDrive value:volume withoutNotifying:self. |
|
9765 | 2270 |
]. |
2271 |
]. |
|
2272 |
||
2273 |
"Created: / 14-02-2011 / 17:54:08 / cg" |
|
17410 | 2274 |
"Modified (format): / 14-02-2017 / 12:50:11 / cg" |
19174 | 2275 |
"Modified: / 10-09-2019 / 18:56:59 / Stefan Vogel" |
9765 | 2276 |
! |
2277 |
||
6065 | 2278 |
selectedDeviceDriveChanged |
9683
83fb945b7a5a
changed: #selectedDeviceDriveChanged
Claus Gittinger <cg@exept.de>
parents:
9678
diff
changeset
|
2279 |
|newDrive curSel newFile| |
6065 | 2280 |
|
2281 |
newDrive := self selectedDeviceDrive value. |
|
2282 |
curSel := treeBrowser currentFileNameHolder value. |
|
2283 |
curSel notEmpty ifTrue:[ |
|
2284 |
curSel first volume = newDrive ifTrue:[ ^self]. |
|
2285 |
]. |
|
9683
83fb945b7a5a
changed: #selectedDeviceDriveChanged
Claus Gittinger <cg@exept.de>
parents:
9678
diff
changeset
|
2286 |
|
6065 | 2287 |
newDrive notNil ifTrue:[ |
2288 |
newFile := newDrive asFilename. |
|
2289 |
newFile isReadable ifTrue:[ |
|
2290 |
treeBrowser gotoFile:newFile. |
|
2291 |
^self. |
|
2292 |
]. |
|
9683
83fb945b7a5a
changed: #selectedDeviceDriveChanged
Claus Gittinger <cg@exept.de>
parents:
9678
diff
changeset
|
2293 |
self warn:'Cannot open drive %1' with:newFile asFilename volume. |
6065 | 2294 |
]. |
9683
83fb945b7a5a
changed: #selectedDeviceDriveChanged
Claus Gittinger <cg@exept.de>
parents:
9678
diff
changeset
|
2295 |
|
16477 | 2296 |
newDrive := curSel notEmpty |
2297 |
ifTrue:[ curSel first volume ] |
|
2298 |
ifFalse:[ |
|
2299 |
OperatingSystem isMSWINDOWSlike ifTrue:['C:'] ifFalse:['/'] |
|
2300 |
"/ Filename defaultVolumeName. |
|
2301 |
]. |
|
9683
83fb945b7a5a
changed: #selectedDeviceDriveChanged
Claus Gittinger <cg@exept.de>
parents:
9678
diff
changeset
|
2302 |
self selectedDeviceDrive value:newDrive. |
6065 | 2303 |
! |
2304 |
||
3892 | 2305 |
update:something with:aParameter from:changedObject |
9765 | 2306 |
|newLabel fn| |
3892 | 2307 |
|
2308 |
changedObject == treeBrowser currentFileNameHolder ifTrue:[ |
|
9765 | 2309 |
self fileSelectionChanged. |
2310 |
^ self. |
|
3892 | 2311 |
]. |
4804 | 2312 |
|
6065 | 2313 |
changedObject == self selectedDeviceDrive ifTrue:[ |
2314 |
self selectedDeviceDriveChanged. |
|
2315 |
^ self. |
|
2316 |
]. |
|
3904 | 2317 |
changedObject == treeBrowser viewFilesInDirectoryTree ifTrue:[ |
2318 |
changedObject value ifTrue:[ |
|
4804 | 2319 |
newLabel := 'Filename:'. |
3904 | 2320 |
] ifFalse:[ |
4804 | 2321 |
newLabel := 'Directory:'. |
2322 |
]. |
|
19511 | 2323 |
filenameLabelHolder value:(resources string:newLabel) |
3904 | 2324 |
]. |
9765 | 2325 |
changedObject == self filenameHolder ifTrue:[ |
4804 | 2326 |
fn := changedObject value asFilename. |
2327 |
(fn exists) ifFalse:[^ self]. |
|
17410 | 2328 |
treeBrowser currentFileNameHolder value:(OrderedCollection with:fn) withoutNotifying:self. |
5949 | 2329 |
fn isDirectory ifTrue:[ |
2330 |
treeBrowser expandEnforceSelectedItems. |
|
2331 |
]. |
|
3892 | 2332 |
]. |
2333 |
^ super update:something with:aParameter from:changedObject |
|
9514
c818ca8969f7
comment/format in: #filenameHolder
Claus Gittinger <cg@exept.de>
parents:
9476
diff
changeset
|
2334 |
|
9765 | 2335 |
"Modified: / 14-02-2011 / 17:54:35 / cg" |
17410 | 2336 |
"Modified (format): / 14-02-2017 / 12:50:30 / cg" |
3892 | 2337 |
! ! |
2338 |
||
12816 | 2339 |
!FileDialog methodsFor:'construction-adding'! |
2340 |
||
2341 |
addComponent: aView |
|
12875 | 2342 |
verticalPanelView addComponent: aView |
12816 | 2343 |
|
2344 |
"Created: / 03-06-2013 / 17:47:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2345 |
! ! |
|
2346 |
||
3892 | 2347 |
!FileDialog methodsFor:'event handling'! |
2348 |
||
18749 | 2349 |
processEvent:anEvent |
2350 |
"filter keyboard edit-events typed into the listOfItemsView. |
|
2351 |
Return true, if I have eaten the event" |
|
2352 |
||
2353 |
<resource: #keyboard (#FindNext)> |
|
2354 |
||
2355 |
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
|
2356 |
|
18749 | 2357 |
anEvent key == #FindNext ifTrue:[ |
2358 |
self doFindAndSelectNextFile. |
|
2359 |
^ true |
|
2360 |
]. |
|
2361 |
^ false |
|
2362 |
||
2363 |
"Created: / 02-05-2019 / 21:17:15 / Claus Gittinger" |
|
3892 | 2364 |
! ! |
2365 |
||
2366 |
!FileDialog methodsFor:'initialization & release'! |
|
2367 |
||
5932 | 2368 |
closeDownViews |
9765 | 2369 |
self rememberExtent. |
5932 | 2370 |
super closeDownViews. |
9765 | 2371 |
|
2372 |
"Modified: / 14-02-2011 / 17:55:14 / cg" |
|
5932 | 2373 |
! |
2374 |
||
2375 |
closeWindow |
|
9765 | 2376 |
self rememberExtent. |
5932 | 2377 |
super closeWindow. |
9765 | 2378 |
|
2379 |
"Modified: / 14-02-2011 / 17:55:55 / cg" |
|
5932 | 2380 |
! |
2381 |
||
5903
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2382 |
commonPostOpen |
8182 | 2383 |
|selection| |
3892 | 2384 |
|
17316 | 2385 |
super commonPostOpen. |
2386 |
||
3892 | 2387 |
"/ 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
|
2388 |
|
19062 | 2389 |
treeBrowser rootHolder value:(self initialRootDirectory). |
2390 |
||
3892 | 2391 |
treeBrowser currentFileNameHolder addDependent:self. |
5598 | 2392 |
treeBrowser doubleClickAction:self doubleClickAction. |
3904 | 2393 |
treeBrowser viewFilesInDirectoryTree addDependent:self. |
5863
e31e066a41d9
root is one up (showing containing directory)
Claus Gittinger <cg@exept.de>
parents:
5858
diff
changeset
|
2394 |
|
4804 | 2395 |
treeBrowser viewFilesInDirectoryTree setValue:(self viewFiles ? true). |
4796 | 2396 |
treeBrowser viewFilesInDirectoryTree changed. |
4804 | 2397 |
|
2398 |
self isLoadDialog ifTrue:[ |
|
4796 | 2399 |
treeBrowser newVisibilityHolder value:false. |
2400 |
treeBrowser allowFileOperations value:false. |
|
2401 |
self newDirectoryVisibilityHolder value:false. |
|
2402 |
]. |
|
5927 | 2403 |
treeBrowser expandEnforceSelectedItems. |
5929 | 2404 |
|
2405 |
selection := treeBrowser treeSelectionHolder value. |
|
2406 |
selection notEmptyOrNil ifTrue:[ |
|
5930 | 2407 |
selection := selection asCollection first. |
5929 | 2408 |
selection enforcedExpand. |
2409 |
treeBrowser browser makeItemVisible:selection withMinimumLines:5. |
|
2410 |
]. |
|
18749 | 2411 |
self windowGroup addPreEventHook:self. |
2412 |
||
2413 |
"Modified: / 02-05-2019 / 21:15:18 / Claus Gittinger" |
|
4796 | 2414 |
! |
2415 |
||
6409 | 2416 |
initialRootDirectory |
2417 |
"returns the directory the browser is open on |
|
2418 |
" |
|
2419 |
|root| |
|
2420 |
||
9678 | 2421 |
initialRoot isNil ifTrue:[ |
6409 | 2422 |
|
9678 | 2423 |
(root := self directory) notNil ifTrue:[ |
2424 |
root := root asFilename. |
|
6409 | 2425 |
|
2426 |
root isDirectory ifFalse:[ |
|
9678 | 2427 |
root := root directory. |
2428 |
root isDirectory ifFalse:[ |
|
2429 |
root := nil. |
|
2430 |
] |
|
6409 | 2431 |
] |
9678 | 2432 |
]. |
2433 |
root isNil ifTrue:[ |
|
2434 |
root := Filename currentDirectory. |
|
2435 |
]. |
|
2436 |
initialRoot := root asAbsoluteFilename. |
|
6409 | 2437 |
]. |
9678 | 2438 |
^ initialRoot |
2439 |
||
2440 |
"Modified: / 27-12-2010 / 09:56:30 / cg" |
|
6409 | 2441 |
! |
2442 |
||
15767 | 2443 |
initialize |
15768 | 2444 |
super initialize. |
19511 | 2445 |
|
15767 | 2446 |
isLoadDialog := false. |
19174 | 2447 |
viewFiles := true. |
2448 |
multipleSelect := false. |
|
2449 |
||
19511 | 2450 |
appendButtonVisibleHolder := false asValue. |
2451 |
appendLabelHolder := 'Append' asValue. |
|
2452 |
okLabelHolder := 'OK' asValue. |
|
2453 |
browseMenuItemVisibleHolder := true "false" asValue. |
|
2454 |
||
2455 |
buttonPanelVisibleHolder := true asValue. |
|
2456 |
buttonPanelVisibleHolder onChangeSend:#buttonPanelVisibilityChanged to:self. |
|
2457 |
||
2458 |
cancelLabelHolder := 'Cancel' asValue. |
|
2459 |
filenameLabelHolder := 'Filename:' asValue. |
|
2460 |
filterHolder := (self pattern ? '*') asValue. |
|
2461 |
searchInfoBoxVisibleHolder := false asValue. |
|
2462 |
||
2463 |
searchedDirectoryInfoHolder := nil asValue. |
|
2464 |
||
19174 | 2465 |
"Modified: / 10-09-2019 / 18:40:07 / Stefan Vogel" |
15767 | 2466 |
! |
2467 |
||
5903
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2468 |
postBuildFileNameField:aWidget |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2469 |
|
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2470 |
filenameField := aWidget. |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2471 |
! |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2472 |
|
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2473 |
postBuildFilterField:aWidget |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2474 |
|
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2475 |
filterField := aWidget. |
4796 | 2476 |
! |
2477 |
||
5903
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2478 |
postBuildTreeBrowser:aSubCanvasView |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2479 |
treeBrowser := aSubCanvasView client. |
6409 | 2480 |
treeBrowser rootHolder value:(self initialRootDirectory value). |
9113 | 2481 |
treeBrowser sortPropertyInTree:(treeBrowser sortBlockProperty). |
9553 | 2482 |
treeBrowser showHiddenFiles value:true. |
2483 |
||
2484 |
"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
|
2485 |
! |
4796 | 2486 |
|
12875 | 2487 |
postBuildVerticalPanelView:aView |
2488 |
verticalPanelView := aView. |
|
12816 | 2489 |
|
2490 |
"Created: / 03-06-2013 / 17:41:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2491 |
! |
|
2492 |
||
13004 | 2493 |
postBuildWith:aBuilder |
2494 |
|win hMin| |
|
2495 |
||
5903
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2496 |
treeBrowser multipleSelect:multipleSelect. |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2497 |
appendWasPressed := false. |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2498 |
|
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2499 |
(aBuilder componentAt:'cancelButton') cursor:(Cursor thumbsDown). |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2500 |
(aBuilder componentAt:'appendButton') cursor:(Cursor thumbsUp). |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2501 |
(aBuilder componentAt:'okButton') cursor:(Cursor thumbsUp). |
0c2fdcd6babf
make use of commonPostOpen in AppModel
Claus Gittinger <cg@exept.de>
parents:
5873
diff
changeset
|
2502 |
|
13004 | 2503 |
win := aBuilder window . |
13187 | 2504 |
win minExtent notNil ifTrue:[ |
2505 |
"minExtent is nil if window is not a TopView" |
|
2506 |
hMin := (win margin * 2) |
|
2507 |
+ (aBuilder menuBar isNil ifTrue:[0] ifFalse:[aBuilder menuBar preferredHeight]) |
|
2508 |
+ (aBuilder componentAt:#FilenameEntryField) height |
|
2509 |
+ (aBuilder componentAt:#ToolBar1) preferredHeight |
|
2510 |
+ (aBuilder componentAt:#ButtonPanel) preferredHeight. |
|
13004 | 2511 |
|
13187 | 2512 |
win minExtent:(win minExtent x @ hMin). |
2513 |
]. |
|
13090 | 2514 |
win topView label:self initialText. |
13004 | 2515 |
|
6632 | 2516 |
super postBuildWith:aBuilder |
5932 | 2517 |
! |
2518 |
||
8182 | 2519 |
postOpenAsSubcanvasWith:aBuilder |
2520 |
super postOpenAsSubcanvasWith:aBuilder. |
|
2521 |
||
2522 |
"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
|
2523 |
self hideButtonPanel. |
8183 | 2524 |
|
9809
fa5280b1259f
changed: #postOpenAsSubcanvasWith:
Stefan Vogel <sv@exept.de>
parents:
9769
diff
changeset
|
2525 |
"filenameHolder contains the initial file name, or nil" |
8191
1779a8c3730d
Make FileDialog usable as SubCanvas
Stefan Vogel <sv@exept.de>
parents:
8183
diff
changeset
|
2526 |
self startFilename:self filenameHolder value. |
9809
fa5280b1259f
changed: #postOpenAsSubcanvasWith:
Stefan Vogel <sv@exept.de>
parents:
9769
diff
changeset
|
2527 |
treeBrowser currentFileNameHolder value:(Array with:self startFilename). |
8182 | 2528 |
! |
2529 |
||
12816 | 2530 |
preOpenWith:aBuilder |
12883 | 2531 |
"called right before being opened" |
2532 |
||
18015 | 2533 |
verticalPanelView notNil ifTrue:[ |
2534 |
"/ SV: disabled, because dialogs where opened full height: |
|
2535 |
"/ "Increase height of the window so height of the file part |
|
2536 |
"/ remains the same. This cares for any components added by a hook" |
|
2537 |
"/ |
|
2538 |
"/ |delta| |
|
2539 |
"/ |
|
2540 |
"/ delta := verticalPanelView preferredHeight - verticalPanelView height. |
|
2541 |
"/ delta > 0 ifTrue:[ |
|
2542 |
"/ "/ components where added (possibly in the aboutToOpenBoxNotifiction |
|
2543 |
"/ aBuilder window height: (aBuilder window height + delta). |
|
2544 |
"/ ]. |
|
12875 | 2545 |
|
18015 | 2546 |
"/ This code was disabled without comment: |
12883 | 2547 |
"/ sumH := 0. |
2548 |
"/ verticalPanelView subViews from:2 do:[:view| |
|
2549 |
"/ sumH := sumH + view preferredHeight. |
|
2550 |
"/ ]. |
|
2551 |
"/ sumH ~~ 0 ifTrue:[ |
|
18015 | 2552 |
"/ newVPanelHeight := verticalPanelView preferredHeight. |
12883 | 2553 |
"/ aBuilder window height: aBuilder window height + sumH. |
2554 |
"/ ]. |
|
8182 | 2555 |
]. |
12816 | 2556 |
|
14151 | 2557 |
treeBrowser currentFileNameHolder value:(Array with:self startFilename). |
2558 |
||
12816 | 2559 |
"Created: / 03-06-2013 / 18:19:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
18015 | 2560 |
"Modified (format): / 20-03-2018 / 11:34:26 / stefan" |
8182 | 2561 |
! |
2562 |
||
9765 | 2563 |
rememberExtent |
18015 | 2564 |
"if the user changed the size of the dialog, the next time the dialog |
2565 |
is opened with this size. |
|
2566 |
But ignore height changes < 40 pixels. On some systems the height of the title bar |
|
2567 |
is added to the height. (https://expeccoalm.exept.de/D160693)" |
|
2568 |
||
2569 |
|currentExtent| |
|
2570 |
||
2571 |
currentExtent := self window topView extent. |
|
2572 |
(LastExtent isNil or:[(LastExtent y - currentExtent y) abs > 40]) ifTrue:[ |
|
2573 |
self class lastExtent:currentExtent. |
|
2574 |
]. |
|
9765 | 2575 |
|
2576 |
"Created: / 14-02-2011 / 17:55:11 / cg" |
|
18015 | 2577 |
"Modified: / 20-03-2018 / 11:44:06 / stefan" |
4796 | 2578 |
! ! |
2579 |
||
9113 | 2580 |
!FileDialog methodsFor:'menus'! |
2581 |
||
19478 | 2582 |
additionalFoldersMenuSlice |
2583 |
|slice| |
|
2584 |
||
2585 |
"/ AdditionalFolderItemsInMenu := #('/foo' '/etc' '/Users') |
|
2586 |
"/ AdditionalFolderItemsInMenu := #('/foo' ('/etc' 'Other') '/Users') |
|
2587 |
||
2588 |
{ additionalFolderItemsInMenu . AdditionalFolderItemsInMenu } do:[:moreOrEmpty | |
|
2589 |
moreOrEmpty notEmptyOrNil ifTrue:[ |
|
2590 |
slice isNil ifTrue:[ |
|
2591 |
slice := Menu new. |
|
2592 |
slice addSeparator. |
|
2593 |
]. |
|
2594 |
moreOrEmpty do:[:eachFolderNameOrPair | |
|
2595 |
|item fn label| |
|
2596 |
||
2597 |
eachFolderNameOrPair isArray ifTrue:[ |
|
2598 |
fn := eachFolderNameOrPair first. |
|
2599 |
label := eachFolderNameOrPair second. |
|
2600 |
] ifFalse:[ |
|
2601 |
eachFolderNameOrPair isAssociation ifTrue:[ |
|
2602 |
fn := eachFolderNameOrPair key. |
|
2603 |
label := eachFolderNameOrPair value. |
|
2604 |
] ifFalse:[ |
|
2605 |
fn := eachFolderNameOrPair. |
|
2606 |
label := eachFolderNameOrPair. |
|
2607 |
]. |
|
2608 |
]. |
|
2609 |
fn := fn asFilename. |
|
2610 |
||
2611 |
item := MenuItem new. |
|
2612 |
item label:label asString. |
|
2613 |
item itemValue:[ self gotoFile:fn ]. |
|
2614 |
item enabled:[ fn exists and:[fn isDirectory and:[fn isExecutable]]]. |
|
2615 |
slice addItem:item. |
|
2616 |
]. |
|
2617 |
]. |
|
2618 |
]. |
|
2619 |
^ slice |
|
2620 |
! |
|
2621 |
||
2622 |
additionalFoldersMenuSliceHolder |
|
2623 |
^ [ self additionalFoldersMenuSlice ] |
|
2624 |
||
2625 |
! |
|
2626 |
||
9113 | 2627 |
bookmarksMenu |
2628 |
^ treeBrowser bookmarksMenu |
|
2629 |
! |
|
2630 |
||
2631 |
directoryMenu |
|
2632 |
^ treeBrowser directoryMenu |
|
2633 |
! |
|
2634 |
||
2635 |
showMenuSpecForDialog |
|
2636 |
^ treeBrowser class showMenuSpecForDialog |
|
2637 |
! |
|
2638 |
||
2639 |
sortMenu |
|
2640 |
^ treeBrowser class sortInTreeMenu |
|
2641 |
! |
|
2642 |
||
2643 |
visitedDirectoriesMenu |
|
2644 |
^ treeBrowser visitedDirectoriesMenu |
|
2645 |
! ! |
|
2646 |
||
4796 | 2647 |
!FileDialog methodsFor:'private'! |
2648 |
||
2649 |
returnWasPressedInFilterField |
|
8663 | 2650 |
|wg ev| |
4796 | 2651 |
|
8663 | 2652 |
((wg := self windowGroup) notNil |
2653 |
and:[ (ev := wg lastEvent) notNil |
|
2654 |
and:[ ev isKeyEvent |
|
2655 |
and:[ ev key == #Return |
|
2656 |
and:[ (ev targetView isSameOrComponentOf:filterField) |
|
2657 |
or:[false "ev targetView isSameOrComponentOf:filenameField"]]]]]) ifTrue:[ |
|
4796 | 2658 |
^ true |
2659 |
]. |
|
2660 |
^ false |
|
2661 |
! |
|
2662 |
||
2663 |
returnWasPressedInFilterOrFilenameField |
|
17990 | 2664 |
|wg ev| |
4796 | 2665 |
|
17990 | 2666 |
((wg := self windowGroup) notNil |
2667 |
and:[(ev := wg lastEvent) notNil |
|
2668 |
and:[ev notNil |
|
4796 | 2669 |
and:[ev isKeyEvent |
2670 |
and:[ev key == #Return |
|
2671 |
and:[( ev targetView isSameOrComponentOf:filterField) |
|
17990 | 2672 |
or:[false "ev targetView isSameOrComponentOf:filenameField"]]]]]]) ifTrue:[ |
4796 | 2673 |
^ true |
2674 |
]. |
|
2675 |
^ false |
|
2676 |
! ! |
|
2677 |
||
6065 | 2678 |
!FileDialog methodsFor:'queries'! |
2679 |
||
2680 |
driveSelectorVisible |
|
2681 |
^ OperatingSystem isMSDOSlike |
|
2682 |
! ! |
|
2683 |
||
4796 | 2684 |
!FileDialog methodsFor:'user actions'! |
2685 |
||
2686 |
appendPressed |
|
2687 |
appendWasPressed := true. |
|
2688 |
self commonAcceptAction. |
|
2689 |
! |
|
2690 |
||
2691 |
commonAcceptAction |
|
2692 |
filenameField accept. |
|
2693 |
self result:(self filenameHolder value asString). |
|
2694 |
||
2695 |
^ super doAccept |
|
2696 |
! |
|
2697 |
||
2698 |
doAccept |
|
2699 |
"force accept - ignore in filterField" |
|
2700 |
||
2701 |
self returnWasPressedInFilterField ifTrue:[ |
|
2702 |
^ self |
|
2703 |
]. |
|
4996
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4824
diff
changeset
|
2704 |
treeBrowser hasOpenEditor ifTrue:[ |
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4824
diff
changeset
|
2705 |
"/ 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
|
2706 |
treeBrowser browser closeEditor. |
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4824
diff
changeset
|
2707 |
^ self |
5927cc0508e8
close the editor in treebrowser on rename if ENTER is pressed
penk
parents:
4824
diff
changeset
|
2708 |
]. |
4796 | 2709 |
appendWasPressed := false. |
2710 |
self commonAcceptAction. |
|
2711 |
! |
|
2712 |
||
2713 |
doBack |
|
2714 |
||
2715 |
treeBrowser doBack. |
|
2716 |
! |
|
2717 |
||
5966 | 2718 |
doBrowseDirectory |
17651 | 2719 |
FileBrowser default openOn:(treeBrowser currentDirectory ? treeBrowser rootHolder value). |
5966 | 2720 |
|
17651 | 2721 |
"Modified: / 01-09-2017 / 14:05:09 / cg" |
5966 | 2722 |
! |
2723 |
||
4796 | 2724 |
doCancel |
2725 |
||
2726 |
self result:nil. |
|
2727 |
^ super doCancel. |
|
2728 |
! |
|
2729 |
||
18268 | 2730 |
doFindAndSelectFile |
19012 | 2731 |
"search for a file matching a requested pattern" |
2732 |
||
2733 |
|fileNameInEditField initialSearchPattern patternAndTopDirectoryForSearch |
|
2734 |
searchPattern topDirectoryForSearch searchRoot list| |
|
18749 | 2735 |
|
19012 | 2736 |
(fileNameInEditField := filenameField contents) notEmptyOrNil ifTrue:[ |
2737 |
initialSearchPattern := fileNameInEditField asFilename baseName. |
|
2738 |
] ifFalse:[ |
|
2739 |
initialSearchPattern := LastFindPattern ? '*.txt' |
|
2740 |
]. |
|
18268 | 2741 |
|
19012 | 2742 |
patternAndTopDirectoryForSearch := Dialog |
18268 | 2743 |
request:'Filename Pattern (match):' |
19012 | 2744 |
initialAnswer:initialSearchPattern |
2745 |
and:'Search under:' |
|
2746 |
initialAnswer:(directory ? Filename currentDirectory) name |
|
19265 | 2747 |
label:'Search for File (not Folder)'. |
19012 | 2748 |
patternAndTopDirectoryForSearch isEmptyOrNil ifTrue:[^ self]. |
2749 |
||
2750 |
searchPattern := patternAndTopDirectoryForSearch first. |
|
2751 |
topDirectoryForSearch := patternAndTopDirectoryForSearch second. |
|
2752 |
||
2753 |
LastFindPattern := searchPattern. |
|
2754 |
||
2755 |
list := HierarchicalFileList new. |
|
2756 |
searchRoot := HierarchicalFileList::HierarchicalFileItem fileName:topDirectoryForSearch. |
|
2757 |
list root:searchRoot. |
|
18749 | 2758 |
|
18748 | 2759 |
self withWaitCursorDo:[ |
19012 | 2760 |
[ |
2761 |
|dirHolder| |
|
2762 |
||
19511 | 2763 |
dirHolder := searchedDirectoryInfoHolder. |
2764 |
searchInfoBoxVisibleHolder value:true. |
|
19012 | 2765 |
self windowGroup processExposeEvents. |
2766 |
||
2767 |
treeBrowser |
|
2768 |
findAndSelectNextFileMatching:searchPattern |
|
2769 |
under:searchRoot |
|
2770 |
searchInfoInto:[:path | dirHolder value:path. self windowGroup processExposeEvents]. |
|
2771 |
] ensure:[ |
|
19511 | 2772 |
searchInfoBoxVisibleHolder value:false |
19012 | 2773 |
] |
18748 | 2774 |
]. |
18268 | 2775 |
|
2776 |
"Created: / 17-07-2018 / 12:44:20 / Claus Gittinger" |
|
18749 | 2777 |
"Modified (format): / 02-05-2019 / 20:44:14 / Claus Gittinger" |
2778 |
! |
|
2779 |
||
2780 |
doFindAndSelectNextFile |
|
2781 |
"search the next file matching the previous pattern" |
|
2782 |
||
19264 | 2783 |
LastFindPattern isEmptyOrNil ifTrue:[ |
2784 |
self doFindAndSelectFile. |
|
2785 |
^ self. |
|
2786 |
]. |
|
18749 | 2787 |
self withWaitCursorDo:[ |
2788 |
treeBrowser findAndSelectNextFileMatching:LastFindPattern. |
|
2789 |
]. |
|
2790 |
||
2791 |
"Created: / 02-05-2019 / 21:18:13 / Claus Gittinger" |
|
18268 | 2792 |
! |
2793 |
||
4796 | 2794 |
doForward |
2795 |
||
2796 |
treeBrowser doForward. |
|
2797 |
! |
|
2798 |
||
2799 |
doGoDirectoryUp |
|
2800 |
||
2801 |
treeBrowser doGoDirectoryUp. |
|
2802 |
! |
|
2803 |
||
8092 | 2804 |
doGotoDesktopDirectory |
2805 |
||
2806 |
treeBrowser doGotoDesktopDirectory. |
|
19482 | 2807 |
self expandSelectionIfShowingFiles. |
2808 |
||
8092 | 2809 |
! |
2810 |
||
18037 | 2811 |
doGotoDocumentsDirectory |
2812 |
||
2813 |
treeBrowser doGotoDocumentsDirectory. |
|
19482 | 2814 |
self expandSelectionIfShowingFiles. |
2815 |
||
18037 | 2816 |
! |
2817 |
||
2818 |
doGotoDownloadsDirectory |
|
2819 |
||
2820 |
treeBrowser doGotoDownloadsDirectory. |
|
19482 | 2821 |
self expandSelectionIfShowingFiles. |
2822 |
||
18037 | 2823 |
! |
2824 |
||
4796 | 2825 |
doGotoHomeDirectory |
2826 |
||
2827 |
treeBrowser doGotoHomeDirectory. |
|
19482 | 2828 |
self expandSelectionIfShowingFiles. |
2829 |
||
2830 |
! |
|
2831 |
||
2832 |
expandSelectionIfShowingFiles |
|
2833 |
viewFiles ifTrue:[ |
|
2834 |
treeBrowser expandSelectedItems. |
|
2835 |
]. |
|
4796 | 2836 |
! |
2837 |
||
19265 | 2838 |
findAndSelectNextFileEnabledHolder |
2839 |
^ [LastFindPattern notEmptyOrNil]. |
|
2840 |
! |
|
2841 |
||
19267 | 2842 |
gotoFile:fn |
2843 |
treeBrowser gotoFile:fn. |
|
19482 | 2844 |
self expandSelectionIfShowingFiles. |
2845 |
||
19267 | 2846 |
! |
2847 |
||
4796 | 2848 |
menuDirHistory:backOrForward |
2849 |
||
2850 |
^ treeBrowser menuDirHistory:backOrForward. |
|
2851 |
! |
|
2852 |
||
2853 |
menuDirHistoryBack |
|
2854 |
||
2855 |
^ treeBrowser menuDirHistory:#back. |
|
2856 |
! |
|
2857 |
||
2858 |
menuDirHistoryForward |
|
2859 |
||
2860 |
^ treeBrowser menuDirHistory:#forward. |
|
2861 |
! |
|
2862 |
||
2863 |
newDirectory |
|
17380 | 2864 |
"forward to the treebrowser component, which already has this functionality" |
2865 |
||
2866 |
^ treeBrowser newDirectory |
|
4796 | 2867 |
|
17380 | 2868 |
"Modified (comment): / 04-02-2017 / 14:41:43 / cg" |
4796 | 2869 |
! |
2870 |
||
2871 |
okPressed |
|
2872 |
self doAccept |
|
9113 | 2873 |
! |
2874 |
||
19012 | 2875 |
openTerminal |
2876 |
"forward to the treebrowser component, which already has this functionality" |
|
2877 |
||
2878 |
^ treeBrowser openTerminal |
|
2879 |
! |
|
2880 |
||
9113 | 2881 |
updateCurrentDirectory |
2882 |
treeBrowser updateCurrentDirectory |
|
4796 | 2883 |
! ! |
2884 |
||
2885 |
!FileDialog class methodsFor:'documentation'! |
|
2886 |
||
2887 |
version |
|
15725 | 2888 |
^ '$Header$' |
12883 | 2889 |
! |
2890 |
||
2891 |
version_CVS |
|
15725 | 2892 |
^ '$Header$' |
19195 | 2893 |
! |
2894 |
||
2895 |
version_HG |
|
2896 |
||
2897 |
^ '$Changeset: <not expanded> $' |
|
2898 |
! |
|
2899 |
||
2900 |
version_SVN |
|
2901 |
^ '$Id$' |
|
4796 | 2902 |
! ! |
12816 | 2903 |