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