author | Claus Gittinger <cg@exept.de> |
Tue, 21 Oct 1997 20:33:10 +0200 | |
changeset 566 | 11ca5c6ba3d8 |
parent 452 | 9ea2102124af |
child 1192 | 6c182c8683ec |
permissions | -rw-r--r-- |
84 | 1 |
" |
2 |
COPYRIGHT (c) 1994 by AEG Industry Automation |
|
3 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
4 |
All Rights Reserved |
|
5 |
||
6 |
This software is furnished under a license and may be used |
|
7 |
only in accordance with the terms of that license and with the |
|
8 |
inclusion of the above copyright notice. This software may not |
|
9 |
be provided or otherwise made available to, or used by, any |
|
10 |
other person. No title to or ownership of the software is |
|
11 |
hereby transferred. |
|
12 |
" |
|
13 |
||
14 |
Object subclass:#HierarchyNode |
|
435 | 15 |
instanceVariableNames:'name id parent children contents disabled hide level |
16 |
childCollectionClass' |
|
253 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
19 |
category:'Interface-Support' |
|
84 | 20 |
! |
21 |
||
359 | 22 |
!HierarchyNode class methodsFor:'documentation'! |
84 | 23 |
|
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1994 by AEG Industry Automation |
|
27 |
COPYRIGHT (c) 1994 by 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 |
documentation |
|
40 |
" |
|
41 |
class to build up tree like structures to represent |
|
42 |
file-trees, class tress etc. |
|
43 |
Especially suited for use with SelectionInHierarchy and |
|
44 |
SelectionInHierarchyView. |
|
45 |
See examples in SelectionInHierarchyView. |
|
253 | 46 |
|
47 |
[Author:] |
|
48 |
W. Olberding AEG Factory Automation |
|
49 |
||
50 |
[See also:] |
|
51 |
SelectionInHierarchy |
|
52 |
SelectionInHierarchyView |
|
84 | 53 |
" |
118 | 54 |
! ! |
84 | 55 |
|
359 | 56 |
!HierarchyNode class methodsFor:'instance creation'! |
253 | 57 |
|
58 |
new |
|
452 | 59 |
^ self basicNew initialize |
253 | 60 |
! |
84 | 61 |
|
359 | 62 |
newAsTreeFromSmalltalkClass:aClass |
63 |
"create a tree of nodes with aClass and all its |
|
64 |
subclasses as contents." |
|
84 | 65 |
|
359 | 66 |
^ self |
67 |
newAsTreeFromSmalltalkClass:aClass |
|
68 |
level:(aClass allSuperclasses size). |
|
69 |
||
70 |
"Modified: 15.4.1997 / 16:34:23 / cg" |
|
84 | 71 |
! |
72 |
||
359 | 73 |
newAsTreeFromSmalltalkClass:aClass level:level |
74 |
"create a tree of nodes with aClass and all its |
|
75 |
subclasses as contents. Set the initial level as given." |
|
76 |
||
447
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
77 |
|newInst clsName| |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
78 |
|
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
79 |
aClass isNil ifTrue:[ |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
80 |
"/ nil subclasses requested |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
81 |
clsName := 'nil' |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
82 |
] ifFalse:[ |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
83 |
"/ regular tree requested |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
84 |
clsName := aClass name |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
85 |
]. |
359 | 86 |
|
87 |
newInst := super new initialize. |
|
447
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
88 |
newInst name:clsName. |
359 | 89 |
newInst contents:aClass. |
90 |
newInst level:level. |
|
438 | 91 |
newInst childCollectionClass:OrderedCollection. |
447
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
92 |
|
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
93 |
aClass isNil ifTrue:[ |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
94 |
((Smalltalk allClasses select:[:cls | cls superclass isNil]) |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
95 |
asSortedCollection:[:a :b | a name < b name]) |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
96 |
do:[:aSubClass | |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
97 |
newInst addChild:(self newAsTreeFromSmalltalkClass:aSubClass level:level+1). |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
98 |
] |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
99 |
] ifFalse:[ |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
100 |
(aClass subclasses asSortedCollection:[:a :b | a name < b name]) |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
101 |
do:[:aSubClass | |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
102 |
newInst addChild:(self newAsTreeFromSmalltalkClass:aSubClass level:level+1). |
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
103 |
] |
359 | 104 |
]. |
105 |
^newInst |
|
84 | 106 |
|
359 | 107 |
"Created: 15.4.1997 / 16:33:52 / cg" |
447
705b618eb324
changed #newAsTreeFromSmalltalk to handle nil-superclass tree
Claus Gittinger <cg@exept.de>
parents:
442
diff
changeset
|
108 |
"Modified: 3.7.1997 / 12:25:03 / cg" |
359 | 109 |
! |
110 |
||
111 |
newWithName:aString |
|
112 |
"create a new node with a name" |
|
113 |
||
114 |
|newInst| |
|
115 |
||
116 |
newInst := super new initialize. |
|
117 |
newInst name: aString. |
|
118 |
^newInst |
|
119 |
||
120 |
"Modified: 15.4.1997 / 16:32:06 / cg" |
|
84 | 121 |
! |
122 |
||
123 |
newWithName: aString andId: anId |
|
359 | 124 |
"create a new node with a name and id" |
84 | 125 |
|
359 | 126 |
|newInst| |
127 |
||
128 |
newInst := super new initialize. |
|
129 |
newInst name: aString. |
|
130 |
newInst id: anId. |
|
131 |
^newInst |
|
132 |
||
133 |
"Modified: 15.4.1997 / 16:32:22 / cg" |
|
84 | 134 |
! ! |
135 |
||
136 |
!HierarchyNode methodsFor:'accessing'! |
|
137 |
||
435 | 138 |
childCollectionClass:aCollectionClass |
139 |
"set the class of the child-collection. |
|
140 |
Default is Set." |
|
141 |
||
142 |
childCollectionClass := aCollectionClass. |
|
143 |
children := aCollectionClass withAll:children. |
|
144 |
! |
|
145 |
||
359 | 146 |
children |
147 |
"Answer my immediate children." |
|
148 |
||
149 |
^ children |
|
150 |
||
151 |
"Modified: 10.10.94 / 16:13:34 / W.Olberding"! |
|
152 |
||
153 |
children:aCollectionWithElementsOfMyKind |
|
253 | 154 |
"set my children" |
155 |
||
359 | 156 |
aCollectionWithElementsOfMyKind do:[:child | |
157 |
child parent: self. |
|
158 |
child level: level + 1. |
|
253 | 159 |
]. |
359 | 160 |
children := aCollectionWithElementsOfMyKind. |
253 | 161 |
|
359 | 162 |
"Modified: 10.10.1994 / 16:13:33 / W.Olberding" |
163 |
"Modified: 15.4.1997 / 16:48:38 / cg" |
|
164 |
! |
|
253 | 165 |
|
84 | 166 |
contents |
167 |
"Answer the contents of me (e.g. a set of items)" |
|
168 |
||
169 |
^contents |
|
170 |
||
171 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
|
172 |
||
173 |
contents: anObject |
|
174 |
"Set the contents of me to any object (e.g. a set of items)" |
|
175 |
||
176 |
^contents:= anObject |
|
177 |
||
178 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
|
179 |
||
253 | 180 |
disabled |
181 |
"return disabled" |
|
182 |
||
183 |
^ disabled |
|
184 |
||
185 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
|
186 |
||
187 |
disabled: aBool |
|
188 |
"set disabled" |
|
189 |
||
190 |
disabled := aBool. |
|
191 |
||
192 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
|
193 |
||
84 | 194 |
hide: aBoolean |
195 |
||
196 |
"Set hide to aBoolean" |
|
197 |
||
198 |
hide:= aBoolean |
|
199 |
||
200 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
|
201 |
||
202 |
hideToFalseForPath |
|
203 |
"set the hide-flag to false" |
|
204 |
||
205 |
hide:= false. |
|
206 |
parent isNil ifTrue: [^self]. |
|
207 |
parent hideToFalseForPath |
|
208 |
||
209 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
|
210 |
||
211 |
id |
|
212 |
"return id" |
|
213 |
||
214 |
^ id |
|
215 |
||
216 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
|
217 |
||
218 |
id:something |
|
219 |
"set id" |
|
220 |
||
221 |
id := something. |
|
222 |
||
223 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
|
224 |
||
253 | 225 |
level |
226 |
"answer the level in hierarchy (0=root)" |
|
227 |
||
228 |
^level |
|
84 | 229 |
|
253 | 230 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
231 |
||
232 |
level: anInteger |
|
233 |
"set the level in hierarchy (0=root)" |
|
234 |
||
235 |
level := anInteger. |
|
84 | 236 |
|
237 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
|
238 |
||
253 | 239 |
name |
240 |
"return name" |
|
84 | 241 |
|
253 | 242 |
^ name |
84 | 243 |
|
244 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
|
245 |
||
253 | 246 |
name: aString |
247 |
"set the name that identifys me within my parent's context." |
|
248 |
||
249 |
name := aString. |
|
84 | 250 |
|
253 | 251 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
252 |
||
435 | 253 |
ordered:aBoolean |
254 |
"set/clear the children-are-ordered flag. |
|
255 |
If unordered (the default), children are kept in a set; |
|
256 |
if ordered, they are kept in an orderedCollection." |
|
257 |
||
258 |
aBoolean ifTrue:[ |
|
259 |
children := children asOrderedCollection |
|
260 |
] ifFalse:[ |
|
261 |
children := children asSet |
|
262 |
]. |
|
263 |
! |
|
264 |
||
253 | 265 |
parent:something |
266 |
"set parent" |
|
267 |
||
268 |
parent := something. |
|
84 | 269 |
|
270 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
|
271 |
||
272 |
pathName |
|
273 |
"return a full path name to me" |
|
274 |
||
359 | 275 |
|n| |
84 | 276 |
|
359 | 277 |
n := self delimiterString , name. |
278 |
parent isNil ifTrue: [^ n]. |
|
279 |
^ parent pathName , n. |
|
280 |
||
281 |
"Modified: 10.10.1994 / 16:13:33 / W.Olberding" |
|
282 |
"Modified: 15.4.1997 / 16:52:02 / cg" |
|
283 |
! ! |
|
84 | 284 |
|
253 | 285 |
!HierarchyNode methodsFor:'constants'! |
84 | 286 |
|
253 | 287 |
delimiter |
288 |
"Answer the delimiter character" |
|
84 | 289 |
|
253 | 290 |
^$/ |
84 | 291 |
|
253 | 292 |
"Modified: 10.10.94 / 16:13:35 / W.Olberding"! |
84 | 293 |
|
253 | 294 |
delimiterString |
295 |
"Answer the delimiter character asString" |
|
84 | 296 |
|
253 | 297 |
^self delimiter asString |
84 | 298 |
|
253 | 299 |
"Modified: 10.10.94 / 16:13:35 / W.Olberding"! ! |
84 | 300 |
|
439 | 301 |
!HierarchyNode methodsFor:'copy'! |
302 |
||
303 |
copyWithParent:aParent |
|
566 | 304 |
|node| |
439 | 305 |
|
306 |
node := self copy. |
|
307 |
node parent:aParent. |
|
308 |
node level:((aParent level) + 1). |
|
309 |
node children:(children collect:[:aChild| aChild copyWithParent:self]). |
|
310 |
^ node |
|
311 |
! ! |
|
312 |
||
84 | 313 |
!HierarchyNode methodsFor:'hierarchy operations'! |
314 |
||
359 | 315 |
addChild:anObjectOfMyKind |
253 | 316 |
"add anObjectOfMyKind to my children" |
317 |
||
318 |
anObjectOfMyKind parent: self. |
|
319 |
anObjectOfMyKind level: level +1. |
|
359 | 320 |
self children add:anObjectOfMyKind. |
253 | 321 |
|
359 | 322 |
"Modified: 10.10.1994 / 16:13:34 / W.Olberding" |
323 |
"Modified: 15.4.1997 / 16:49:17 / cg" |
|
324 |
! |
|
84 | 325 |
|
253 | 326 |
addChildren: aCollectionWithElementsOfMyKind |
327 |
"add aCollectionWithElementsOfMyKind to my children" |
|
328 |
||
359 | 329 |
aCollectionWithElementsOfMyKind do:[:child | |
330 |
child parent: self. |
|
331 |
child level: level +1. |
|
253 | 332 |
]. |
359 | 333 |
self children addAll:aCollectionWithElementsOfMyKind. |
84 | 334 |
|
359 | 335 |
"Modified: 10.10.1994 / 16:13:34 / W.Olberding" |
336 |
"Modified: 15.4.1997 / 16:49:03 / cg" |
|
337 |
! |
|
84 | 338 |
|
339 |
allChildren |
|
340 |
"Answer my immediate children plus all my grandchildren |
|
341 |
-- in hierachical order and alphabeticaly sorted by name within one level." |
|
342 |
||
343 |
| kids | |
|
344 |
kids := OrderedCollection new. |
|
345 |
self addAllChildrenTo: kids. |
|
346 |
^kids. |
|
347 |
||
348 |
"Modified: 10.10.94 / 16:13:34 / W.Olberding"! |
|
349 |
||
253 | 350 |
allParents |
351 |
"return all my parents (next first - root last)" |
|
352 |
||
353 |
parent isNil ifTrue: [ ^OrderedCollection new: 0 ] |
|
354 |
ifFalse: [ ^parent, parent allParents ]. |
|
355 |
||
356 |
"Modified: 10.10.94 / 16:13:34 / W.Olberding"! |
|
357 |
||
358 |
collapse |
|
359 |
"Hide my children in hierachical printouts." |
|
360 |
||
361 |
hide := true |
|
362 |
||
363 |
"Modified: 10.10.94 / 16:13:34 / W.Olberding"! |
|
364 |
||
365 |
collapseAll |
|
359 | 366 |
"Hide my children and all my grandchildren in hierachical printouts." |
253 | 367 |
|
359 | 368 |
hide := true. |
369 |
self children do: [:kid | kid collapseAll ]. |
|
84 | 370 |
|
359 | 371 |
"Modified: 10.10.1994 / 16:13:34 / W.Olberding" |
372 |
"Modified: 15.4.1997 / 16:49:34 / cg" |
|
373 |
! |
|
84 | 374 |
|
375 |
expand |
|
376 |
"Show my immediate children in hierachical printouts." |
|
377 |
||
378 |
hide := false. |
|
379 |
||
380 |
"Modified: 10.10.94 / 16:13:34 / W.Olberding"! |
|
381 |
||
253 | 382 |
expandAll |
359 | 383 |
"Show my children and all grand children in hierachical printouts." |
253 | 384 |
|
359 | 385 |
hide := false. |
386 |
self children do: [:kid | kid expandAll ]. |
|
253 | 387 |
|
359 | 388 |
"Modified: 10.10.1994 / 16:13:34 / W.Olberding" |
389 |
"Modified: 15.4.1997 / 16:49:48 / cg" |
|
390 |
! |
|
253 | 391 |
|
392 |
parent |
|
393 |
"return parent" |
|
84 | 394 |
|
253 | 395 |
^ parent |
396 |
||
397 |
"Modified: 10.10.94 / 16:13:34 / W.Olberding"! |
|
398 |
||
399 |
removeAllChildren |
|
400 |
"Remove all children of me from the tree, i.e. let them |
|
401 |
forget myself as parent." |
|
402 |
||
359 | 403 |
| kids | |
84 | 404 |
|
359 | 405 |
kids := self allChildren. |
406 |
kids do: [:kid | kid parent: nil ]. |
|
435 | 407 |
children := childCollectionClass new. |
359 | 408 |
|
409 |
"Modified: 10.10.1994 / 16:13:34 / W.Olberding" |
|
410 |
"Modified: 15.4.1997 / 16:50:01 / cg" |
|
411 |
! |
|
84 | 412 |
|
413 |
removeChild: anObjectOfMyKind |
|
359 | 414 |
"remove anObjectOfMyKind from my children" |
84 | 415 |
|
416 |
anObjectOfMyKind parent: nil. |
|
359 | 417 |
children remove: anObjectOfMyKind. |
84 | 418 |
|
359 | 419 |
"Modified: 10.10.1994 / 16:13:34 / W.Olberding" |
420 |
"Modified: 15.4.1997 / 16:50:23 / cg" |
|
84 | 421 |
! |
422 |
||
423 |
removeYourself |
|
424 |
"remove me and all my children" |
|
425 |
||
426 |
parent isNil ifTrue: [^nil]. |
|
427 |
parent removeChild: self. |
|
428 |
||
359 | 429 |
"Modified: 10.10.1994 / 16:13:34 / W.Olberding" |
430 |
"Modified: 15.4.1997 / 16:52:33 / cg" |
|
431 |
! |
|
84 | 432 |
|
433 |
withAllChildren |
|
434 |
"Answer me, my immediate children and all my grandchildren |
|
435 |
-- in hierachical order and alphabeticaly sorted by name within one level." |
|
436 |
||
437 |
| kids | |
|
438 |
kids := OrderedCollection with: self . |
|
439 |
self addAllChildrenTo: kids. |
|
440 |
^kids. |
|
441 |
||
442 |
"Modified: 10.10.94 / 16:13:34 / W.Olberding"! |
|
443 |
||
253 | 444 |
withAllShownChildren |
445 |
"Answer me, my immediate children and all my grandchildren which are |
|
446 |
currently not hidden. |
|
447 |
-- in hierachical order and alphabeticaly sorted by name within one level." |
|
84 | 448 |
|
449 |
| kids | |
|
253 | 450 |
kids := OrderedCollection with: self . |
451 |
self addAllShownChildrenTo: kids. |
|
452 |
^kids. |
|
84 | 453 |
|
454 |
"Modified: 10.10.94 / 16:13:34 / W.Olberding"! ! |
|
455 |
||
442 | 456 |
!HierarchyNode methodsFor:'hierarchy sequencable operations'! |
457 |
||
458 |
addChildAndSubChildren:aHierarchyNode after:aChild |
|
459 |
"add aHierarchyNode to my children after an existing child or at end" |
|
460 |
||
461 |
|node index| |
|
462 |
||
463 |
node := aHierarchyNode copyWithParent:self. |
|
464 |
||
465 |
(index := self indexOfChild:aChild) == 0 ifTrue:[ |
|
466 |
self children add:node |
|
467 |
] ifFalse:[ |
|
468 |
self children add:node afterIndex:index |
|
469 |
]. |
|
470 |
! |
|
471 |
||
472 |
addChildAndSubChildren:aHierarchyNode at:anIndex |
|
473 |
"add aHierarchyNode to my children at an index or at end" |
|
474 |
||
475 |
|node cseq| |
|
476 |
||
477 |
node := aHierarchyNode copyWithParent:self. |
|
478 |
cseq := self children. |
|
479 |
||
480 |
(cseq isSequenceable and:[cseq size >= anIndex]) ifTrue:[ |
|
481 |
cseq add:node beforeIndex:anIndex |
|
482 |
] ifFalse:[ |
|
483 |
cseq add:node |
|
484 |
] |
|
485 |
! |
|
486 |
||
487 |
indexOfChild:aChild |
|
488 |
|seq| |
|
489 |
||
490 |
aChild notNil ifTrue:[ |
|
491 |
seq := self children. |
|
492 |
seq isSequenceable ifTrue:[ |
|
493 |
^ seq findFirst:[:c| c == aChild ] |
|
494 |
] |
|
495 |
]. |
|
496 |
^ 0 |
|
497 |
! ! |
|
498 |
||
84 | 499 |
!HierarchyNode methodsFor:'initialize-release'! |
500 |
||
501 |
initialize |
|
359 | 502 |
"init some defaults" |
84 | 503 |
|
504 |
" name |
|
359 | 505 |
id |
506 |
parent --" |
|
507 |
||
435 | 508 |
childCollectionClass := Set. |
359 | 509 |
children := Set new. |
510 |
||
84 | 511 |
" contents := Set new." |
512 |
||
359 | 513 |
disabled := false. |
514 |
hide := false. |
|
515 |
level := 0. "=root" |
|
516 |
||
517 |
"Modified: 10.10.1994 / 16:13:35 / W.Olberding" |
|
518 |
"Modified: 15.4.1997 / 16:50:44 / cg" |
|
519 |
! ! |
|
84 | 520 |
|
253 | 521 |
!HierarchyNode methodsFor:'private'! |
522 |
||
359 | 523 |
addAllChildrenTo:aCollection |
524 |
"Add all my children in hierachical and alphabetical order |
|
525 |
to aCollection." |
|
526 |
||
527 |
|myChildren| |
|
84 | 528 |
|
435 | 529 |
"/ myChildren := children asSortedCollection:[:x :y | x name < y name ]. |
530 |
myChildren := self children. |
|
359 | 531 |
myChildren do:[:aChild | |
532 |
aCollection addLast: aChild. |
|
533 |
aChild addAllChildrenTo:aCollection. |
|
534 |
]. |
|
84 | 535 |
|
359 | 536 |
"Modified: 10.10.1994 / 16:13:35 / W.Olberding" |
537 |
"Modified: 15.4.1997 / 16:47:53 / cg" |
|
538 |
! |
|
84 | 539 |
|
253 | 540 |
addAllShownChildrenTo: aCollection |
359 | 541 |
"Add all my children in hierachical and alphabetical order |
542 |
if they are not hidden." |
|
543 |
||
544 |
|myChildren| |
|
84 | 545 |
|
359 | 546 |
hide ifTrue: [^self]. |
435 | 547 |
"/ myChildren := self children asSortedCollection:[:x :y | x name < y name ]. |
548 |
myChildren := self children. |
|
359 | 549 |
myChildren do: [:aChild | |
550 |
aCollection addLast: aChild. |
|
551 |
aChild addAllShownChildrenTo: aCollection. |
|
552 |
]. |
|
84 | 553 |
|
359 | 554 |
"Modified: 10.10.1994 / 16:13:35 / W.Olberding" |
555 |
"Modified: 15.4.1997 / 16:53:08 / cg" |
|
556 |
! ! |
|
84 | 557 |
|
253 | 558 |
!HierarchyNode methodsFor:'queries'! |
84 | 559 |
|
253 | 560 |
childrenHidden |
561 |
"Answer true if my children shall be hidden |
|
562 |
in hierachical printouts etc." |
|
563 |
||
564 |
^hide. |
|
565 |
||
566 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
|
567 |
||
568 |
childrenShown |
|
569 |
"Answer true if my children shall be shown |
|
570 |
in hierachical printouts etc." |
|
571 |
||
572 |
^hide not. |
|
573 |
||
574 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
|
575 |
||
576 |
hasChildren |
|
577 |
||
578 |
^children size > 0. |
|
579 |
||
580 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
|
581 |
||
582 |
isCollapsable |
|
583 |
"Answer true if I have shown children" |
|
584 |
||
585 |
self hasChildren ifTrue: [ ^hide == false ]. |
|
586 |
^false. |
|
587 |
||
588 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! |
|
589 |
||
590 |
isExpandable |
|
591 |
"Answer true if I have hidden children" |
|
592 |
||
593 |
self hasChildren ifTrue: [ ^hide == true ]. |
|
594 |
^false. |
|
595 |
||
596 |
"Modified: 10.10.94 / 16:13:33 / W.Olberding"! ! |
|
597 |
||
359 | 598 |
!HierarchyNode class methodsFor:'documentation'! |
253 | 599 |
|
600 |
version |
|
566 | 601 |
^ '$Header: /cvs/stx/stx/libwidg2/HierarchyNode.st,v 1.12 1997-10-21 18:33:09 cg Exp $' |
253 | 602 |
! ! |