author | Claus Gittinger <cg@exept.de> |
Wed, 13 Mar 2019 10:30:41 +0100 | |
changeset 6035 | 1f975ac0771e |
parent 5667 | a213756b3b4d |
child 6156 | 2f7f8fc3abe1 |
permissions | -rw-r--r-- |
5667 | 1 |
"{ Encoding: utf8 }" |
2 |
||
458 | 3 |
" |
4 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
1818 | 14 |
"{ Package: 'stx:libwidg2' }" |
15 |
||
4941 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
458 | 18 |
Model subclass:#SelectionInTree |
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
19 |
instanceVariableNames:'root list selection showRoot contentsAction labelAction |
811 | 20 |
childrenAction iconAction indicatorList indicatorTask accessLock' |
458 | 21 |
classVariableNames:'' |
22 |
poolDictionaries:'' |
|
23 |
category:'Interface-Support-Models' |
|
24 |
! |
|
25 |
||
26 |
!SelectionInTree class methodsFor:'documentation'! |
|
27 |
||
28 |
copyright |
|
29 |
" |
|
30 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
31 |
All Rights Reserved |
|
32 |
||
33 |
This software is furnished under a license and may be used |
|
34 |
only in accordance with the terms of that license and with the |
|
35 |
inclusion of the above copyright notice. This software may not |
|
36 |
be provided or otherwise made available to, or used by, any |
|
37 |
other person. No title to or ownership of the software is |
|
38 |
hereby transferred. |
|
39 |
" |
|
40 |
||
41 |
||
42 |
! |
|
43 |
||
44 |
documentation |
|
45 |
" |
|
5452 | 46 |
list and selection holder for hierarchical list structures. |
47 |
Used to buildup file-trees, class trees etc. |
|
458 | 48 |
|
49 |
Especially suited for use with SelectionInTreeView. |
|
50 |
||
5452 | 51 |
Notice: this class replaces SelectionInHierarchy, |
52 |
which provides similar (but less sophisticated) functionality. |
|
1189 | 53 |
|
458 | 54 |
[See also:] |
55 |
TreeItem |
|
56 |
SelectionInTreeView |
|
5452 | 57 |
SelectionInHierarchy |
458 | 58 |
|
59 |
[Author:] |
|
60 |
W. Olberding |
|
61 |
Claus Atzkern |
|
62 |
" |
|
63 |
! ! |
|
64 |
||
811 | 65 |
!SelectionInTree class methodsFor:'instance creation'! |
66 |
||
67 |
new |
|
2840 | 68 |
^ self basicNew initialize |
811 | 69 |
! ! |
70 |
||
1174 | 71 |
!SelectionInTree class methodsFor:'defaults'! |
72 |
||
73 |
defaultItemClass |
|
5452 | 74 |
"returns the default item class or nil (the default)" |
75 |
||
1174 | 76 |
^ nil |
77 |
||
5452 | 78 |
"Modified (comment): / 04-02-2017 / 19:48:09 / cg" |
1174 | 79 |
! ! |
80 |
||
458 | 81 |
!SelectionInTree methodsFor:'accessing'! |
82 |
||
83 |
list |
|
5452 | 84 |
"get the list of currently shown objects" |
85 |
||
458 | 86 |
^ list |
5452 | 87 |
|
88 |
"Modified (comment): / 04-02-2017 / 19:38:18 / cg" |
|
458 | 89 |
! |
90 |
||
91 |
root |
|
5452 | 92 |
"get the root node" |
93 |
||
458 | 94 |
^ root |
5452 | 95 |
|
96 |
"Modified (comment): / 04-02-2017 / 19:40:07 / cg" |
|
458 | 97 |
! |
98 |
||
509 | 99 |
root:aRoot |
5452 | 100 |
"set a new root" |
101 |
||
1176 | 102 |
|tree| |
103 |
||
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
104 |
root notNil ifTrue: [ |
1176 | 105 |
tree := root tree. |
106 |
root tree:nil. |
|
107 |
] ifFalse:[ |
|
108 |
tree := self |
|
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
109 |
]. |
811 | 110 |
self stopRunningTasks. |
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
111 |
|
515 | 112 |
(root := aRoot) notNil ifTrue:[ |
1176 | 113 |
root tree:tree. |
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
114 |
root parent:nil. |
857 | 115 |
]. |
1189 | 116 |
self recomputeList |
5452 | 117 |
|
118 |
"Modified (comment): / 04-02-2017 / 19:40:12 / cg" |
|
860 | 119 |
! |
120 |
||
121 |
value |
|
122 |
^ list |
|
496 | 123 |
! ! |
491 | 124 |
|
2697 | 125 |
!SelectionInTree methodsFor:'accessing hierarchy new'! |
126 |
||
5626 | 127 |
doMakeVisible:itemOrCollectionOfItems |
128 |
"make an item or collection of items visible" |
|
5452 | 129 |
|
2697 | 130 |
|anchor parent| |
131 |
||
5626 | 132 |
self each:itemOrCollectionOfItems do:[:anItem| |
2697 | 133 |
parent := anItem. |
134 |
anchor := nil. |
|
135 |
||
136 |
parent notNil ifTrue:[ |
|
137 |
[(parent := parent parent) notNil] whileTrue:[ |
|
138 |
parent hidden ifTrue:[ |
|
139 |
anchor notNil ifTrue:[ anchor expand ]. |
|
140 |
anchor := parent. |
|
141 |
] |
|
142 |
]. |
|
143 |
anchor notNil ifTrue:[ |
|
144 |
self expandItem:anchor do:[anchor expand] |
|
145 |
] |
|
146 |
]. |
|
147 |
] |
|
5452 | 148 |
|
5626 | 149 |
"Modified (comment): / 18-10-2017 / 11:55:53 / cg" |
2697 | 150 |
! ! |
151 |
||
1818 | 152 |
!SelectionInTree methodsFor:'accessing-behavior'! |
496 | 153 |
|
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
154 |
childrenAction |
5452 | 155 |
"get the children action block. |
156 |
This is called by tree items to retrieve the children of a node" |
|
157 |
||
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
158 |
^childrenAction |
5452 | 159 |
|
160 |
"Modified (comment): / 04-02-2017 / 19:31:38 / cg" |
|
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
161 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
162 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
163 |
childrenAction:aBlock |
5452 | 164 |
"set the children action block |
165 |
This is called by tree items to retrieve the children of a node" |
|
166 |
||
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
167 |
childrenAction := aBlock. |
5452 | 168 |
|
169 |
"Modified (comment): / 04-02-2017 / 19:31:51 / cg" |
|
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
170 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
171 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
172 |
contentsAction |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
173 |
"get contents action block |
5452 | 174 |
This is called by tree items to retrieve the contents of a node" |
175 |
||
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
176 |
^contentsAction |
5452 | 177 |
|
178 |
"Modified (comment): / 04-02-2017 / 19:32:04 / cg" |
|
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
179 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
180 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
181 |
contentsAction:aBlock |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
182 |
"set contents action block |
5452 | 183 |
This is called by tree items to retrieve the contents of a node" |
184 |
||
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
185 |
contentsAction := aBlock. |
5452 | 186 |
|
187 |
"Modified (comment): / 04-02-2017 / 19:32:09 / cg" |
|
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
188 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
189 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
190 |
iconAction |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
191 |
"get icon action block |
5452 | 192 |
This is called by tree items to retrieve the icon of a node" |
193 |
||
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
194 |
^iconAction |
5452 | 195 |
|
196 |
"Modified (comment): / 04-02-2017 / 19:32:22 / cg" |
|
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
197 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
198 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
199 |
iconAction:aBlock |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
200 |
"set icon action block |
5452 | 201 |
This is called by tree items to retrieve the icon of a node" |
202 |
||
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
203 |
iconAction := aBlock. |
5452 | 204 |
|
205 |
"Modified (comment): / 04-02-2017 / 19:32:17 / cg" |
|
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
206 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
207 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
208 |
labelAction |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
209 |
"get label action block |
5452 | 210 |
This is called by tree items to retrieve the label of a node" |
211 |
||
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
212 |
^labelAction |
5452 | 213 |
|
214 |
"Modified (comment): / 04-02-2017 / 19:32:27 / cg" |
|
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
215 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
216 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
217 |
labelAction:aBlock |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
218 |
"set label action block |
5452 | 219 |
This is called by tree items to retrieve the label of a node" |
220 |
||
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
221 |
labelAction := aBlock. |
5452 | 222 |
|
223 |
"Modified (comment): / 04-02-2017 / 19:32:35 / cg" |
|
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
224 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
225 |
|
496 | 226 |
showRoot |
5452 | 227 |
"controls if the list is shown with or without root. |
228 |
Notice that technically, there is always one single root item; |
|
229 |
however, its visibility can be suppressed to make the tree look like a list |
|
230 |
on the top level" |
|
231 |
||
496 | 232 |
^ showRoot |
5452 | 233 |
|
234 |
"Modified (comment): / 04-02-2017 / 19:33:45 / cg" |
|
491 | 235 |
! |
236 |
||
5452 | 237 |
showRoot:aBoolean |
238 |
"controls if the list is shown with or without root. |
|
239 |
Notice that technically, there is always one single root item; |
|
240 |
however, its visibility can be suppressed to make the tree look like a list |
|
241 |
on the top level" |
|
242 |
||
243 |
aBoolean ~~ showRoot ifTrue:[ |
|
244 |
showRoot := aBoolean. |
|
491 | 245 |
|
496 | 246 |
root notNil ifTrue:[ |
5452 | 247 |
aBoolean ifTrue:[ |
857 | 248 |
list addFirst:root. |
249 |
self changed:#insertCollection: with:(Array with:1 with:1 with:nil). |
|
250 |
] ifFalse:[ |
|
251 |
list removeFirst. |
|
252 |
self changed:#removeFrom: with:(Array with:1 with:1 with:nil). |
|
253 |
]. |
|
491 | 254 |
]. |
255 |
]. |
|
5452 | 256 |
|
257 |
"Modified (format): / 04-02-2017 / 21:34:26 / cg" |
|
458 | 258 |
! ! |
259 |
||
1818 | 260 |
!SelectionInTree methodsFor:'accessing-hierarchy'! |
458 | 261 |
|
262 |
collapse:something |
|
5452 | 263 |
"collapse a node or collection of nodes" |
264 |
||
857 | 265 |
|listChanged| |
266 |
||
267 |
listChanged := false. |
|
458 | 268 |
|
269 |
self each:something do:[:aNode| |
|
270 |
aNode isCollapsable ifTrue:[ |
|
271 |
aNode collapse. |
|
857 | 272 |
listChanged := true |
458 | 273 |
] |
274 |
]. |
|
857 | 275 |
listChanged ifTrue:[ |
276 |
self listFromRoot. |
|
277 |
self changed:#list. |
|
278 |
] |
|
279 |
||
5452 | 280 |
"Modified (comment): / 04-02-2017 / 19:34:09 / cg" |
458 | 281 |
! |
282 |
||
509 | 283 |
expand |
5452 | 284 |
"expand the root" |
285 |
||
509 | 286 |
self expand:root |
5452 | 287 |
|
288 |
"Modified (comment): / 04-02-2017 / 19:34:13 / cg" |
|
509 | 289 |
! |
290 |
||
458 | 291 |
expand:something |
5452 | 292 |
"expand a node or collection of nodes" |
293 |
||
857 | 294 |
|listChanged| |
295 |
||
296 |
listChanged := false. |
|
458 | 297 |
|
298 |
self each:something do:[:aNode| |
|
299 |
aNode isExpandable ifTrue:[ |
|
300 |
aNode expand. |
|
857 | 301 |
listChanged := true |
458 | 302 |
] |
303 |
]. |
|
857 | 304 |
listChanged ifTrue:[ |
305 |
self listFromRoot. |
|
306 |
self changed:#list. |
|
307 |
] |
|
5452 | 308 |
|
309 |
"Modified (comment): / 04-02-2017 / 19:34:17 / cg" |
|
857 | 310 |
! ! |
311 |
||
1818 | 312 |
!SelectionInTree methodsFor:'accessing-hierarchy new'! |
857 | 313 |
|
314 |
doCollapse:something |
|
315 |
"collapse all children under an item or a sequence of items; |
|
5452 | 316 |
if the list changed, a change notifications are sent" |
317 |
||
857 | 318 |
self each:something do:[:anItem| |
319 |
self collapseItem:anItem do:[ anItem collapse ] |
|
320 |
] |
|
5452 | 321 |
|
322 |
"Modified (comment): / 04-02-2017 / 19:36:30 / cg" |
|
857 | 323 |
! |
324 |
||
325 |
doCollapseAll:something |
|
326 |
"collapse all children and subChildren under an item or sequence of items; |
|
5452 | 327 |
if the list changed, a change notifications are sent" |
328 |
||
857 | 329 |
self each:something do:[:anItem| |
330 |
self collapseItem:anItem do:[ anItem collapseAll ] |
|
331 |
] |
|
5452 | 332 |
|
333 |
"Modified (comment): / 04-02-2017 / 19:36:39 / cg" |
|
857 | 334 |
! |
335 |
||
336 |
doExpand:something |
|
337 |
"expand all children under an item or collection of items; |
|
5452 | 338 |
if the list changed, a change notifications are sent" |
339 |
||
857 | 340 |
self each:something do:[:anItem| |
341 |
self expandItem:anItem do:[anItem expand] |
|
342 |
] |
|
5452 | 343 |
|
344 |
"Modified (comment): / 04-02-2017 / 19:36:44 / cg" |
|
857 | 345 |
! |
346 |
||
347 |
doExpandAll:something |
|
348 |
"expand all children and subChildren under an item or sequence of items; |
|
5452 | 349 |
if the list changed, change notifications are sent" |
350 |
||
857 | 351 |
self each:something do:[:anItem| |
352 |
self expandItem:anItem do:[anItem expandAll] |
|
353 |
] |
|
5452 | 354 |
|
355 |
"Modified (comment): / 04-02-2017 / 19:36:55 / cg" |
|
458 | 356 |
! ! |
357 |
||
358 |
!SelectionInTree methodsFor:'adding & removing'! |
|
359 |
||
360 |
add:something after:aChild |
|
5452 | 361 |
"add a node or collection of nodes to the parent of aChild |
362 |
after that child in the sublist" |
|
363 |
||
857 | 364 |
|p| |
365 |
||
366 |
(aChild notNil and:[(p := aChild parent) notNil]) ifTrue:[ |
|
367 |
self add:something afterIndex:(p indexOfChild:aChild) below:p |
|
458 | 368 |
] |
857 | 369 |
|
5452 | 370 |
"Modified (comment): / 04-02-2017 / 19:35:11 / cg" |
458 | 371 |
! |
372 |
||
373 |
add:something afterIndex:anIndex below:aParent |
|
374 |
"add a node or collection of nodes to parent after an index |
|
375 |
" |
|
857 | 376 |
self add:something beforeIndex:(anIndex + 1) below:aParent |
458 | 377 |
! |
378 |
||
379 |
add:something before:aChild |
|
5452 | 380 |
"add a node or collection of nodes to before a child" |
381 |
||
857 | 382 |
|p| |
383 |
||
384 |
(aChild notNil and:[(p := aChild parent) notNil]) ifTrue:[ |
|
385 |
self add:something beforeIndex:(p indexOfChild:aChild) below:p |
|
458 | 386 |
] |
5452 | 387 |
|
388 |
"Modified (comment): / 04-02-2017 / 19:35:19 / cg" |
|
458 | 389 |
! |
390 |
||
391 |
add:something beforeIndex:anIndex below:aParent |
|
1204 | 392 |
"add a node or collection of nodes to aParents children |
5452 | 393 |
before anIndex (which is a child-index)" |
394 |
||
857 | 395 |
|children start index size pList| |
396 |
||
397 |
( aParent isNil |
|
398 |
or:[something isNil |
|
399 |
or:[(something isCollection and:[something isEmpty])]] |
|
400 |
) ifTrue:[ |
|
401 |
^ self |
|
402 |
]. |
|
403 |
||
404 |
(start := self indexOf:aParent) == 0 ifTrue:[ |
|
405 |
"/ |
|
406 |
"/ parent not visible; list not changed |
|
407 |
"/ |
|
1304 | 408 |
aParent == root ifFalse:[ |
409 |
aParent add:something beforeIndex:anIndex. |
|
410 |
^ self |
|
411 |
] |
|
412 |
] ifFalse:[ |
|
413 |
aParent shown ifFalse:[ |
|
414 |
aParent add:something beforeIndex:anIndex. |
|
415 |
self changed:#at: with:start. |
|
416 |
^ self |
|
417 |
] |
|
857 | 418 |
]. |
419 |
children := aParent children. |
|
420 |
||
421 |
(children isEmpty or:[anIndex <= 1]) ifTrue:[ |
|
422 |
index := 1. |
|
423 |
] ifFalse:[ |
|
424 |
size := children size. |
|
425 |
||
426 |
anIndex > size ifTrue:[ |
|
427 |
index := size + 1. |
|
428 |
start := aParent numberOfAllVisibleChildren + start. |
|
429 |
] ifFalse:[ |
|
430 |
index := anIndex. |
|
431 |
start := (self indexOf:(children at:index)) - 1. |
|
432 |
] |
|
433 |
]. |
|
434 |
aParent add:something beforeIndex:index. |
|
435 |
||
436 |
(start := start + 1) == 0 ifTrue:[ |
|
437 |
"/ |
|
438 |
"/ not visible |
|
439 |
"/ |
|
440 |
^ self |
|
441 |
]. |
|
442 |
pList := OrderedCollection new:2048. |
|
443 |
||
444 |
self each:something do:[:aNode| |
|
445 |
pList add:aNode. |
|
446 |
aNode addVisibleChildrenTo:pList |
|
447 |
]. |
|
448 |
pList isEmpty ifTrue:[ |
|
449 |
^ self |
|
450 |
]. |
|
451 |
list addAll:pList beforeIndex:start. |
|
452 |
||
453 |
self changed:#insertCollection: |
|
454 |
with:(Array with:start with:pList size with:aParent). |
|
458 | 455 |
|
5452 | 456 |
"Modified (comment): / 04-02-2017 / 19:35:23 / cg" |
458 | 457 |
! |
458 |
||
459 |
add:something below:aParent |
|
5452 | 460 |
"add a node or collection of nodes to parent" |
461 |
||
857 | 462 |
aParent notNil ifTrue:[ |
463 |
self add:something beforeIndex:(aParent numberOfChildren + 1) below:aParent |
|
464 |
] |
|
5452 | 465 |
|
466 |
"Modified (comment): / 04-02-2017 / 19:35:28 / cg" |
|
458 | 467 |
! |
468 |
||
469 |
remove:something |
|
5452 | 470 |
"remove a node or collection of nodes. |
471 |
Change notifications are sent" |
|
472 |
||
1268 | 473 |
|node index loNums loItem start size parent stop| |
857 | 474 |
|
475 |
something isNil ifTrue:[ |
|
476 |
^ something |
|
477 |
]. |
|
478 |
loNums := SortedCollection new. |
|
479 |
||
480 |
self each:something do:[:el| |
|
481 |
node := el isNumber ifTrue:[list at:el ifAbsent:nil] |
|
482 |
ifFalse:[el]. |
|
483 |
||
484 |
node notNil ifTrue:[ |
|
485 |
self stopIndicatorValidationFor:node. |
|
458 | 486 |
|
857 | 487 |
node parent isNil ifTrue:[ |
488 |
"/ remove all including root |
|
489 |
node == root ifTrue:[ self root:nil ]. |
|
490 |
^ something |
|
491 |
]. |
|
492 |
index := self indexOf:node. |
|
811 | 493 |
|
857 | 494 |
index == 0 ifTrue:[ |
495 |
"/ not visible |
|
496 |
node parent removeChild:node |
|
497 |
] ifFalse:[ |
|
498 |
loNums add:index |
|
499 |
]. |
|
458 | 500 |
] |
501 |
]. |
|
857 | 502 |
|
503 |
loNums isEmpty ifTrue:[ |
|
504 |
"/ nothing visible changed |
|
505 |
^ something |
|
506 |
]. |
|
507 |
loItem := OrderedCollection new. |
|
508 |
loNums do:[:i| loItem add:(list at:i)]. |
|
509 |
||
510 |
loItem do:[:aNode| |
|
511 |
start := self indexOf:aNode. |
|
512 |
||
513 |
start ~~ 0 ifTrue:[ |
|
514 |
parent := aNode parent. |
|
515 |
size := 1 + aNode numberOfAllVisibleChildren. |
|
860 | 516 |
stop := start + size - 1. |
857 | 517 |
parent remove:aNode. |
860 | 518 |
list removeFromIndex:start toIndex:stop. |
811 | 519 |
|
857 | 520 |
self changed:#removeFrom: |
860 | 521 |
with:(Array with:start with:stop with:parent). |
857 | 522 |
] |
523 |
]. |
|
524 |
^ something |
|
5452 | 525 |
|
526 |
"Modified (comment): / 04-02-2017 / 19:39:07 / cg" |
|
857 | 527 |
! |
528 |
||
529 |
removeAllOtherThanRoot |
|
5452 | 530 |
"remove all children from the root |
531 |
Change notifications are sent" |
|
532 |
||
857 | 533 |
|listChanged| |
534 |
||
535 |
root notNil ifTrue:[ |
|
536 |
listChanged := root isCollapsable. |
|
537 |
root children:(OrderedCollection new). |
|
538 |
||
539 |
listChanged ifTrue:[ |
|
540 |
self listFromRoot. |
|
541 |
self changed:#list |
|
542 |
] |
|
543 |
] |
|
5452 | 544 |
|
545 |
"Modified (comment): / 04-02-2017 / 19:39:31 / cg" |
|
458 | 546 |
! |
547 |
||
548 |
removeIndex:something |
|
5452 | 549 |
"remove a node at index or collection of indexed nodes. |
550 |
Change notifications are sent" |
|
551 |
||
857 | 552 |
self remove:something |
5452 | 553 |
|
554 |
"Modified (comment): / 04-02-2017 / 19:39:42 / cg" |
|
458 | 555 |
! |
556 |
||
557 |
removeSelection |
|
5452 | 558 |
"remove selected nodes. |
559 |
Change notifications are sent" |
|
560 |
||
857 | 561 |
|sel| |
562 |
||
563 |
sel := self selectionIndex. |
|
564 |
self selectionIndex:nil. |
|
565 |
self remove:sel. |
|
5452 | 566 |
|
567 |
"Modified (comment): / 04-02-2017 / 19:39:51 / cg" |
|
1209 | 568 |
! |
569 |
||
570 |
replaceNode:aNode with:aNewNode |
|
571 |
"replace a node by a new node; if the new node is nil, the node and its |
|
5452 | 572 |
children are removed. |
573 |
Otherwise the children are taken over to the new node." |
|
574 |
||
1209 | 575 |
|parent index children| |
576 |
||
577 |
(aNode isNil or:[aNode == aNewNode]) ifTrue:[ |
|
578 |
^ self |
|
579 |
]. |
|
580 |
||
581 |
aNewNode isNil ifTrue:[ |
|
582 |
^ self remove:aNode |
|
583 |
]. |
|
584 |
self stopIndicatorValidationFor:aNode. |
|
585 |
||
586 |
aNewNode children:(aNode children). |
|
587 |
aNode children:nil. |
|
588 |
||
589 |
aNode == root ifTrue:[ |
|
590 |
aNewNode tree:(aNode tree). |
|
591 |
aNewNode parent:nil. |
|
592 |
root := aNewNode. |
|
593 |
] ifFalse:[ |
|
594 |
parent := aNode parent. |
|
595 |
aNewNode tree:nil. |
|
596 |
aNewNode parent:parent. |
|
597 |
children := parent children. |
|
598 |
index := children identityIndexOf:aNode. |
|
599 |
children at:index put:aNewNode. |
|
600 |
]. |
|
601 |
||
602 |
aNode tree:nil. |
|
603 |
aNode parent:nil. |
|
604 |
||
605 |
(index := self indexOf:aNode) ~~ 0 ifTrue:[ |
|
606 |
list at:index put:aNewNode. |
|
607 |
self changed:#at: with:index |
|
608 |
]. |
|
5452 | 609 |
|
610 |
"Modified (comment): / 04-02-2017 / 19:40:02 / cg" |
|
458 | 611 |
! ! |
612 |
||
758 | 613 |
!SelectionInTree methodsFor:'change & update'! |
614 |
||
615 |
invalidate |
|
5452 | 616 |
"called whenever something changed that requires a redraw but no recomputation. |
617 |
For example a name or icon" |
|
618 |
||
758 | 619 |
self dependents do:[:aDependent| |
620 |
aDependent isView ifTrue:[ aDependent invalidate ] |
|
621 |
]. |
|
622 |
||
5452 | 623 |
"Modified (comment): / 04-02-2017 / 19:38:06 / cg" |
762
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
624 |
! |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
625 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
626 |
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
|
627 |
|
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
628 |
self dependents do:[:aDependent| |
df337e82f064
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
758
diff
changeset
|
629 |
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
|
630 |
] |
758 | 631 |
! ! |
632 |
||
458 | 633 |
!SelectionInTree methodsFor:'enumerating'! |
634 |
||
5626 | 635 |
each:itemOrCollectionOfItems do:aOneArgBlock |
458 | 636 |
"evaluate a block for something or in case of a collection for each |
5452 | 637 |
element in the collection" |
638 |
||
5626 | 639 |
itemOrCollectionOfItems notNil ifTrue:[ |
640 |
itemOrCollectionOfItems isCollection ifTrue:[ |
|
641 |
itemOrCollectionOfItems do:aOneArgBlock |
|
642 |
] ifFalse:[ |
|
643 |
aOneArgBlock value:itemOrCollectionOfItems |
|
644 |
] |
|
458 | 645 |
] |
646 |
||
5626 | 647 |
"Modified (format): / 18-10-2017 / 11:55:36 / cg" |
458 | 648 |
! ! |
649 |
||
496 | 650 |
!SelectionInTree methodsFor:'initialization'! |
651 |
||
652 |
initialize |
|
811 | 653 |
|
1166
d062a52bc7cc
list attribute changed from OrderedCollection to List
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
654 |
showRoot := true. |
811 | 655 |
indicatorList := OrderedCollection new. |
656 |
accessLock := Semaphore forMutualExclusion. |
|
1166
d062a52bc7cc
list attribute changed from OrderedCollection to List
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
657 |
list := List new. |
496 | 658 |
! ! |
659 |
||
458 | 660 |
!SelectionInTree methodsFor:'private'! |
661 |
||
662 |
recomputeList |
|
663 |
"Travers the tree and build a new list." |
|
664 |
||
857 | 665 |
self listFromRoot. |
666 |
self changed:#list. |
|
667 |
! ! |
|
668 |
||
2494 | 669 |
!SelectionInTree methodsFor:'private-hierarchy'! |
857 | 670 |
|
671 |
collapseItem:anItem do:collapseBlock |
|
5452 | 672 |
"collapse all children under an item; |
673 |
send a change notification if the list changed" |
|
674 |
||
857 | 675 |
|start stop size| |
676 |
||
677 |
anItem isCollapsable ifFalse:[ |
|
678 |
^ self |
|
679 |
]. |
|
680 |
||
681 |
(start := self indexOf:anItem) == 0 ifTrue:[ |
|
682 |
"/ |
|
683 |
"/ item not visible |
|
684 |
"/ |
|
685 |
collapseBlock value. |
|
686 |
] ifFalse:[ |
|
687 |
size := anItem numberOfAllVisibleChildren. |
|
688 |
collapseBlock value. |
|
689 |
||
690 |
size == 0 ifTrue:[ |
|
691 |
"/ |
|
692 |
"/ no children before; list not changed |
|
693 |
"/ |
|
694 |
self changed:#at: with:start |
|
695 |
] ifFalse:[ |
|
696 |
stop := start + size. |
|
697 |
start := start + 1. |
|
698 |
list removeFromIndex:start toIndex:stop. |
|
860 | 699 |
self changed:#removeFrom: with:(Array with:start with:stop with:anItem). |
857 | 700 |
] |
701 |
] |
|
5452 | 702 |
|
703 |
"Modified (comment): / 04-02-2017 / 19:35:52 / cg" |
|
857 | 704 |
! |
705 |
||
706 |
expandItem:anItem do:expandBlock |
|
5452 | 707 |
"expand all children under an item; |
708 |
send out change a notification if the list changed" |
|
709 |
||
857 | 710 |
|start size pList| |
711 |
||
712 |
anItem isExpandable ifFalse:[ |
|
713 |
^ self |
|
714 |
]. |
|
715 |
expandBlock value. |
|
716 |
||
717 |
(start := self indexOf:anItem) ~~ 0 ifTrue:[ |
|
718 |
anItem addVisibleChildrenTo:(pList := OrderedCollection new:2048). |
|
719 |
||
720 |
(size := pList size) ~~ 0 ifTrue:[ |
|
721 |
start := 1 + start. |
|
722 |
list addAll:pList beforeIndex:start. |
|
723 |
||
724 |
self changed:#insertCollection: |
|
725 |
with:(Array with:start with:size with:anItem). |
|
726 |
] ifFalse:[ |
|
727 |
self changed:#at: with:start |
|
728 |
] |
|
729 |
] |
|
5452 | 730 |
|
731 |
"Modified (comment): / 04-02-2017 / 19:37:29 / cg" |
|
857 | 732 |
! |
733 |
||
734 |
listFromRoot |
|
1204 | 735 |
"Traverse the tree and build a new list; |
5452 | 736 |
no change notification are sent" |
737 |
||
842 | 738 |
list clearContents. |
458 | 739 |
|
740 |
root notNil ifTrue:[ |
|
857 | 741 |
showRoot ifTrue:[ list add:root ]. |
742 |
root addVisibleChildrenTo:list |
|
743 |
] |
|
744 |
||
5452 | 745 |
"Modified (comment): / 04-02-2017 / 19:38:29 / cg" |
857 | 746 |
! ! |
747 |
||
748 |
!SelectionInTree methodsFor:'queries'! |
|
749 |
||
750 |
indexOf:anItem |
|
5452 | 751 |
"returns the index of an item or 0" |
752 |
||
5667 | 753 |
^ anItem notNil |
754 |
ifTrue:[list identityIndexOf:anItem] |
|
755 |
ifFalse:[0] |
|
5452 | 756 |
|
757 |
"Modified (comment): / 04-02-2017 / 19:37:38 / cg" |
|
458 | 758 |
! ! |
759 |
||
849 | 760 |
!SelectionInTree methodsFor:'searching'! |
761 |
||
1550 | 762 |
detectFirstItem:aOneArgBlock |
763 |
"detect an item the evaluation of the block returns true. |
|
764 |
The argument to the block is the item. |
|
765 |
This recursively enumerates the tree for the first item for which |
|
5452 | 766 |
the block returns true." |
767 |
||
1550 | 768 |
root notNil ifTrue:[ |
769 |
^ root detectFirstChild:aOneArgBlock |
|
770 |
]. |
|
771 |
^ nil |
|
772 |
||
5452 | 773 |
"Modified (comment): / 04-02-2017 / 19:36:01 / cg" |
1550 | 774 |
! |
775 |
||
849 | 776 |
detectItem:aOneArgBlock |
1553 | 777 |
"detect an item the evaluation of the block returns true. |
778 |
The argument to the block is the item. |
|
5452 | 779 |
This searches top-level items only." |
780 |
||
849 | 781 |
root notNil ifTrue:[ |
782 |
^ root detectChild:aOneArgBlock |
|
783 |
]. |
|
784 |
^ nil |
|
785 |
||
5452 | 786 |
"Modified (comment): / 04-02-2017 / 19:36:06 / cg" |
849 | 787 |
! |
788 |
||
789 |
detectItem:aTwoArgBlock arguments:aListOfArgs |
|
1553 | 790 |
"detect an item the evaluation of the block returns true. |
791 |
The first argument to the block is the item, the second argument |
|
792 |
the value derived from the argument list at level. |
|
793 |
This recursively walks down the tree up to aListOfArgs size levels; |
|
794 |
i.e. if you pass (1 to:10) as aListOfArgs, the block will get the sub-level |
|
5452 | 795 |
as second argument and stop the search after 10 levels." |
1550 | 796 |
|
849 | 797 |
root notNil ifTrue:[ |
1553 | 798 |
^ root detectChild:aTwoArgBlock arguments:aListOfArgs |
849 | 799 |
]. |
800 |
^ nil |
|
801 |
||
5452 | 802 |
"Modified (comment): / 04-02-2017 / 19:36:15 / cg" |
849 | 803 |
! ! |
804 |
||
458 | 805 |
!SelectionInTree methodsFor:'selection'! |
806 |
||
1213 | 807 |
selectNode:aNode |
5626 | 808 |
"select a given node (by identity - not by index). |
809 |
Notice, that the node must be visible - i.e. its parent chain must be |
|
810 |
currently expanded." |
|
5452 | 811 |
|
1213 | 812 |
|index| |
813 |
||
814 |
(index := self indexOf:aNode) ~~ 0 ifTrue:[ |
|
815 |
self selectionIndex:index |
|
5626 | 816 |
] ifFalse:[ |
817 |
"/ self halt. |
|
1213 | 818 |
] |
5452 | 819 |
|
5626 | 820 |
"Modified: / 18-10-2017 / 11:56:20 / cg" |
1213 | 821 |
! |
822 |
||
1234 | 823 |
selectNodes:aCollectionOfNodes |
5452 | 824 |
"select a given set of nodes (by identity - not by index)" |
825 |
||
1234 | 826 |
| indices| |
827 |
||
4941 | 828 |
indices := aCollectionOfNodes |
829 |
collect:[:aNode | self indexOf:aNode] |
|
830 |
thenSelect:[:idx | idx ~~ 0]. |
|
1234 | 831 |
indices sort. |
832 |
self selectionIndex:indices |
|
833 |
||
5452 | 834 |
"Created: / 06-03-1999 / 22:37:59 / cg" |
835 |
"Modified (comment): / 04-02-2017 / 19:40:55 / cg" |
|
1234 | 836 |
! |
837 |
||
906 | 838 |
selectedNode |
5452 | 839 |
"returns the selected node or nil" |
840 |
||
906 | 841 |
|nodes| |
842 |
(nodes := self selectedNodes) notNil ifTrue: [ |
|
843 |
^nodes first |
|
844 |
]. |
|
845 |
^nil |
|
846 |
||
5452 | 847 |
"Modified (comment): / 04-02-2017 / 19:41:04 / cg" |
906 | 848 |
! |
849 |
||
857 | 850 |
selectedNodes |
5452 | 851 |
"returns a collection of selected nodes or nil" |
852 |
||
857 | 853 |
|node coll| |
854 |
||
855 |
selection isNil ifTrue:[ |
|
856 |
^ nil |
|
857 |
]. |
|
858 |
||
859 |
selection isCollection ifFalse:[ |
|
860 |
node := list at:selection ifAbsent:nil. |
|
5452 | 861 |
^ node notNil ifTrue:[Array with:node] ifFalse:[nil] |
857 | 862 |
]. |
863 |
||
864 |
selection isEmpty ifTrue:[ |
|
865 |
^ nil |
|
866 |
]. |
|
867 |
||
868 |
coll := OrderedCollection new:(selection size). |
|
869 |
||
870 |
selection do:[:idx| |
|
871 |
(node := list at:idx ifAbsent:nil) notNil ifTrue:[ |
|
872 |
coll add:node |
|
873 |
] |
|
874 |
]. |
|
4275 | 875 |
^ coll asNilIfEmpty |
5452 | 876 |
|
877 |
"Modified (format): / 04-02-2017 / 19:41:19 / cg" |
|
857 | 878 |
! |
879 |
||
2038 | 880 |
selectedNodesDo:aOneArgBlock |
5452 | 881 |
"evaluate the block on each node selected" |
882 |
||
2038 | 883 |
|node| |
884 |
||
885 |
selection isNil ifTrue:[ |
|
886 |
^ nil |
|
887 |
]. |
|
888 |
||
889 |
selection isCollection ifFalse:[ |
|
890 |
node := list at:selection ifAbsent:nil. |
|
891 |
node notNil ifTrue:[ |
|
892 |
aOneArgBlock value:node |
|
893 |
]. |
|
894 |
^ self |
|
895 |
]. |
|
896 |
||
897 |
selection do:[:i| |
|
898 |
node := list at:i ifAbsent:nil. |
|
899 |
||
900 |
node notNil ifTrue:[ |
|
901 |
aOneArgBlock value:node |
|
902 |
]. |
|
903 |
]. |
|
5452 | 904 |
|
905 |
"Modified (comment): / 04-02-2017 / 19:41:54 / cg" |
|
2038 | 906 |
! |
907 |
||
458 | 908 |
selection |
5452 | 909 |
"get the selection index or nil" |
910 |
||
458 | 911 |
^ self selectionIndex |
5452 | 912 |
|
913 |
"Modified (comment): / 04-02-2017 / 19:42:40 / cg" |
|
458 | 914 |
! |
915 |
||
916 |
selection:indexesOrNil |
|
5452 | 917 |
"set the selection index" |
3872
a35d3ecdb0bb
comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
918 |
|
458 | 919 |
self selectionIndex:indexesOrNil |
5452 | 920 |
|
921 |
"Modified (comment): / 04-02-2017 / 19:42:45 / cg" |
|
458 | 922 |
! |
923 |
||
924 |
selectionIndex |
|
5452 | 925 |
"get the selection index or nil" |
926 |
||
458 | 927 |
^ selection |
5452 | 928 |
|
929 |
"Modified (comment): / 04-02-2017 / 19:42:59 / cg" |
|
458 | 930 |
! |
931 |
||
932 |
selectionIndex:indexesOrNil |
|
5452 | 933 |
"set the selection index (or nil to deselect)" |
934 |
||
496 | 935 |
|oldSel| |
936 |
||
937 |
oldSel := selection. |
|
938 |
self setSelectionIndex:indexesOrNil. |
|
939 |
||
940 |
oldSel = selection ifFalse:[ |
|
2038 | 941 |
self changed:#selectionIndex. |
942 |
||
943 |
self selectedNodesDo:[:aNode| |
|
944 |
aNode changedSelected |
|
945 |
] |
|
496 | 946 |
] |
5452 | 947 |
|
948 |
"Modified (comment): / 04-02-2017 / 19:43:12 / cg" |
|
496 | 949 |
! |
950 |
||
951 |
setSelection:indexesOrNil |
|
5452 | 952 |
"set the selection index without sending out change notifications" |
953 |
||
496 | 954 |
self setSelectionIndex:indexesOrNil |
5452 | 955 |
|
956 |
"Modified (comment): / 04-02-2017 / 19:43:41 / cg" |
|
496 | 957 |
! |
958 |
||
959 |
setSelectionIndex:indexesOrNil |
|
5452 | 960 |
"set the selection index without sending out change notifications" |
961 |
||
458 | 962 |
|indexes| |
963 |
||
964 |
indexes := indexesOrNil. |
|
965 |
||
966 |
indexes size == 0 ifTrue:[ |
|
967 |
(indexes isCollection or:[indexes == 0]) ifTrue:[ |
|
968 |
indexes := nil |
|
969 |
] |
|
970 |
]. |
|
496 | 971 |
selection := indexes |
458 | 972 |
|
5452 | 973 |
"Modified (comment): / 04-02-2017 / 19:43:37 / cg" |
458 | 974 |
! ! |
975 |
||
811 | 976 |
!SelectionInTree methodsFor:'update indication task'! |
977 |
||
978 |
startIndicatorValidationFor:aNode |
|
5452 | 979 |
"add a node to the list of nodes which are automatically |
980 |
monitored for changes in their children list (by a background task), |
|
981 |
and which will then update their 'has-children' arrow indicator icon. |
|
982 |
This is typically used to check for changed folders in file trees, |
|
983 |
data in databases etc." |
|
984 |
||
811 | 985 |
|index| |
986 |
||
987 |
accessLock critical:[ |
|
1155
ff5b146ca277
run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents:
1145
diff
changeset
|
988 |
|prio| |
ff5b146ca277
run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents:
1145
diff
changeset
|
989 |
|
811 | 990 |
index := indicatorList identityIndexOf:aNode. |
991 |
||
992 |
index ~~ 0 ifTrue:[ |
|
993 |
indicatorList removeIndex:index. "/ reorganize list to be faster |
|
994 |
]. |
|
1155
ff5b146ca277
run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents:
1145
diff
changeset
|
995 |
indicatorList addLast: "addFirst:" aNode. |
811 | 996 |
|
997 |
indicatorTask isNil ifTrue:[ |
|
1155
ff5b146ca277
run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents:
1145
diff
changeset
|
998 |
prio := Processor activePriority. |
5452 | 999 |
indicatorTask := |
1000 |
[ |
|
1001 |
[ self taskCycle ] whileTrue:[ Processor yield ] |
|
1002 |
] forkAt:(prio - 1). |
|
1155
ff5b146ca277
run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents:
1145
diff
changeset
|
1003 |
indicatorTask priorityRange:(prio-1 to:prio). |
811 | 1004 |
] |
1005 |
]. |
|
1155
ff5b146ca277
run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents:
1145
diff
changeset
|
1006 |
|
5452 | 1007 |
"Modified: / 26-09-1998 / 15:20:44 / cg" |
1008 |
"Modified (comment): / 04-02-2017 / 19:47:28 / cg" |
|
811 | 1009 |
! |
1010 |
||
1011 |
stopIndicatorValidationFor:aNodeOrList |
|
5452 | 1012 |
"remove a node or list of nodes from the list of automatically monitored nodes." |
1013 |
||
811 | 1014 |
accessLock critical:[ |
1015 |
aNodeOrList isCollection ifTrue:[ |
|
1016 |
aNodeOrList do:[:aNode| |
|
1017 |
indicatorList removeIdentical:aNode ifAbsent:nil |
|
1018 |
] |
|
1019 |
] ifFalse:[ |
|
1020 |
indicatorList removeIdentical:aNodeOrList ifAbsent:nil |
|
1021 |
] |
|
1022 |
] |
|
1023 |
||
5452 | 1024 |
"Modified (comment): / 04-02-2017 / 19:46:18 / cg" |
811 | 1025 |
! |
1026 |
||
1027 |
stopRunningTasks |
|
5452 | 1028 |
"stop the running update task" |
1029 |
||
811 | 1030 |
accessLock critical:[ indicatorList removeAll ] |
1031 |
||
5452 | 1032 |
"Modified (comment): / 04-02-2017 / 19:46:33 / cg" |
811 | 1033 |
! |
1034 |
||
1035 |
taskCycle |
|
1155
ff5b146ca277
run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents:
1145
diff
changeset
|
1036 |
"run one cycle fetching indicator state. |
ff5b146ca277
run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents:
1145
diff
changeset
|
1037 |
This is done in the background to avoid long startup |
ff5b146ca277
run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents:
1145
diff
changeset
|
1038 |
delays, in case the indicator information takes long to |
5452 | 1039 |
gather (i.e. when reading network directories)" |
1155
ff5b146ca277
run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents:
1145
diff
changeset
|
1040 |
|
2038 | 1041 |
|node flag| |
811 | 1042 |
|
1043 |
accessLock critical:[ |
|
1044 |
indicatorList isEmpty ifTrue:[ "/ queue is empty; terminate task |
|
1045 |
indicatorTask := nil. |
|
1046 |
^ false |
|
1047 |
]. |
|
1048 |
node := indicatorList removeFirst. "/ run task on first node |
|
1049 |
node hasValidIndicator ifTrue:[ "/ up to date |
|
1050 |
^ true |
|
1051 |
]. |
|
2038 | 1052 |
node setShowIndicator:(node defaultShowSeparator). "/ disable registry |
811 | 1053 |
]. |
1054 |
||
2038 | 1055 |
flag := DirectoryContents directoryNamed:(node fileName) detect:(node matchAction). |
1056 |
node showIndicator:flag. |
|
811 | 1057 |
^ true |
1145 | 1058 |
|
5452 | 1059 |
"Modified: / 26-09-1998 / 15:11:16 / cg" |
1060 |
"Modified (comment): / 04-02-2017 / 19:47:51 / cg" |
|
811 | 1061 |
! ! |
1062 |
||
458 | 1063 |
!SelectionInTree class methodsFor:'documentation'! |
1064 |
||
1065 |
version |
|
4941 | 1066 |
^ '$Header$' |
3872
a35d3ecdb0bb
comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
1067 |
! |
a35d3ecdb0bb
comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
1068 |
|
a35d3ecdb0bb
comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
1069 |
version_CVS |
4941 | 1070 |
^ '$Header$' |
458 | 1071 |
! ! |
4275 | 1072 |