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