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