HierarchyNode.st
changeset 359 a4f931c5a7d9
parent 253 01498f4ffcca
child 435 14705c0b1ab9
--- a/HierarchyNode.st	Tue Apr 15 10:13:08 1997 +0200
+++ b/HierarchyNode.st	Tue Apr 15 16:54:52 1997 +0200
@@ -18,7 +18,7 @@
 	category:'Interface-Support'
 !
 
-!HierarchyNode  class methodsFor:'documentation'!
+!HierarchyNode class methodsFor:'documentation'!
 
 copyright 
 "
@@ -52,58 +52,89 @@
 "
 ! !
 
-!HierarchyNode  class methodsFor:'instance creation'!
+!HierarchyNode class methodsFor:'instance creation'!
 
 new
 
 	^super new initialize
 !
 
-newAsTreeFromSmalltalkClass: aClass
-
-       "create a tree of nodes with aClass and all its
-	subclasses as contents."
+newAsTreeFromSmalltalkClass:aClass
+    "create a tree of nodes with aClass and all its
+    subclasses as contents."
 
-	|newInst|
-	newInst := super new initialize.
-	newInst name: aClass name.
-	newInst contents: aClass.
-	newInst level: aClass allSuperclasses size.
-	aClass subclasses do: [ :aSubClass |
-	    newInst addChild: (self newAsTreeFromSmalltalkClass: aSubClass).
-	].
-       ^newInst
+    ^ self
+        newAsTreeFromSmalltalkClass:aClass
+        level:(aClass allSuperclasses size).
+
+    "Modified: 15.4.1997 / 16:34:23 / cg"
 !
 
-newWithName: aString
+newAsTreeFromSmalltalkClass:aClass level:level
+    "create a tree of nodes with aClass and all its
+     subclasses as contents. Set the initial level as given."
+
+    |newInst|
+
+    newInst := super new initialize.
+    newInst name:aClass name.
+    newInst contents:aClass.
+    newInst level:level.
+    aClass subclasses do:[:aSubClass |
+        newInst addChild:(self newAsTreeFromSmalltalkClass:aSubClass level:level+1).
+    ].
+    ^newInst
 
-	|newInst|
-	newInst := super new initialize.
-	newInst name: aString.
-       ^newInst
+    "Created: 15.4.1997 / 16:33:52 / cg"
+    "Modified: 15.4.1997 / 16:34:52 / cg"
+!
+
+newWithName:aString
+    "create a new node with a name"
+
+    |newInst|
+
+    newInst := super new initialize.
+    newInst name: aString.
+    ^newInst
+
+    "Modified: 15.4.1997 / 16:32:06 / cg"
 !
 
 newWithName: aString andId: anId
+    "create a new node with a name and id"
 
-	|newInst|
-	newInst := super new initialize.
-	newInst name: aString.
-	newInst id:   anId.
-	^newInst
+    |newInst|
+
+    newInst := super new initialize.
+    newInst name: aString.
+    newInst id:   anId.
+    ^newInst
+
+    "Modified: 15.4.1997 / 16:32:22 / cg"
 ! !
 
 !HierarchyNode methodsFor:'accessing'!
 
-children: aCollectionWithElementsOfMyKind 
+children
+    "Answer my immediate children."
+
+    ^ children
+
+	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
+
+children:aCollectionWithElementsOfMyKind 
     "set my children"
 
-    aCollectionWithElementsOfMyKind do: [:child | 
-	 child parent: self.
-	 child level: level +1.
+    aCollectionWithElementsOfMyKind do:[:child | 
+         child parent: self.
+         child level: level + 1.
     ].
-    children :=   aCollectionWithElementsOfMyKind.
+    children := aCollectionWithElementsOfMyKind.
 
-	"Modified: 10.10.94 / 16:13:33 / W.Olberding"!
+    "Modified: 10.10.1994 / 16:13:33 / W.Olberding"
+    "Modified: 15.4.1997 / 16:48:38 / cg"
+!
 
 contents
     "Answer the contents of me (e.g. a set of items)"
@@ -202,10 +233,15 @@
 pathName
     "return a full path name to me"
 
-      parent isNil ifTrue: [^ (self delimiterString), name].
-      ^parent pathName, (self delimiterString), name.
+    |n|
 
-	"Modified: 10.10.94 / 16:13:33 / W.Olberding"! !
+    n := self delimiterString , name.
+    parent isNil ifTrue: [^ n].
+    ^ parent pathName , n.
+
+    "Modified: 10.10.1994 / 16:13:33 / W.Olberding"
+    "Modified: 15.4.1997 / 16:52:02 / cg"
+! !
 
 !HierarchyNode methodsFor:'constants'!
 
@@ -225,25 +261,29 @@
 
 !HierarchyNode methodsFor:'hierarchy operations'!
 
-addChild: anObjectOfMyKind 
+addChild:anObjectOfMyKind 
     "add anObjectOfMyKind to my children"
 
     anObjectOfMyKind parent: self.
     anObjectOfMyKind level: level +1.
-    children add:  anObjectOfMyKind.
+    self children add:anObjectOfMyKind.
 
-	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
+    "Modified: 10.10.1994 / 16:13:34 / W.Olberding"
+    "Modified: 15.4.1997 / 16:49:17 / cg"
+!
 
 addChildren: aCollectionWithElementsOfMyKind 
     "add aCollectionWithElementsOfMyKind to my children"
 
-    aCollectionWithElementsOfMyKind do: [:child | 
-	 child parent: self.
-	 child level: level +1.
+    aCollectionWithElementsOfMyKind do:[:child | 
+         child parent: self.
+         child level: level +1.
     ].
-    children addAll:  aCollectionWithElementsOfMyKind.
+    self children addAll:aCollectionWithElementsOfMyKind.
 
-	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
+    "Modified: 10.10.1994 / 16:13:34 / W.Olberding"
+    "Modified: 15.4.1997 / 16:49:03 / cg"
+!
 
 allChildren
     "Answer my immediate children plus all my grandchildren
@@ -264,13 +304,6 @@
 
 	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
 
-children
-    "Answer my immediate children."
-
-    ^ children
-
-	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
-
 collapse 
       "Hide my children in hierachical printouts."
 
@@ -279,12 +312,14 @@
 	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
 
 collapseAll 
-      "Hide my children and all my grandchildren in hierachical printouts."
+    "Hide my children and all my grandchildren in hierachical printouts."
 
-	 hide := true.
-	 children do: [ :kid | kid collapseAll ].
+    hide := true.
+    self children do: [:kid | kid collapseAll ].
 
-	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
+    "Modified: 10.10.1994 / 16:13:34 / W.Olberding"
+    "Modified: 15.4.1997 / 16:49:34 / cg"
+!
 
 expand 
       "Show my immediate children in hierachical printouts."
@@ -294,12 +329,14 @@
 	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
 
 expandAll 
-      "Show my children and all grand children in hierachical printouts."
+    "Show my children and all grand children in hierachical printouts."
 
-	 hide := false.
-	 children do: [ :kid | kid expandAll ].
+    hide := false.
+    self children do: [:kid | kid expandAll ].
 
-	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
+    "Modified: 10.10.1994 / 16:13:34 / W.Olberding"
+    "Modified: 15.4.1997 / 16:49:48 / cg"
+!
 
 parent
     "return parent"
@@ -312,21 +349,25 @@
     "Remove all children of me from the tree, i.e. let them
      forget myself as parent."
 
-     | kids |
-     kids := self allChildren.
-     kids do: [:kid | kid parent: nil ].
-     children := Set new.
+    | kids |
 
-	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
+    kids := self allChildren.
+    kids do: [:kid | kid parent: nil ].
+    children := Set new.
+
+    "Modified: 10.10.1994 / 16:13:34 / W.Olberding"
+    "Modified: 15.4.1997 / 16:50:01 / cg"
+!
 
 removeChild: anObjectOfMyKind 
-    "remove  anObjectOfMyKind from my children"
+    "remove anObjectOfMyKind from my children"
 
     anObjectOfMyKind parent: nil.
     children rehash.
-    children  remove:  anObjectOfMyKind.
+    children remove: anObjectOfMyKind.
 
-	"Modified: 10.10.94 / 16:13:34 / W.Olberding"
+    "Modified: 10.10.1994 / 16:13:34 / W.Olberding"
+    "Modified: 15.4.1997 / 16:50:23 / cg"
 !
 
 removeYourself
@@ -335,7 +376,9 @@
     parent isNil ifTrue: [^nil].
     parent removeChild: self.
 
-	"Modified: 10.10.94 / 16:13:34 / W.Olberding"!
+    "Modified: 10.10.1994 / 16:13:34 / W.Olberding"
+    "Modified: 15.4.1997 / 16:52:33 / cg"
+!
 
 withAllChildren
     "Answer me, my immediate children and all my grandchildren
@@ -363,48 +406,58 @@
 !HierarchyNode methodsFor:'initialize-release'!
 
 initialize
-	"init some defaults"
+        "init some defaults"
 
      "  name 
-	id 
-	parent --"
-	children := Set new.
+        id 
+        parent --"
+
+    children := Set new.
+
        " contents    := Set new."
-	disabled := false.
-	hide     := false.
-	level    := 0. "=root"
 
-	"Modified: 10.10.94 / 16:13:35 / W.Olberding"! !
+    disabled := false.
+    hide     := false.
+    level    := 0. "=root"
+
+    "Modified: 10.10.1994 / 16:13:35 / W.Olberding"
+    "Modified: 15.4.1997 / 16:50:44 / cg"
+! !
 
 !HierarchyNode methodsFor:'private'!
 
-addAllChildrenTo: aCollection
-	"Add all my children in hierachical and alphabetical order."
+addAllChildrenTo:aCollection
+    "Add all my children in hierachical and alphabetical order
+     to aCollection."
+
+    |myChildren|
 
-	|myChildren|
-	myChildren := children asSortedCollection:
-			[:x :y | x name < y name ].
-	myChildren do: [:aChild |
-		aCollection addLast: aChild.
-		aChild addAllChildrenTo: aCollection.
-	].
+    myChildren := children asSortedCollection:[:x :y | x name < y name ].
+    myChildren do:[:aChild |
+        aCollection addLast: aChild.
+        aChild addAllChildrenTo:aCollection.
+    ].
 
-	"Modified: 10.10.94 / 16:13:35 / W.Olberding"!
+    "Modified: 10.10.1994 / 16:13:35 / W.Olberding"
+    "Modified: 15.4.1997 / 16:47:53 / cg"
+!
 
 addAllShownChildrenTo: aCollection
-	"Add all my children in hierachical and alphabetical order
-	 if they are not hidden."
+    "Add all my children in hierachical and alphabetical order
+     if they are not hidden."
+
+    |myChildren|
 
-	|myChildren|
-	hide ifTrue: [^self].
-	myChildren := children asSortedCollection:
-			[:x :y | x name < y name ].
-	myChildren do: [:aChild |
-		aCollection addLast: aChild.
-		aChild addAllShownChildrenTo: aCollection.
-	].
+    hide ifTrue: [^self].
+    myChildren := self children asSortedCollection:[:x :y | x name < y name ].
+    myChildren do: [:aChild |
+        aCollection addLast: aChild.
+        aChild addAllShownChildrenTo: aCollection.
+    ].
 
-	"Modified: 10.10.94 / 16:13:35 / W.Olberding"! !
+    "Modified: 10.10.1994 / 16:13:35 / W.Olberding"
+    "Modified: 15.4.1997 / 16:53:08 / cg"
+! !
 
 !HierarchyNode methodsFor:'queries'!
 
@@ -446,8 +499,8 @@
 
 	"Modified: 10.10.94 / 16:13:33 / W.Olberding"! !
 
-!HierarchyNode  class methodsFor:'documentation'!
+!HierarchyNode class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchyNode.st,v 1.4 1996-10-11 14:40:54 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchyNode.st,v 1.5 1997-04-15 14:54:52 cg Exp $'
 ! !