author | ca |
Thu, 09 Apr 1998 13:37:54 +0200 | |
changeset 849 | f7d8363fc24f |
parent 842 | 636d8a543c35 |
child 857 | d8e14b853cb7 |
permissions | -rw-r--r-- |
458 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
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 |
Model subclass:#SelectionInTree |
|
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
16 |
instanceVariableNames:'root list selection showRoot contentsAction labelAction |
811 | 17 |
childrenAction iconAction indicatorList indicatorTask accessLock' |
458 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-Support-Models' |
|
21 |
! |
|
22 |
||
23 |
!SelectionInTree class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
||
38 |
||
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
43 |
list and selection holder for hierarchical list structures. Used |
|
44 |
to buildup file-trees, class tress etc. |
|
45 |
||
46 |
Especially suited for use with SelectionInTreeView. |
|
47 |
||
48 |
[See also:] |
|
49 |
TreeItem |
|
50 |
SelectionInTreeView |
|
51 |
||
52 |
[Author:] |
|
53 |
W. Olberding |
|
54 |
Claus Atzkern |
|
55 |
" |
|
56 |
! ! |
|
57 |
||
811 | 58 |
!SelectionInTree class methodsFor:'instance creation'! |
59 |
||
60 |
new |
|
61 |
^ super new initialize |
|
62 |
! ! |
|
63 |
||
458 | 64 |
!SelectionInTree methodsFor:'accessing'! |
65 |
||
66 |
list |
|
67 |
"get list oc currently shown objects |
|
68 |
" |
|
69 |
^ list |
|
70 |
! |
|
71 |
||
72 |
root |
|
73 |
"get the root node |
|
74 |
" |
|
75 |
^ root |
|
76 |
! |
|
77 |
||
509 | 78 |
root:aRoot |
79 |
"set a new root |
|
458 | 80 |
" |
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
81 |
root notNil ifTrue: [ |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
82 |
root tree: nil |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
83 |
]. |
811 | 84 |
self stopRunningTasks. |
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
85 |
|
515 | 86 |
(root := aRoot) notNil ifTrue:[ |
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
87 |
root parent:nil. |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
88 |
root tree: self. |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
89 |
]. |
496 | 90 |
self recomputeList. |
91 |
||
92 |
! ! |
|
491 | 93 |
|
496 | 94 |
!SelectionInTree methodsFor:'accessing behavior'! |
95 |
||
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
96 |
childrenAction |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
97 |
"get children action block |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
98 |
" |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
99 |
^childrenAction |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
100 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
101 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
102 |
childrenAction:aBlock |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
103 |
"set children action block |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
104 |
" |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
105 |
childrenAction := aBlock. |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
106 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
107 |
self changed:#list. |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
108 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
109 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
110 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
111 |
contentsAction |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
112 |
"get contents action block |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
113 |
" |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
114 |
^contentsAction |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
115 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
116 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
117 |
contentsAction:aBlock |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
118 |
"set contents action block |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
119 |
" |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
120 |
contentsAction := aBlock. |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
121 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
122 |
self changed:#list. |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
123 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
124 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
125 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
126 |
iconAction |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
127 |
"get icon action block |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
128 |
" |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
129 |
^iconAction |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
130 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
131 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
132 |
iconAction:aBlock |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
133 |
"set icon action block |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
134 |
" |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
135 |
iconAction := aBlock. |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
136 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
137 |
self changed:#list. |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
138 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
139 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
140 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
141 |
labelAction |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
142 |
"get label action block |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
143 |
" |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
144 |
^labelAction |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
145 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
146 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
147 |
labelAction:aBlock |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
148 |
"set label action block |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
149 |
" |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
150 |
labelAction := aBlock. |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
151 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
152 |
self changed:#list. |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
153 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
154 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
155 |
|
496 | 156 |
showRoot |
157 |
"list with or without root |
|
158 |
" |
|
159 |
^ showRoot |
|
491 | 160 |
! |
161 |
||
496 | 162 |
showRoot:aState |
163 |
"list with or without root |
|
491 | 164 |
" |
496 | 165 |
aState ~~ showRoot ifTrue:[ |
166 |
showRoot := aState. |
|
491 | 167 |
|
496 | 168 |
root notNil ifTrue:[ |
169 |
aState ifTrue:[list addFirst:root] |
|
170 |
ifFalse:[list removeFirst]. |
|
491 | 171 |
|
496 | 172 |
self changed:#list. |
491 | 173 |
]. |
174 |
]. |
|
458 | 175 |
! ! |
176 |
||
177 |
!SelectionInTree methodsFor:'accessing hierarchy'! |
|
178 |
||
179 |
collapse:something |
|
180 |
"collapse a node or collection of nodes |
|
181 |
" |
|
182 |
|invalidate| |
|
183 |
||
184 |
self each:something do:[:aNode| |
|
185 |
aNode isCollapsable ifTrue:[ |
|
186 |
aNode collapse. |
|
187 |
invalidate := true |
|
188 |
] |
|
189 |
]. |
|
190 |
invalidate == true ifTrue:[self recomputeList] |
|
191 |
! |
|
192 |
||
509 | 193 |
expand |
194 |
"expand the root |
|
195 |
" |
|
196 |
self expand:root |
|
197 |
! |
|
198 |
||
458 | 199 |
expand:something |
200 |
"expand a node or collection of nodes |
|
201 |
" |
|
202 |
|invalidate| |
|
203 |
||
204 |
self each:something do:[:aNode| |
|
205 |
aNode isExpandable ifTrue:[ |
|
206 |
aNode expand. |
|
207 |
invalidate := true |
|
208 |
] |
|
209 |
]. |
|
210 |
invalidate == true ifTrue:[self recomputeList] |
|
211 |
! ! |
|
212 |
||
213 |
!SelectionInTree methodsFor:'adding & removing'! |
|
214 |
||
215 |
add:something after:aChild |
|
216 |
"add a node or collection of nodes to parent after a child |
|
217 |
" |
|
218 |
"add a node or collection of nodes to after a child |
|
219 |
" |
|
220 |
aChild notNil ifTrue:[ |
|
221 |
aChild parent add:something after:aChild. |
|
222 |
self recomputeList |
|
223 |
] |
|
224 |
! |
|
225 |
||
226 |
add:something afterIndex:anIndex below:aParent |
|
227 |
"add a node or collection of nodes to parent after an index |
|
228 |
" |
|
229 |
aParent add:something afterIndex:anIndex. |
|
230 |
self recomputeList |
|
231 |
||
232 |
! |
|
233 |
||
234 |
add:something before:aChild |
|
235 |
"add a node or collection of nodes to before a child |
|
236 |
" |
|
237 |
aChild notNil ifTrue:[ |
|
238 |
aChild parent add:something before:aChild. |
|
239 |
self recomputeList |
|
240 |
] |
|
241 |
! |
|
242 |
||
243 |
add:something beforeIndex:anIndex below:aParent |
|
244 |
"add a node or collection of nodes to parent before an index |
|
245 |
" |
|
246 |
aParent add:something beforeIndex:anIndex. |
|
247 |
self recomputeList |
|
248 |
||
249 |
! |
|
250 |
||
251 |
add:something below:aParent |
|
252 |
"add a node or collection of nodes to parent |
|
253 |
" |
|
254 |
aParent add:something. |
|
255 |
self recomputeList |
|
256 |
||
257 |
! |
|
258 |
||
259 |
remove:something |
|
260 |
"remove a node or collection of nodes |
|
261 |
" |
|
262 |
|invalidate| |
|
263 |
||
264 |
self each:something do:[:aNode| |
|
811 | 265 |
self stopIndicatorValidationFor:aNode. |
266 |
||
458 | 267 |
aNode parent notNil ifTrue:[ |
268 |
aNode parent remove:aNode. |
|
269 |
invalidate := true |
|
270 |
] |
|
271 |
]. |
|
272 |
invalidate == true ifTrue:[self recomputeList]. |
|
273 |
^ something |
|
811 | 274 |
|
458 | 275 |
! |
276 |
||
277 |
removeIndex:something |
|
278 |
"remove a node at index or collection of indexed nodes |
|
279 |
" |
|
280 |
|invalidate node| |
|
281 |
||
282 |
something isCollection ifFalse:[ |
|
283 |
(something isNil or:[something == 0]) ifFalse:[ |
|
284 |
^ self remove:(list at:something) |
|
285 |
]. |
|
286 |
^ nil |
|
287 |
]. |
|
288 |
||
289 |
(SortedCollection withAll:something) reverseDo:[:anIndex| |
|
290 |
node := list at:anIndex. |
|
811 | 291 |
self stopIndicatorValidationFor:node. |
458 | 292 |
|
293 |
node parent notNil ifTrue:[ |
|
294 |
node parent remove:node. |
|
295 |
invalidate := true |
|
296 |
] |
|
297 |
]. |
|
298 |
invalidate == true ifTrue:[self recomputeList]. |
|
811 | 299 |
|
458 | 300 |
! |
301 |
||
302 |
removeSelection |
|
303 |
"remove selected nodes |
|
304 |
" |
|
305 |
self removeIndex:(self selectionIndex). |
|
306 |
self selectionIndex:nil |
|
307 |
! ! |
|
308 |
||
758 | 309 |
!SelectionInTree methodsFor:'change & update'! |
310 |
||
311 |
invalidate |
|
312 |
"called; something changed what requires a redraw but no recomputation. |
|
313 |
for example a name |
|
314 |
" |
|
315 |
self dependents do:[:aDependent| |
|
316 |
aDependent isView ifTrue:[ aDependent invalidate ] |
|
317 |
]. |
|
318 |
||
319 |
||
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
320 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
321 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
322 |
update:something with:aParameter from:aModel |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
323 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
324 |
self dependents do:[:aDependent| |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
325 |
aDependent update:something with:aParameter from:aModel |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
326 |
] |
758 | 327 |
! ! |
328 |
||
458 | 329 |
!SelectionInTree methodsFor:'enumerating'! |
330 |
||
331 |
each:something do:aBlock |
|
332 |
"evaluate a block for something or in case of a collection for each |
|
333 |
element in the collection |
|
334 |
" |
|
335 |
something notNil ifTrue:[ |
|
336 |
something isCollection ifTrue:[something do:[:el|aBlock value:el]] |
|
337 |
ifFalse:[aBlock value:something] |
|
338 |
] |
|
339 |
||
340 |
! ! |
|
341 |
||
496 | 342 |
!SelectionInTree methodsFor:'initialization'! |
343 |
||
344 |
initialize |
|
811 | 345 |
|
346 |
showRoot := true. |
|
347 |
indicatorList := OrderedCollection new. |
|
348 |
accessLock := Semaphore forMutualExclusion. |
|
842 | 349 |
list := OrderedCollection new:128. |
496 | 350 |
super initialize. |
811 | 351 |
|
496 | 352 |
! ! |
353 |
||
458 | 354 |
!SelectionInTree methodsFor:'private'! |
355 |
||
356 |
recomputeList |
|
357 |
"Travers the tree and build a new list." |
|
358 |
||
842 | 359 |
list clearContents. |
458 | 360 |
|
361 |
root notNil ifTrue:[ |
|
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
362 |
showRoot ifTrue:[ |
496 | 363 |
list add:root |
364 |
]. |
|
842 | 365 |
root recomputeList:list. |
458 | 366 |
]. |
585 | 367 |
self changed:#list. |
458 | 368 |
! ! |
369 |
||
849 | 370 |
!SelectionInTree methodsFor:'searching'! |
371 |
||
372 |
detectItem:aOneArgBlock |
|
373 |
"detect an item the evaluation of the block returns true. The |
|
374 |
argument to the block is the item. |
|
375 |
" |
|
376 |
root notNil ifTrue:[ |
|
377 |
^ root detectChild:aOneArgBlock |
|
378 |
]. |
|
379 |
^ nil |
|
380 |
||
381 |
||
382 |
! |
|
383 |
||
384 |
detectItem:aTwoArgBlock arguments:aListOfArgs |
|
385 |
"detect an item the evaluation of the block returns true. The |
|
386 |
first argument to the block is the item, the second argument |
|
387 |
the value derived from the argument list at an index |
|
388 |
" |
|
389 |
root notNil ifTrue:[ |
|
390 |
^ root detectChild:aTwoArgBlock arguments:aListOfArgs index:1 |
|
391 |
]. |
|
392 |
^ nil |
|
393 |
||
394 |
||
395 |
! ! |
|
396 |
||
458 | 397 |
!SelectionInTree methodsFor:'selection'! |
398 |
||
399 |
selection |
|
400 |
"get the selection or nil |
|
401 |
" |
|
402 |
^ self selectionIndex |
|
403 |
! |
|
404 |
||
405 |
selection:indexesOrNil |
|
406 |
"set the selection |
|
407 |
" |
|
408 |
self selectionIndex:indexesOrNil |
|
409 |
! |
|
410 |
||
411 |
selectionIndex |
|
412 |
"get the selection or nil |
|
413 |
" |
|
414 |
^ selection |
|
415 |
! |
|
416 |
||
417 |
selectionIndex:indexesOrNil |
|
418 |
"set the selection |
|
419 |
" |
|
496 | 420 |
|oldSel| |
421 |
||
422 |
oldSel := selection. |
|
423 |
self setSelectionIndex:indexesOrNil. |
|
424 |
||
425 |
oldSel = selection ifFalse:[ |
|
585 | 426 |
self changed:#selectionIndex |
496 | 427 |
] |
428 |
! |
|
429 |
||
430 |
setSelection:indexesOrNil |
|
431 |
"set the selection without raising a notification |
|
432 |
" |
|
433 |
self setSelectionIndex:indexesOrNil |
|
434 |
! |
|
435 |
||
436 |
setSelectionIndex:indexesOrNil |
|
437 |
"set the selection without raising a notification |
|
438 |
" |
|
458 | 439 |
|indexes| |
440 |
||
441 |
indexes := indexesOrNil. |
|
442 |
||
443 |
indexes size == 0 ifTrue:[ |
|
444 |
(indexes isCollection or:[indexes == 0]) ifTrue:[ |
|
445 |
indexes := nil |
|
446 |
] |
|
447 |
]. |
|
496 | 448 |
selection := indexes |
458 | 449 |
|
450 |
! ! |
|
451 |
||
811 | 452 |
!SelectionInTree methodsFor:'update indication task'! |
453 |
||
454 |
startIndicatorValidationFor:aNode |
|
455 |
"add a node to list of updating indications |
|
456 |
" |
|
457 |
|index| |
|
458 |
||
459 |
accessLock critical:[ |
|
460 |
index := indicatorList identityIndexOf:aNode. |
|
461 |
||
462 |
index ~~ 0 ifTrue:[ |
|
463 |
indicatorList removeIndex:index. "/ reorganize list to be faster |
|
464 |
]. |
|
465 |
indicatorList addFirst:aNode. |
|
466 |
||
467 |
indicatorTask isNil ifTrue:[ |
|
468 |
indicatorTask := [ |
|
469 |
[ self taskCycle ] whileTrue:[ Processor yield ] |
|
470 |
] forkAt:(Processor activePriority - 1) |
|
471 |
] |
|
472 |
]. |
|
473 |
! |
|
474 |
||
475 |
stopIndicatorValidationFor:aNodeOrList |
|
476 |
"remove a node or list of nodes from list of updating indications |
|
477 |
" |
|
478 |
accessLock critical:[ |
|
479 |
aNodeOrList isCollection ifTrue:[ |
|
480 |
aNodeOrList do:[:aNode| |
|
481 |
indicatorList removeIdentical:aNode ifAbsent:nil |
|
482 |
] |
|
483 |
] ifFalse:[ |
|
484 |
indicatorList removeIdentical:aNodeOrList ifAbsent:nil |
|
485 |
] |
|
486 |
] |
|
487 |
||
488 |
||
489 |
! |
|
490 |
||
491 |
stopRunningTasks |
|
492 |
"stop task |
|
493 |
" |
|
494 |
accessLock critical:[ indicatorList removeAll ] |
|
495 |
||
496 |
! |
|
497 |
||
498 |
taskCycle |
|
499 |
"run one cycle |
|
500 |
" |
|
501 |
|node| |
|
502 |
||
503 |
accessLock critical:[ |
|
504 |
indicatorList isEmpty ifTrue:[ "/ queue is empty; terminate task |
|
505 |
indicatorTask := nil. |
|
506 |
^ false |
|
507 |
]. |
|
508 |
node := indicatorList removeFirst. "/ run task on first node |
|
509 |
||
510 |
node hasValidIndicator ifTrue:[ "/ up to date |
|
511 |
^ true |
|
512 |
]. |
|
513 |
node setShowIndicator:false "/ disable registry |
|
514 |
]. |
|
515 |
||
516 |
(DirectoryContents directoryNamed:(node fileName) detect:(node matchAction)) ifTrue:[ |
|
517 |
node showIndicator:true |
|
518 |
]. |
|
519 |
^ true |
|
520 |
! ! |
|
521 |
||
458 | 522 |
!SelectionInTree class methodsFor:'documentation'! |
523 |
||
524 |
version |
|
849 | 525 |
^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTree.st,v 1.12 1998-04-09 11:37:54 ca Exp $' |
458 | 526 |
! ! |