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