author | Jan Vrany <jan.vrany@labware.com> |
Mon, 26 Oct 2020 22:34:32 +0000 | |
branch | jv |
changeset 6247 | a1272bf7ae91 |
parent 5283 | 781bb59c4cd7 |
child 5689 | 9f4b7b32d11f |
permissions | -rw-r--r-- |
486 | 1 |
" |
489 | 2 |
COPYRIGHT (c) 1997 by eXept Software AG |
486 | 3 |
All Rights Reserved |
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1818 | 12 |
"{ Package: 'stx:libwidg2' }" |
13 |
||
5283 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
486 | 16 |
TreeItem subclass:#FileSelectionItem |
786 | 17 |
instanceVariableNames:'modificationTime matchAction isDirectory imageType showIndicator' |
2037 | 18 |
classVariableNames:'ReadDirectoriesForIndicator' |
486 | 19 |
poolDictionaries:'' |
20 |
category:'Interface-Support' |
|
21 |
! |
|
22 |
||
23 |
FileSelectionItem subclass:#Directory |
|
24 |
instanceVariableNames:'' |
|
25 |
classVariableNames:'' |
|
26 |
poolDictionaries:'' |
|
27 |
privateIn:FileSelectionItem |
|
28 |
! |
|
29 |
||
30 |
FileSelectionItem subclass:#File |
|
31 |
instanceVariableNames:'' |
|
32 |
classVariableNames:'' |
|
33 |
poolDictionaries:'' |
|
34 |
privateIn:FileSelectionItem |
|
35 |
! |
|
36 |
||
37 |
!FileSelectionItem class methodsFor:'documentation'! |
|
38 |
||
39 |
copyright |
|
40 |
" |
|
489 | 41 |
COPYRIGHT (c) 1997 by eXept Software AG |
486 | 42 |
All Rights Reserved |
43 |
||
44 |
This software is furnished under a license and may be used |
|
45 |
only in accordance with the terms of that license and with the |
|
46 |
inclusion of the above copyright notice. This software may not |
|
47 |
be provided or otherwise made available to, or used by, any |
|
48 |
other person. No title to or ownership of the software is |
|
49 |
hereby transferred. |
|
50 |
" |
|
51 |
||
52 |
||
53 |
! |
|
54 |
||
55 |
documentation |
|
56 |
" |
|
2805 | 57 |
class to build up file tree like structures. You can define your own |
58 |
icons and filter. To change the icons, look for these methods: |
|
486 | 59 |
|
2805 | 60 |
class method: #keysAndIcons : returns a list of icons and access keys used |
486 | 61 |
|
2805 | 62 |
instance method: #imageType : get type of icon assigned to file |
486 | 63 |
|
2805 | 64 |
#icon : get the type of image to be drawn |
486 | 65 |
|
66 |
Especially suited for use with FileSelectionTree. |
|
67 |
||
2037 | 68 |
[class variables:] |
69 |
ReadDirectoriesForIndicator <Boolean> if true, the directories are searched |
|
70 |
for subdirectories to update the |
|
71 |
indicator; on auto mounted file systems |
|
72 |
this would take a very long time!!!! |
|
2805 | 73 |
therefore the default is set to false. |
2037 | 74 |
|
486 | 75 |
[Author:] |
76 |
Claus Atzkern |
|
77 |
||
78 |
[See also:] |
|
79 |
TreeItem |
|
80 |
FileSelectionTree |
|
81 |
" |
|
82 |
! ! |
|
83 |
||
2037 | 84 |
!FileSelectionItem class methodsFor:'initialization'! |
85 |
||
86 |
initialize |
|
87 |
ReadDirectoriesForIndicator := false. |
|
88 |
! ! |
|
89 |
||
486 | 90 |
!FileSelectionItem class methodsFor:'instance creation'! |
91 |
||
92 |
pathName:aPath |
|
93 |
"create a new node entry associated with the full pathname, aPath |
|
94 |
" |
|
95 |
|node| |
|
96 |
||
97 |
node := self new. |
|
98 |
node pathName:aPath. |
|
99 |
^ node |
|
100 |
||
101 |
||
102 |
! ! |
|
103 |
||
104 |
!FileSelectionItem class methodsFor:'accessing class'! |
|
105 |
||
731 | 106 |
filterClassForDirectoriesOnly |
486 | 107 |
^ Directory |
108 |
! |
|
109 |
||
731 | 110 |
filterClassForFilesOnly |
486 | 111 |
^ File |
112 |
! ! |
|
113 |
||
114 |
!FileSelectionItem class methodsFor:'converting'! |
|
115 |
||
116 |
asFilename:aPathname |
|
117 |
"convert pathname to an absolute path |
|
118 |
" |
|
119 |
|path| |
|
120 |
||
121 |
path := aPathname asString. |
|
122 |
||
123 |
(path size > 1 and:[path endsWith:(Filename separator)]) ifTrue:[ |
|
4211
c553f879beac
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
2929
diff
changeset
|
124 |
^ (path copyButLast:1) asFilename. |
486 | 125 |
]. |
126 |
^ aPathname asFilename |
|
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
127 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
128 |
"Modified: / 24.9.1998 / 15:33:50 / cg" |
486 | 129 |
! ! |
130 |
||
786 | 131 |
!FileSelectionItem class methodsFor:'default icons'! |
486 | 132 |
|
786 | 133 |
keysAndIcons |
486 | 134 |
"returns an IdentityDictionary containing a list of images and keys used |
135 |
by any file entry. |
|
136 |
" |
|
137 |
|icons image| |
|
138 |
||
139 |
icons := IdentityDictionary new. |
|
5283 | 140 |
|
486 | 141 |
#( |
5283 | 142 |
(#directory fileTypeDirectoryIcon 'tiny_yellow_dir.xpm') |
143 |
(#directoryOpened fileTypeDirectoryOpenIcon 'tiny_yellow_dir_open.xpm') |
|
144 |
(#directoryLocked fileTypeDirectoryLockedIcon 'tiny_yellow_dir_locked.xpm') |
|
145 |
(#directoryLink fileTypeDirectoryLinkIcon 'tiny_yellow_dir_link.xpm' ) |
|
486 | 146 |
|
5283 | 147 |
(#file fileTypeFileIcon 'tiny_file_plain.xpm' ) |
148 |
(#fileLink fileTypeFileLinkIcon 'tiny_file_link.xpm' ) |
|
149 |
(#fileLocked fileTypeFileLockedIcon 'tiny_file_lock.xpm' ) |
|
150 |
(#imageFile fileTypeImageFileIcon 'tiny_file_pix.xpm' ) |
|
486 | 151 |
|
152 |
) do:[:el | |
|
5283 | 153 |
|key sel fileName| |
786 | 154 |
|
5283 | 155 |
key := el at:1. |
156 |
sel := el at:2. |
|
157 |
fileName := el at:3. |
|
158 |
image := ToolbarIconLibrary perform:sel. |
|
159 |
image isNil ifTrue:[ |
|
160 |
image := Image fromFile:('xpmBitmaps/document_images/', fileName ). |
|
161 |
]. |
|
569 | 162 |
image notNil ifTrue:[ |
163 |
icons at:(el first) put:image. |
|
164 |
] |
|
486 | 165 |
]. |
5283 | 166 |
^ icons |
486 | 167 |
! ! |
168 |
||
169 |
!FileSelectionItem methodsFor:'accessing'! |
|
170 |
||
171 |
children |
|
172 |
"get's list of children |
|
173 |
" |
|
786 | 174 |
readChildren ifTrue:[ |
569 | 175 |
children := self readInChildren |
486 | 176 |
]. |
177 |
^ children |
|
178 |
! |
|
179 |
||
811 | 180 |
fileName |
181 |
"returns the fileName of node |
|
182 |
" |
|
183 |
^ contents |
|
184 |
||
185 |
||
186 |
||
187 |
! |
|
188 |
||
786 | 189 |
icon |
569 | 190 |
"returns type of image to be drawn |
191 |
" |
|
192 |
(children size ~~ 0 and:[hide == false]) ifTrue:[ |
|
193 |
^ #directoryOpened |
|
194 |
]. |
|
195 |
^ self imageType |
|
196 |
! |
|
197 |
||
198 |
match:aOneArgBlock |
|
199 |
||
200 |
aOneArgBlock isNil ifTrue:[ |
|
201 |
self discardFiles ifTrue:[ |
|
202 |
matchAction := [:aFile :isDirectory| isDirectory ] |
|
203 |
] ifFalse:[ |
|
204 |
self discardDirectories ifTrue:[ |
|
205 |
matchAction := [:aFile :isDirectory| isDirectory not ] |
|
206 |
] ifFalse:[ |
|
207 |
matchAction := [:aFile :isDir| true ] |
|
208 |
] |
|
209 |
] |
|
210 |
] ifFalse:[ |
|
211 |
self discardFiles ifTrue:[ |
|
212 |
matchAction := [:aFile :isDirectory| (isDirectory and:[aOneArgBlock value:aFile]) ] |
|
213 |
] ifFalse:[ |
|
214 |
self discardDirectories ifTrue:[ |
|
215 |
matchAction := [:aFile :isDirectory| (isDirectory not and:[aOneArgBlock value:aFile]) ] |
|
216 |
] ifFalse:[ |
|
217 |
matchAction := [:aFile :isDir| aOneArgBlock value:aFile ] |
|
218 |
] |
|
219 |
] |
|
220 |
] |
|
221 |
! |
|
222 |
||
486 | 223 |
pathName |
224 |
"returns full pathname of node |
|
225 |
" |
|
569 | 226 |
^ contents asString |
486 | 227 |
|
228 |
||
229 |
! |
|
230 |
||
231 |
pathName:aPathname |
|
232 |
"initialze attributes associated with the full pathname, aPathname |
|
233 |
" |
|
569 | 234 |
|file| |
235 |
||
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
236 |
"/ file := self class asFilename:aPathname. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
237 |
file := aPathname asFilename pathName asFilename. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
238 |
self |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
239 |
fileName:file |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
240 |
baseName:(file baseName) |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
241 |
parent:nil |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
242 |
isDirectory:(file isDirectory) |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
243 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
244 |
"Modified: / 24.9.1998 / 16:02:53 / cg" |
569 | 245 |
! ! |
246 |
||
1818 | 247 |
!FileSelectionItem methodsFor:'accessing-hierarchy'! |
569 | 248 |
|
249 |
collapse |
|
811 | 250 |
"check to release children |
569 | 251 |
" |
811 | 252 |
self stopIndicatorValidation. |
569 | 253 |
hide := true. |
486 | 254 |
|
811 | 255 |
children notEmpty ifTrue:[ |
569 | 256 |
children do:[:aChild| |
811 | 257 |
aChild releaseCollapsedChildren ifFalse:[ ^ self ] |
569 | 258 |
]. |
811 | 259 |
self canReleaseChildren ifTrue:[ |
260 |
self releaseChildren |
|
569 | 261 |
] |
262 |
] |
|
811 | 263 |
|
569 | 264 |
! |
265 |
||
266 |
collapseAll |
|
267 |
"release my childrens |
|
268 |
" |
|
811 | 269 |
self stopIndicatorValidation. |
569 | 270 |
hide := true. |
271 |
||
811 | 272 |
children notEmpty ifTrue:[ |
273 |
self canReleaseChildren ifTrue:[ |
|
274 |
self releaseChildren |
|
569 | 275 |
] ifFalse:[ |
811 | 276 |
children do:[:c| c releaseChildren ] |
569 | 277 |
] |
486 | 278 |
]. |
811 | 279 |
|
844 | 280 |
! |
281 |
||
282 |
expandAll |
|
283 |
"not allowed for a file directory |
|
284 |
" |
|
285 |
self expand |
|
486 | 286 |
! ! |
287 |
||
2037 | 288 |
!FileSelectionItem methodsFor:'change & update'! |
289 |
||
290 |
changedSelected |
|
291 |
"called if the node is selected |
|
292 |
" |
|
293 |
|model| |
|
294 |
||
295 |
(showIndicator isNil and:[ReadDirectoriesForIndicator not]) ifTrue:[ |
|
296 |
model := self model. |
|
297 |
||
298 |
model notNil ifTrue:[ |
|
299 |
model startIndicatorValidationFor:self |
|
300 |
] |
|
301 |
]. |
|
302 |
! ! |
|
303 |
||
569 | 304 |
!FileSelectionItem methodsFor:'private'! |
486 | 305 |
|
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
306 |
childFileName:aFilename baseName:aBaseName parent:aParent isDirectory:aBool matchAction:mA |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
307 |
"initialze attributes associated with the full pathname, aPathname. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
308 |
Same as #fileName:baseName:parent:isDirectory:, |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
309 |
but used only for children (i.e. no need to check for |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
310 |
being a rootDirectory). |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
311 |
" |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
312 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
313 |
contents := aFilename. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
314 |
name := aBaseName. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
315 |
parent := aParent. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
316 |
isDirectory := readChildren := aBool. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
317 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
318 |
isDirectory ifFalse:[ |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
319 |
showIndicator := false |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
320 |
] ifTrue:[ |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
321 |
showIndicator := nil |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
322 |
]. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
323 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
324 |
matchAction := mA |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
325 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
326 |
"Modified: / 24.9.1998 / 14:10:38 / cg" |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
327 |
"Created: / 24.9.1998 / 15:51:58 / cg" |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
328 |
! |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
329 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
330 |
directoryIsLocked |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
331 |
^ self imageType == #directoryLocked |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
332 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
333 |
"Created: / 24.9.1998 / 14:22:08 / cg" |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
334 |
! |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
335 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
336 |
fileName:aFilename baseName:aBaseName parent:aParent isDirectory:aBool |
569 | 337 |
"initialze attributes associated with the full pathname, aPathname |
486 | 338 |
" |
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
339 |
|f| |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
340 |
|
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
341 |
contents := aFilename. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
342 |
(f := aFilename asFilename) isRootDirectory ifTrue:[ |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
343 |
name := f name. |
1144 | 344 |
"/ (name endsWith:Filename separator) ifTrue:[ |
345 |
"/ name ~= Filename separator asString ifTrue:[ |
|
346 |
"/ name := name copyWithoutLast:1. |
|
347 |
"/ ] |
|
348 |
"/ ] |
|
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
349 |
] ifFalse:[ |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
350 |
name := aBaseName. |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
351 |
]. |
569 | 352 |
parent := aParent. |
786 | 353 |
isDirectory := readChildren := aBool. |
486 | 354 |
|
569 | 355 |
isDirectory ifFalse:[ |
356 |
showIndicator := false |
|
357 |
] ifTrue:[ |
|
358 |
showIndicator := nil |
|
359 |
]. |
|
360 |
||
361 |
parent notNil ifTrue:[ |
|
362 |
matchAction := parent matchAction "/ same as from parent |
|
363 |
] ifFalse:[ |
|
364 |
self match:nil "/ setup matchAction new |
|
365 |
] |
|
486 | 366 |
|
1144 | 367 |
"Modified: / 24.9.1998 / 19:19:57 / cg" |
486 | 368 |
! |
369 |
||
569 | 370 |
matchAction |
371 |
"returns my match action |
|
486 | 372 |
" |
569 | 373 |
^ matchAction |
811 | 374 |
! |
375 |
||
376 |
releaseChildren |
|
377 |
"release my childrens without tests and deregistration from |
|
378 |
update task |
|
379 |
" |
|
380 |
hide := true. |
|
381 |
readChildren := true. |
|
382 |
modificationTime := nil. |
|
383 |
children := OrderedCollection new. |
|
384 |
||
385 |
||
386 |
! |
|
387 |
||
388 |
stopIndicatorValidation |
|
389 |
"called to stop indicator validation on each child |
|
390 |
" |
|
391 |
|model| |
|
392 |
||
393 |
(hide or:[children isEmpty]) ifFalse:[ |
|
394 |
(model := self model) notNil ifTrue:[ |
|
395 |
children do:[:c| c stopIndicatorValidation:model ]. |
|
396 |
model stopIndicatorValidationFor:children |
|
397 |
] |
|
398 |
] |
|
399 |
||
400 |
||
401 |
! |
|
402 |
||
403 |
stopIndicatorValidation:aModel |
|
404 |
"called to stop indicator validation on each child |
|
405 |
" |
|
406 |
(hide or:[children isEmpty]) ifFalse:[ |
|
407 |
children do:[:c| c stopIndicatorValidation:aModel ]. |
|
408 |
aModel stopIndicatorValidationFor:children |
|
409 |
] |
|
410 |
||
411 |
||
486 | 412 |
! ! |
413 |
||
901 | 414 |
!FileSelectionItem methodsFor:'protected'! |
415 |
||
416 |
isVisibleFile:aFilename isDirectory:isDirectory baseName:aBasename |
|
417 |
^ matchAction value:aFilename value:isDirectory |
|
418 |
! ! |
|
419 |
||
486 | 420 |
!FileSelectionItem methodsFor:'queries'! |
421 |
||
811 | 422 |
canReleaseChildren |
423 |
"returns true if children could be released |
|
424 |
" |
|
425 |
^ (parent notNil and:[parent parent notNil]) |
|
426 |
||
427 |
||
428 |
! |
|
429 |
||
2037 | 430 |
defaultShowSeparator |
431 |
"returns true if the separator is shown if the contents |
|
432 |
from the directory is not yet read |
|
433 |
" |
|
434 |
^ ReadDirectoriesForIndicator not |
|
435 |
! |
|
436 |
||
569 | 437 |
discardDirectories |
438 |
"returns true if children are not type of directory; could be |
|
439 |
reimplemented for speed in any subclass |
|
440 |
" |
|
441 |
^ false |
|
442 |
! |
|
443 |
||
444 |
discardFiles |
|
445 |
"returns true if children are not type of file; could be |
|
446 |
reimplemented for speed in any subclass |
|
447 |
" |
|
448 |
^ false |
|
449 |
! |
|
450 |
||
486 | 451 |
hasChildren |
452 |
"returns true if the pathname assigned to this node is a directory |
|
453 |
otherwise false |
|
454 |
" |
|
569 | 455 |
^ isDirectory |
486 | 456 |
|
457 |
! |
|
458 |
||
811 | 459 |
hasValidIndicator |
460 |
"returns true if indication flag is uptodate |
|
461 |
" |
|
2037 | 462 |
|model| |
463 |
||
464 |
showIndicator notNil ifTrue:[ |
|
465 |
^ true |
|
466 |
]. |
|
467 |
ReadDirectoriesForIndicator ifTrue:[ |
|
468 |
^ false |
|
469 |
]. |
|
811 | 470 |
|
2037 | 471 |
model := self model. |
472 |
||
473 |
model isNil ifTrue:[ |
|
474 |
^ true "/ oops, no model exist |
|
475 |
]. |
|
476 |
||
477 |
model selectedNode == self ifTrue:[ |
|
478 |
^ false "/ i'am selected, update indicator |
|
479 |
]. |
|
480 |
^ true |
|
811 | 481 |
! |
482 |
||
486 | 483 |
isDirectory |
484 |
^ isDirectory |
|
485 |
! |
|
486 |
||
569 | 487 |
releaseCollapsedChildren |
488 |
"release collapsed children |
|
489 |
" |
|
1269 | 490 |
|canCollapse| |
569 | 491 |
|
811 | 492 |
children isEmpty ifTrue:[ |
569 | 493 |
^ true |
494 |
]. |
|
495 |
canCollapse := true. |
|
496 |
||
497 |
children do:[:aChild| |
|
498 |
aChild releaseCollapsedChildren ifFalse:[ |
|
499 |
canCollapse := false |
|
500 |
] |
|
501 |
]. |
|
811 | 502 |
|
569 | 503 |
(canCollapse and:[self isExpandable]) ifTrue:[ |
811 | 504 |
self canReleaseChildren ifTrue:[ |
505 |
self releaseChildren. |
|
569 | 506 |
^ true. |
507 |
] |
|
508 |
]. |
|
509 |
^ false |
|
811 | 510 |
|
511 |
! |
|
512 |
||
513 |
setShowIndicator:aBool |
|
514 |
"set indication; raise no change notification |
|
515 |
" |
|
516 |
showIndicator := aBool. |
|
569 | 517 |
! |
518 |
||
519 |
showIndicator |
|
1154
41d487404200
only send change message if indicator changes from false->true and
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
520 |
"returns true if the node is a non-empty directory. |
41d487404200
only send change message if indicator changes from false->true and
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
521 |
This information is gathered lazily: first, false is |
41d487404200
only send change message if indicator changes from false->true and
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
522 |
returned and indicatorValidation is started for mySelf; |
41d487404200
only send change message if indicator changes from false->true and
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
523 |
this will read directories in the background to avoid |
2805 | 524 |
long startup delays (of my treeView)" |
525 |
||
811 | 526 |
|model| |
527 |
||
569 | 528 |
showIndicator isNil ifTrue:[ |
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
529 |
self directoryIsLocked ifTrue:[ |
786 | 530 |
showIndicator := readChildren := false. |
569 | 531 |
] ifFalse:[ |
811 | 532 |
(model := self model) notNil ifTrue:[ |
2037 | 533 |
ReadDirectoriesForIndicator ifFalse:[ |
534 |
^ true |
|
535 |
]. |
|
811 | 536 |
model startIndicatorValidationFor:self. |
537 |
]. |
|
538 |
^ false |
|
569 | 539 |
] |
540 |
]. |
|
541 |
^ showIndicator |
|
811 | 542 |
! |
543 |
||
544 |
showIndicator:aBool |
|
545 |
"indication might change; raise a change notification |
|
546 |
" |
|
2037 | 547 |
|oldState| |
1154
41d487404200
only send change message if indicator changes from false->true and
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
548 |
|
2037 | 549 |
(oldState := showIndicator) isNil ifTrue:[ |
550 |
oldState := self defaultShowSeparator |
|
551 |
]. |
|
1154
41d487404200
only send change message if indicator changes from false->true and
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
552 |
showIndicator := aBool. |
2037 | 553 |
|
554 |
oldState ~~ aBool ifTrue:[ |
|
555 |
self changed |
|
811 | 556 |
]. |
557 |
||
1154
41d487404200
only send change message if indicator changes from false->true and
Claus Gittinger <cg@exept.de>
parents:
1144
diff
changeset
|
558 |
"Modified: / 28.9.1998 / 11:14:30 / cg" |
569 | 559 |
! ! |
560 |
||
561 |
!FileSelectionItem methodsFor:'repair mechanism'! |
|
562 |
||
563 |
hasObsoleteNodes |
|
564 |
"check whether node or any child node is obsolete |
|
486 | 565 |
" |
569 | 566 |
modificationTime notNil ifTrue:[ |
567 |
modificationTime < contents modificationTime ifTrue:[ |
|
568 |
^ true |
|
569 |
]. |
|
2929 | 570 |
self discardDirectories ifFalse:[ |
571 |
(children contains:[:aChild | aChild hasObsoleteNodes]) ifTrue:[^ true]. |
|
569 | 572 |
] |
573 |
]. |
|
574 |
^ false |
|
575 |
! |
|
576 |
||
577 |
repairObsoleteNodes |
|
578 |
"repair nodes |
|
579 |
" |
|
1269 | 580 |
|list hasChanged| |
569 | 581 |
|
582 |
modificationTime isNil ifTrue:[ |
|
583 |
^ false |
|
493 | 584 |
]. |
569 | 585 |
|
586 |
modificationTime < contents modificationTime ifTrue:[ |
|
587 |
list := self readInChildren. |
|
588 |
hasChanged := list size ~~ children size. |
|
589 |
||
590 |
children do:[:aChild||i| |
|
591 |
i := list findFirst:[:f| f name = aChild name ]. |
|
592 |
||
593 |
i ~~ 0 ifTrue:[ |
|
594 |
list at:i put:aChild |
|
595 |
] ifFalse:[ |
|
596 |
hasChanged := true |
|
597 |
]. |
|
598 |
]. |
|
599 |
hasChanged ifTrue:[ |
|
811 | 600 |
self stopIndicatorValidation. |
569 | 601 |
children := list |
602 |
] |
|
603 |
] ifFalse:[ |
|
604 |
hasChanged := false |
|
605 |
]. |
|
606 |
children size ~~ 0 ifTrue:[ |
|
607 |
children do:[:aChild| |
|
608 |
(aChild repairObsoleteNodes) ifTrue:[hasChanged := true] |
|
609 |
] |
|
610 |
]. |
|
611 |
^ self shown ifTrue:[hasChanged] |
|
612 |
ifFalse:[false] |
|
486 | 613 |
|
811 | 614 |
|
486 | 615 |
! ! |
616 |
||
617 |
!FileSelectionItem methodsFor:'update'! |
|
618 |
||
569 | 619 |
imageType |
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
620 |
"return my icon-image type - a symbol" |
569 | 621 |
|
622 |
|readable| |
|
623 |
||
624 |
imageType isNil ifTrue:[ |
|
625 |
readable := contents isReadable. |
|
486 | 626 |
|
569 | 627 |
isDirectory ifTrue:[ |
628 |
(readable and:[contents isExecutable]) ifTrue:[ |
|
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
629 |
contents isSymbolicLink |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
630 |
ifFalse:[imageType := #directory] |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
631 |
ifTrue:[imageType := #directoryLink] |
569 | 632 |
] ifFalse:[ |
633 |
imageType := #directoryLocked |
|
634 |
] |
|
635 |
] ifFalse:[ |
|
636 |
readable ifFalse:[ |
|
637 |
imageType := #fileLocked |
|
638 |
] ifTrue:[ |
|
639 |
contents isSymbolicLink ifFalse:[ |
|
640 |
(Image isImageFileSuffix:(contents suffix)) ifFalse:[ |
|
641 |
imageType := #file |
|
642 |
] ifTrue:[ |
|
643 |
imageType := #imageFile |
|
644 |
] |
|
645 |
] ifTrue:[ |
|
646 |
imageType := #fileLink |
|
647 |
] |
|
486 | 648 |
] |
649 |
] |
|
650 |
]. |
|
569 | 651 |
^ imageType |
486 | 652 |
|
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
653 |
"Modified: / 24.9.1998 / 15:47:38 / cg" |
486 | 654 |
! |
655 |
||
569 | 656 |
readInChildren |
657 |
"read children from directory |
|
486 | 658 |
" |
1269 | 659 |
|list directory| |
569 | 660 |
|
661 |
list := OrderedCollection new. |
|
811 | 662 |
readChildren := false. |
2037 | 663 |
showIndicator := self defaultShowSeparator. |
569 | 664 |
|
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
665 |
self directoryIsLocked ifFalse:[ |
1141 | 666 |
Cursor read showWhile:[ |
811 | 667 |
directory := DirectoryContents directoryNamed:contents. |
569 | 668 |
|
811 | 669 |
directory isNil ifTrue:[ |
670 |
self stopIndicatorValidation. |
|
671 |
self releaseChildren. |
|
672 |
imageType := #directoryLocked. |
|
673 |
] ifFalse:[ |
|
674 |
modificationTime := directory modificationTime. |
|
675 |
||
901 | 676 |
directory contentsAndBaseNamesDo:[:file :bname :isDir| |
677 |
(self isVisibleFile:file isDirectory:isDir baseName:bname) ifTrue:[ |
|
1139
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
678 |
list add:(self class new |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
679 |
childFileName:file |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
680 |
baseName:bname |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
681 |
parent:self |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
682 |
isDirectory:isDir |
465a6c941877
fixes for WIN32 (network drives and drive-volumes)
Claus Gittinger <cg@exept.de>
parents:
901
diff
changeset
|
683 |
matchAction:matchAction) |
811 | 684 |
] |
685 |
]. |
|
686 |
showIndicator := list size ~~ 0. |
|
486 | 687 |
] |
569 | 688 |
] |
486 | 689 |
]. |
2422 | 690 |
list sort:[:a :b | a fileName name < b fileName name]. |
691 |
^ list |
|
811 | 692 |
|
1141 | 693 |
"Modified: / 24.9.1998 / 17:51:48 / cg" |
486 | 694 |
! ! |
695 |
||
696 |
!FileSelectionItem::Directory class methodsFor:'documentation'! |
|
697 |
||
698 |
documentation |
|
699 |
" |
|
700 |
subtype of FileSelectionItem only showing directories; more an example to show |
|
701 |
how to implement filters |
|
702 |
||
703 |
[Author:] |
|
704 |
Claus Atzkern |
|
705 |
||
706 |
[See also:] |
|
707 |
FileSelectionItem |
|
708 |
" |
|
709 |
||
710 |
! ! |
|
711 |
||
569 | 712 |
!FileSelectionItem::Directory methodsFor:'queries'! |
486 | 713 |
|
569 | 714 |
discardFiles |
715 |
^ true |
|
486 | 716 |
! ! |
717 |
||
718 |
!FileSelectionItem::File class methodsFor:'documentation'! |
|
719 |
||
720 |
documentation |
|
721 |
" |
|
722 |
subtype of FileSelectionItem only showing files; more an example to show |
|
723 |
how to implement filters |
|
724 |
||
725 |
[Author:] |
|
726 |
Claus Atzkern |
|
727 |
||
728 |
[See also:] |
|
729 |
FileSelectionItem |
|
730 |
" |
|
731 |
||
732 |
||
733 |
! ! |
|
734 |
||
569 | 735 |
!FileSelectionItem::File methodsFor:'queries'! |
486 | 736 |
|
569 | 737 |
discardDirectories |
738 |
^ true |
|
486 | 739 |
|
740 |
||
741 |
! ! |
|
742 |
||
743 |
!FileSelectionItem class methodsFor:'documentation'! |
|
744 |
||
745 |
version |
|
5283 | 746 |
^ '$Header$' |
486 | 747 |
! ! |
2422 | 748 |
|
4211
c553f879beac
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
2929
diff
changeset
|
749 |
|
2037 | 750 |
FileSelectionItem initialize! |