author | penk |
Wed, 11 Sep 2002 14:54:54 +0200 | |
changeset 2180 | d01612ed451e |
parent 2140 | 7dfe3b338437 |
child 2223 | c34e7fd25e53 |
permissions | -rw-r--r-- |
1431 | 1 |
" |
2 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
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 |
||
1780 | 14 |
"{ Package: 'stx:libwidg2' }" |
15 |
||
1390 | 16 |
HierarchicalList subclass:#HierarchicalFileList |
2180 | 17 |
instanceVariableNames:'matchBlock showCursor' |
2138 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Views-Support' |
|
1390 | 21 |
! |
22 |
||
23 |
HierarchicalItem subclass:#File |
|
2138 | 24 |
instanceVariableNames:'fileName icon' |
25 |
classVariableNames:'' |
|
26 |
poolDictionaries:'' |
|
27 |
privateIn:HierarchicalFileList |
|
1390 | 28 |
! |
29 |
||
30 |
HierarchicalFileList::File subclass:#Directory |
|
2138 | 31 |
instanceVariableNames:'modificationTime' |
32 |
classVariableNames:'' |
|
33 |
poolDictionaries:'' |
|
34 |
privateIn:HierarchicalFileList::File |
|
1390 | 35 |
! |
36 |
||
1431 | 37 |
!HierarchicalFileList class methodsFor:'documentation'! |
38 |
||
39 |
copyright |
|
40 |
" |
|
41 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
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 |
! ! |
|
1390 | 53 |
|
54 |
!HierarchicalFileList class methodsFor:'examples'! |
|
55 |
||
2180 | 56 |
examples |
2130 | 57 |
" |
2180 | 58 |
[exBegin] |
2130 | 59 |
|top sel list| |
1390 | 60 |
|
61 |
list := HierarchicalFileList new. |
|
62 |
list directory:(Filename homeDirectory). |
|
63 |
list showRoot:false. |
|
2130 | 64 |
list matchBlock:[:fn :isDir| true ]. |
1390 | 65 |
|
66 |
top := StandardSystemView new; extent:300@300. |
|
67 |
sel := ScrollableView for:HierarchicalListView miniScroller:true |
|
68 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
69 |
||
70 |
sel list:list. |
|
71 |
list root expand. |
|
72 |
||
73 |
sel doubleClickAction:[:i| (list at:i) toggleExpand ]. |
|
74 |
sel indicatorAction:[:i| (list at:i) toggleExpand ]. |
|
75 |
||
76 |
top open. |
|
2180 | 77 |
[exEnd] |
78 |
" |
|
1390 | 79 |
! ! |
80 |
||
81 |
!HierarchicalFileList methodsFor:'accessing'! |
|
82 |
||
83 |
directory |
|
84 |
"returns the root directory or nil |
|
85 |
" |
|
86 |
^ root notNil ifTrue:[root fileName] ifFalse:[nil] |
|
87 |
||
88 |
! |
|
89 |
||
90 |
directory:aDirectory |
|
91 |
"set the root directory or nil |
|
92 |
" |
|
93 |
|directory| |
|
94 |
||
1960
2363303c1c8c
monitoring must be enebled by user (no longer automatically)
ca
parents:
1867
diff
changeset
|
95 |
"/ must explicitly enabled by user: ca |
2363303c1c8c
monitoring must be enebled by user (no longer automatically)
ca
parents:
1867
diff
changeset
|
96 |
"/ monitoringTaskDelay := 1. |
1390 | 97 |
|
98 |
(aDirectory notNil and:[(directory := aDirectory asFilename) exists]) ifTrue:[ |
|
99 |
directory isDirectory ifFalse:[ |
|
100 |
directory := directory directory |
|
101 |
] |
|
102 |
] ifFalse:[ |
|
103 |
directory := nil |
|
104 |
]. |
|
105 |
||
106 |
directory = self directory ifFalse:[ |
|
107 |
directory notNil ifTrue:[ |
|
108 |
directory := File fileName:directory isDirectory:true |
|
109 |
]. |
|
110 |
self root:directory |
|
111 |
]. |
|
112 |
! ! |
|
113 |
||
114 |
!HierarchicalFileList methodsFor:'actions'! |
|
115 |
||
116 |
matchBlock |
|
117 |
"set the matchBlock - if non-nil, it controls which files are visible. |
|
118 |
" |
|
119 |
^ matchBlock |
|
120 |
||
121 |
! |
|
122 |
||
123 |
matchBlock:aBlock |
|
124 |
"set the matchBlock - if non-nil, it controls which files are visible. |
|
125 |
" |
|
126 |
matchBlock := aBlock. |
|
1866 | 127 |
|
128 |
root notNil ifTrue:[ |
|
1867 | 129 |
self recursionLock critical:[ |
130 |
self stopMonitoringTask. |
|
131 |
root matchBlockChanged. |
|
132 |
]. |
|
133 |
self startMonitoringTask. |
|
1866 | 134 |
]. |
1867 | 135 |
|
1390 | 136 |
! ! |
137 |
||
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
138 |
!HierarchicalFileList methodsFor:'private monitoring task'! |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
139 |
|
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
140 |
monitoringCycle |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
141 |
"the block evaluated by the monitoring task; test whether directory is expanded |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
142 |
otherwise we have not to evaluate the directory contents. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
143 |
think about remote file-systems |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
144 |
" |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
145 |
|index item| |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
146 |
|
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
147 |
item := root. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
148 |
index := showRoot ifTrue:[1] ifFalse:[0]. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
149 |
|
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
150 |
[item notNil] whileTrue:[ |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
151 |
(item isDirectory and:[item getChildren notNil]) ifTrue:[ |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
152 |
"/ children already initialized; thus we can update the contents |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
153 |
item monitoringCycle |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
154 |
]. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
155 |
Processor yield. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
156 |
index := index + 1. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
157 |
item := self at:index ifAbsent:nil. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
158 |
]. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
159 |
! ! |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
160 |
|
1390 | 161 |
!HierarchicalFileList methodsFor:'protocol'! |
162 |
||
163 |
childrenFor:anItem |
|
164 |
"returns all visible children derived from the physical |
|
165 |
directory contents. |
|
166 |
" |
|
167 |
|contents list block| |
|
168 |
||
2130 | 169 |
anItem isDirectory ifFalse:[^ #()]. |
1390 | 170 |
|
1581 | 171 |
contents := DirectoryContents directoryNamed:(anItem fileName). |
2130 | 172 |
contents ifNil:[ ^ #() ]. |
1390 | 173 |
|
174 |
||
2130 | 175 |
list := SortedCollection sortBlock:[:a :b| |res| |
176 |
a isDirectory == b isDirectory ifTrue:[ res := a baseName <= b baseName ] |
|
177 |
ifFalse:[ res := a isDirectory ]. |
|
178 |
res |
|
179 |
]. |
|
180 |
block := self matchBlockFor:anItem. |
|
181 |
||
182 |
block isNil ifTrue:[ |
|
183 |
contents contentsDo:[:fn :isDir| |
|
184 |
list add:(File fileName:fn isDirectory:isDir) |
|
185 |
] |
|
186 |
] ifFalse:[ |
|
187 |
contents contentsDo:[:fn :isDir| |
|
188 |
(block value:fn value:isDir) ifTrue:[ |
|
1581 | 189 |
list add:(File fileName:fn isDirectory:isDir) |
190 |
] |
|
1390 | 191 |
] |
192 |
]. |
|
2130 | 193 |
list isEmpty ifTrue:[^ #()]. |
194 |
^ list asOrderedCollection |
|
1390 | 195 |
! |
196 |
||
197 |
hasChildrenFor:anItem |
|
198 |
"returns true if the physical directory contains at least |
|
199 |
one visible item otherwise false. |
|
200 |
" |
|
201 |
|block| |
|
202 |
||
203 |
anItem isDirectory ifFalse:[ |
|
204 |
^ false |
|
205 |
]. |
|
206 |
||
207 |
(block := self matchBlockFor:anItem) isNil ifTrue:[ |
|
208 |
block := [:aFilename :isDirectory| true ] |
|
209 |
]. |
|
210 |
^ DirectoryContents directoryNamed:(anItem fileName) detect:block |
|
211 |
! |
|
212 |
||
213 |
iconFor:anItem |
|
214 |
"returns the icon for an item |
|
215 |
" |
|
216 |
||
2180 | 217 |
(anItem isExpanded and:[anItem hasChildren]) ifTrue:[ |
218 |
^ FileBrowser iconForKeyMatching:#directoryOpen |
|
1390 | 219 |
]. |
2180 | 220 |
^ FileBrowser iconForFile:(anItem fileName) |
1390 | 221 |
! |
222 |
||
223 |
matchBlockFor:anItem |
|
224 |
"get the matchBlock - if non-nil, it controls which files are |
|
225 |
visible within the physical directory |
|
226 |
" |
|
227 |
^ matchBlock |
|
2095 | 228 |
! |
229 |
||
230 |
validateIcon:anIcon for:anItem |
|
231 |
^ anIcon |
|
1390 | 232 |
! ! |
233 |
||
1581 | 234 |
!HierarchicalFileList methodsFor:'searching'! |
235 |
||
236 |
detectItemFor:aPathOrFilename |
|
237 |
"make a filename visible |
|
238 |
" |
|
239 |
|file node p1 p2 sz| |
|
240 |
||
1582 | 241 |
aPathOrFilename isNil ifTrue:[^ nil]. |
1581 | 242 |
|
243 |
file := aPathOrFilename asFilename. |
|
244 |
||
245 |
file exists ifFalse:[ |
|
1582 | 246 |
^ nil |
1581 | 247 |
]. |
1582 | 248 |
(node := root) isNil ifTrue:[^ nil]. |
1581 | 249 |
|
250 |
p1 := node pathName. |
|
251 |
p2 := file pathName. |
|
252 |
||
1582 | 253 |
(p2 startsWith:p1) ifFalse:[^ nil]. |
1581 | 254 |
sz := 1 + p1 size. |
255 |
||
256 |
(p1 last == Filename separator) ifFalse:[ |
|
257 |
sz := sz + 1. |
|
258 |
]. |
|
259 |
||
1582 | 260 |
p2 size > sz ifFalse:[^ nil]. |
1581 | 261 |
|
262 |
p2 := Filename components:(p2 copyFrom:sz). |
|
263 |
||
264 |
p2 do:[:bn| |
|
265 |
node := node detect:[:el| el baseName = bn] ifNone:nil. |
|
266 |
node isNil ifTrue:[^ nil ]. |
|
267 |
]. |
|
268 |
^ node |
|
269 |
! ! |
|
270 |
||
1390 | 271 |
!HierarchicalFileList::File class methodsFor:'instance creation'! |
272 |
||
273 |
fileName:aFileName isDirectory:isDirectory |
|
274 |
"instance creation |
|
275 |
" |
|
276 |
|item| |
|
277 |
||
278 |
item := isDirectory ifTrue:[Directory new] ifFalse:[HierarchicalFileList::File new]. |
|
279 |
item fileName:aFileName. |
|
280 |
^ item |
|
281 |
||
282 |
! ! |
|
283 |
||
284 |
!HierarchicalFileList::File methodsFor:'accessing'! |
|
285 |
||
286 |
baseName |
|
287 |
"returns the baseName |
|
288 |
" |
|
2138 | 289 |
^ fileName baseName. |
290 |
"/ ^ baseName |
|
1390 | 291 |
! |
292 |
||
293 |
children |
|
294 |
"always returns an empty list |
|
295 |
" |
|
296 |
^ #() |
|
297 |
! |
|
298 |
||
299 |
fileName |
|
300 |
"returns the fileName |
|
301 |
" |
|
302 |
^ fileName |
|
303 |
||
304 |
||
305 |
! |
|
306 |
||
307 |
fileName:fname |
|
308 |
"instance creation |
|
309 |
" |
|
310 |
fileName := fname. |
|
2138 | 311 |
"/ baseName := fname baseName. |
1390 | 312 |
! |
313 |
||
314 |
icon |
|
315 |
"returns the icon key |
|
316 |
" |
|
317 |
|model| |
|
318 |
||
2095 | 319 |
model := self model. |
320 |
model ifNil:[^ nil]. |
|
321 |
||
1390 | 322 |
icon isNil ifTrue:[ |
2095 | 323 |
icon := model iconFor:self |
1390 | 324 |
]. |
2095 | 325 |
^ model validateIcon:icon for:self |
1390 | 326 |
! |
327 |
||
328 |
label |
|
329 |
"returns the printable name, the baseName |
|
330 |
" |
|
2138 | 331 |
^ self baseName |
1390 | 332 |
! |
333 |
||
334 |
pathName |
|
335 |
"returns the pathName |
|
336 |
" |
|
337 |
^ fileName pathName |
|
338 |
! ! |
|
339 |
||
340 |
!HierarchicalFileList::File methodsFor:'accessing hierarchy'! |
|
341 |
||
342 |
recursiveExpand |
|
343 |
"redefined to expand |
|
344 |
" |
|
345 |
self expand |
|
346 |
||
347 |
||
348 |
! ! |
|
349 |
||
350 |
!HierarchicalFileList::File methodsFor:'invalidate'! |
|
351 |
||
352 |
invalidate |
|
353 |
"invalidate the contents |
|
354 |
" |
|
355 |
self invalidateRepairNow:false |
|
356 |
||
357 |
! |
|
358 |
||
359 |
invalidateRepairNow |
|
360 |
"invalidate the contents; repair now |
|
361 |
" |
|
362 |
self invalidateRepairNow:true |
|
363 |
||
364 |
! |
|
365 |
||
366 |
invalidateRepairNow:doRepair |
|
367 |
"invalidate the contents; dependent on the boolean |
|
368 |
do repair immediately |
|
369 |
" |
|
370 |
||
371 |
||
1866 | 372 |
! |
373 |
||
374 |
matchBlockChanged |
|
375 |
"called if the matchBlock changed |
|
376 |
" |
|
377 |
||
1390 | 378 |
! ! |
379 |
||
2127 | 380 |
!HierarchicalFileList::File methodsFor:'printing'! |
381 |
||
382 |
printString |
|
383 |
||
384 |
^ super printString, ' for: ', self fileName asString |
|
385 |
! ! |
|
386 |
||
1390 | 387 |
!HierarchicalFileList::File methodsFor:'queries'! |
388 |
||
389 |
hasChildren |
|
390 |
"always returns false |
|
391 |
" |
|
392 |
^ false |
|
393 |
! |
|
394 |
||
395 |
isDirectory |
|
396 |
"always returns false |
|
397 |
" |
|
398 |
^ false |
|
399 |
||
400 |
! ! |
|
401 |
||
402 |
!HierarchicalFileList::File::Directory methodsFor:'accessing'! |
|
403 |
||
404 |
children |
|
405 |
"returns the list of children |
|
406 |
" |
|
407 |
|model list| |
|
408 |
||
1867 | 409 |
children notNil ifTrue:[ |
410 |
^ children |
|
411 |
]. |
|
1390 | 412 |
|
1867 | 413 |
(model := self model) isNil ifTrue:[ |
414 |
"/ must reread later |
|
415 |
modificationTime := children := nil. |
|
416 |
^ nil |
|
417 |
]. |
|
1390 | 418 |
|
1867 | 419 |
children := #(). |
420 |
modificationTime := fileName modificationTime. |
|
421 |
list := model childrenFor:self. |
|
422 |
||
423 |
list size ~~ 0 ifTrue:[ |
|
424 |
list do:[:aChild| aChild parent:self]. |
|
425 |
children := list. |
|
1390 | 426 |
]. |
427 |
^ children |
|
428 |
! |
|
429 |
||
430 |
icon |
|
2140 | 431 |
"reset first and returns the new icon |
1390 | 432 |
" |
2140 | 433 |
icon := nil. |
1390 | 434 |
^ super icon |
435 |
! ! |
|
436 |
||
2104
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
437 |
!HierarchicalFileList::File::Directory methodsFor:'accessing-hierarchy'! |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
438 |
|
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
439 |
expand |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
440 |
"expand children; must redefine to raise a notification |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
441 |
if children are not yet initialized and after initialization empty. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
442 |
" |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
443 |
|notInit| |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
444 |
|
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
445 |
notInit := children isNil. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
446 |
super expand. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
447 |
|
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
448 |
notInit ifTrue:[ |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
449 |
(children notNil and:[children isEmpty]) ifTrue:[ |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
450 |
"/ no children exists |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
451 |
"/ indicator +/- has changed to unexistant |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
452 |
self changed:#redraw |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
453 |
] |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
454 |
]. |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
455 |
! ! |
327f2f77ec12
support remote file-systems (not reading contents of directory if not yet initialized)
ca
parents:
2095
diff
changeset
|
456 |
|
1390 | 457 |
!HierarchicalFileList::File::Directory methodsFor:'queries'! |
458 |
||
459 |
hasChildren |
|
460 |
"returns true if children exists |
|
461 |
" |
|
462 |
^ children isNil or:[children notEmpty] |
|
463 |
! |
|
464 |
||
465 |
isDirectory |
|
466 |
"always returns true |
|
467 |
" |
|
468 |
^ true |
|
469 |
||
470 |
||
471 |
! ! |
|
472 |
||
473 |
!HierarchicalFileList::File::Directory methodsFor:'validation'! |
|
474 |
||
475 |
invalidateRepairNow:doRepair |
|
476 |
"invalidate contents |
|
477 |
" |
|
478 |
modificationTime := nil. |
|
479 |
||
480 |
doRepair ifTrue:[ |
|
481 |
self monitoringCycle |
|
482 |
] ifFalse:[ |
|
483 |
(isExpanded or:[children size == 0]) ifFalse:[ |
|
484 |
children := nil |
|
485 |
] |
|
486 |
]. |
|
487 |
||
488 |
! |
|
489 |
||
1866 | 490 |
matchBlockChanged |
491 |
"called if the matchBlock changed |
|
492 |
" |
|
493 |
modificationTime := nil. |
|
494 |
||
495 |
isExpanded ifFalse:[ |
|
496 |
children := nil. |
|
1867 | 497 |
] ifTrue:[ |
498 |
self monitoringCycle. |
|
1866 | 499 |
|
1867 | 500 |
children size ~~ 0 ifTrue:[ |
501 |
children do:[:aChild| aChild matchBlockChanged ] |
|
502 |
] |
|
1866 | 503 |
]. |
504 |
! |
|
505 |
||
1390 | 506 |
monitoringCycle |
507 |
"run monitoring cycle |
|
508 |
" |
|
509 |
|list size name modifyTime isNotEmpty wasNotEmpty model| |
|
510 |
||
511 |
modifyTime := fileName modificationTime. |
|
512 |
||
513 |
(modificationTime notNil and:[modifyTime <= modificationTime]) ifTrue:[ |
|
514 |
^ self |
|
515 |
]. |
|
516 |
model := self model. |
|
517 |
modificationTime := modifyTime. |
|
518 |
||
519 |
isExpanded ifFalse:[ |
|
520 |
||
521 |
"/ CHECK WHETHER CHILDREN EXIST( INDICATOR ) |
|
522 |
"/ ========================================= |
|
523 |
||
524 |
isNotEmpty := model hasChildrenFor:self. |
|
525 |
||
526 |
"/ check whether has changed durring evaluation |
|
527 |
(isExpanded or:[modificationTime ~= modifyTime]) ifFalse:[ |
|
528 |
wasNotEmpty := children isNil. |
|
529 |
children := isNotEmpty ifTrue:[nil] ifFalse:[#()]. |
|
530 |
||
531 |
wasNotEmpty ~~ isNotEmpty ifTrue:[ |
|
532 |
self changed |
|
533 |
] |
|
534 |
]. |
|
535 |
^ self |
|
536 |
||
537 |
]. |
|
538 |
||
539 |
"/ START MERGING( CONTENTS IS VISIBLE ) |
|
540 |
"/ ==================================== |
|
541 |
||
542 |
list := model childrenFor:self. |
|
543 |
||
544 |
list size == 0 ifTrue:[ "/ contents becomes empty |
|
545 |
^ self removeAll "/ clear contents |
|
546 |
]. |
|
547 |
(size := children size) == 0 ifTrue:[ "/ old contents was empty |
|
548 |
^ self addAll:list. "/ take over new contents |
|
549 |
]. |
|
550 |
||
551 |
size to:1 by:-1 do:[:anIndex| "/ remove invisible items |
|
552 |
name := (children at:anIndex) baseName. |
|
553 |
||
554 |
(list findFirst:[:i|i baseName = name]) == 0 ifTrue:[ |
|
555 |
self removeIndex:anIndex |
|
556 |
] |
|
557 |
]. |
|
558 |
||
559 |
list keysAndValuesDo:[:anIndex :anItem| "/ add new visible items |
|
560 |
name := anItem baseName. |
|
561 |
||
562 |
(children findFirst:[:i|i baseName = name]) == 0 ifTrue:[ |
|
563 |
self add:anItem beforeIndex:anIndex |
|
564 |
] |
|
565 |
]. |
|
566 |
! ! |
|
567 |
||
568 |
!HierarchicalFileList class methodsFor:'documentation'! |
|
569 |
||
570 |
version |
|
2180 | 571 |
^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalFileList.st,v 1.18 2002-09-11 12:54:54 penk Exp $' |
1390 | 572 |
! ! |