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