SelectionInHierarchy.st
changeset 252 4db843d36c46
parent 86 4d7dbb5f1719
child 253 01498f4ffcca
--- a/SelectionInHierarchy.st	Thu Oct 10 19:26:05 1996 +0200
+++ b/SelectionInHierarchy.st	Fri Oct 11 16:35:45 1996 +0200
@@ -12,13 +12,13 @@
 "
 
 Model subclass:#SelectionInHierarchy
-	 instanceVariableNames:'root list selection'
-	 classVariableNames:''
-	 poolDictionaries:''
-	 category:'Interface-Support-Models'
+	instanceVariableNames:'root list selection'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Interface-Support-Models'
 !
 
-!SelectionInHierarchy class methodsFor:'documentation'!
+!SelectionInHierarchy  class methodsFor:'documentation'!
 
 copyright 
 "
@@ -35,24 +35,37 @@
 "
 !
 
-version
-    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInHierarchy.st,v 1.2 1995-11-11 16:29:20 cg Exp $'
-!
-
 documentation
 "
     model for a selection in a hierarchical list.
     See examples in SelectionInHierarchyView.
+
+    [Author:]
+        W. Olberding AEG Factory Automation
+
+    [See also:]
+        SelectionInHierarchyView
 "
 ! !
 
 !SelectionInHierarchy methodsFor:'accessing'!
 
-list
-	"Answer a collection of nodes representing the
-	list of currently viewed objects."
+add: aHierarchyNode  below: existingHierarchyNode
+	"Add a new HierarchyNode to the tree."
+
+
+	 existingHierarchyNode addChild: aHierarchyNode. 
+	 self setNewList.
 
-	^list
+	"Modified: 10.10.94 / 16:13:36 / W.Olberding"!
+
+add: aHierarchyNode  belowIndex: anIndex
+	"Add a new HierarchyNode to the tree below the node
+	which is found in the list at anIndex."
+
+       | existingHierarchyNode |
+	 existingHierarchyNode := list at: anIndex  ifAbsent: [^nil]. 
+	 self add: aHierarchyNode  below: existingHierarchyNode
 
 	"Modified: 10.10.94 / 16:13:36 / W.Olberding"!
 
@@ -70,35 +83,11 @@
 
 	"Modified: 10.10.94 / 16:13:36 / W.Olberding"!
 
-showCompleteHierarchyStartingAtNode: aHierarchyNode
-	"Set the hide-Flag to false for the hierarchy starting at aHierarchyNode"
-
-	 | |
-	aHierarchyNode isNil ifTrue: [^self].
-	aHierarchyNode hideToFalseForPath.
-	self setNewList.
-
-	"Modified: 10.10.94 / 16:13:36 / W.Olberding"!
-
-setHideToChildren: aBoolean startingAt: aHierarchyNode
-
-     "set the hide-Falg to aBoolean starting at aHierarchyNode down"
+list
+	"Answer a collection of nodes representing the
+	list of currently viewed objects."
 
-     |allNodes|
-
-     allNodes:= root allChildren.
-     allNodes do: [:each|
-	  each hide: aBoolean
-     ].
-     self setNewList.
-
-	"Modified: 10.10.94 / 16:13:36 / W.Olberding"!
-
-root: aHierarchyNode
-	"Set the root object - this means initialization."
-
-	root :=  aHierarchyNode.
-	self initialize.
+	^list
 
 	"Modified: 10.10.94 / 16:13:36 / W.Olberding"!
 
@@ -111,45 +100,6 @@
 
 	"Modified: 10.10.94 / 16:13:36 / W.Olberding"!
 
-add: aHierarchyNode  below: existingHierarchyNode
-	"Add a new HierarchyNode to the tree."
-
-
-	 existingHierarchyNode addChild: aHierarchyNode. 
-	 self setNewList.
-
-	"Modified: 10.10.94 / 16:13:36 / W.Olberding"!
-
-selectedPath 
-	"Answer the pathName to the currently selected node."
-
-	 | selectedNode |
-	selection isNil ifTrue: [^String new].
-	selectedNode := list at: selection ifAbsent: [^String new].   
-	^selectedNode pathName.
-
-	"Modified: 10.10.94 / 16:13:36 / W.Olberding"!
-
-add: aHierarchyNode  belowIndex: anIndex
-	"Add a new HierarchyNode to the tree below the node
-	which is found in the list at anIndex."
-
-       | existingHierarchyNode |
-	 existingHierarchyNode := list at: anIndex  ifAbsent: [^nil]. 
-	 self add: aHierarchyNode  below: existingHierarchyNode
-
-	"Modified: 10.10.94 / 16:13:36 / W.Olberding"!
-
-removeIndex: anIndex
-	"Remove the HierarchyNode and all its children
-	which is found in the list at anIndex."
-
-       | existingHierarchyNode |
-	 existingHierarchyNode := list at: anIndex ifAbsent: [^nil]. 
-	^self remove: existingHierarchyNode.
-
-	"Modified: 10.10.94 / 16:13:36 / W.Olberding"!
-
 removeBelow: existingHierarchyNode
 	"Remove all children below an existingHierarchyNode ."
 
@@ -167,64 +117,80 @@
 	 existingHierarchyNode := list at: anIndex ifAbsent: [^nil]. 
 	^self removeBelow: existingHierarchyNode.
 
-	"Modified: 10.10.94 / 16:13:37 / W.Olberding"! !
-
-!SelectionInHierarchy methodsFor:'selection'!
+	"Modified: 10.10.94 / 16:13:37 / W.Olberding"!
 
-selection
-	"Answer the current selection as
-	  anIndex of the selection list."
+removeIndex: anIndex
+	"Remove the HierarchyNode and all its children
+	which is found in the list at anIndex."
 
-	^selection
+       | existingHierarchyNode |
+	 existingHierarchyNode := list at: anIndex ifAbsent: [^nil]. 
+	^self remove: existingHierarchyNode.
 
 	"Modified: 10.10.94 / 16:13:36 / W.Olberding"!
 
-selection: anIndex
-	"Set the current selected object to be the element
-	at anIndex of the selection list."
+root: aHierarchyNode
+	"Set the root object - this means initialization."
+
+	root :=  aHierarchyNode.
+	self initialize.
+
+	"Modified: 10.10.94 / 16:13:36 / W.Olberding"!
 
-	anIndex isNil 
-	    ifTrue:  [ selection := 0]
-	    ifFalse: [
-		  (selection = anIndex) 
-		       ifTrue:  [^nil] 
-		       ifFalse: [selection := anIndex ].
-	    ].
-	self changed: #selection.
+selectedPath 
+	"Answer the pathName to the currently selected node."
+
+	 | selectedNode |
+	selection isNil ifTrue: [^String new].
+	selectedNode := list at: selection ifAbsent: [^String new].   
+	^selectedNode pathName.
 
 	"Modified: 10.10.94 / 16:13:36 / W.Olberding"!
 
-doubleClickSelection: anIndex
-	"Set the current selected object to be the element
-	at anIndex of the selection list.
-	Also expand or collapse the tree at that point."
+setHideToChildren: aBoolean startingAt: aHierarchyNode
+
+     "set the hide-Falg to aBoolean starting at aHierarchyNode down"
+
+     |allNodes|
 
-	self selection:  anIndex.  
-	self hideShow.
+     allNodes:= root allChildren.
+     allNodes do: [:each|
+	  each hide: aBoolean
+     ].
+     self setNewList.
+
+	"Modified: 10.10.94 / 16:13:36 / W.Olberding"!
+
+showCompleteHierarchyStartingAtNode: aHierarchyNode
+	"Set the hide-Flag to false for the hierarchy starting at aHierarchyNode"
+
+	 | |
+	aHierarchyNode isNil ifTrue: [^self].
+	aHierarchyNode hideToFalseForPath.
+	self setNewList.
 
 	"Modified: 10.10.94 / 16:13:36 / W.Olberding"! !
 
-!SelectionInHierarchy methodsFor:'private'!
-
-setNewList
-	"Travers the tree and build a new list."
-
-	list :=  root withAllShownChildren.
-	self changed: #list.
-
-	"Modified: 10.10.94 / 16:13:37 / W.Olberding"! !
-
 !SelectionInHierarchy methodsFor:'hierarchy manipulation'!
 
-hideShow
-	"If possible, expand or collaps the tree 
-	 at the currently selected node."
+collapse 
+	"If possible, collapse the tree  at the currently selected node.
+	 The tree structure can be restored again with #expand. "
 
 	 | selectedNode |
-	selectedNode := list at: selection.
-	selectedNode isExpandable  ifTrue: [ selectedNode expand.
-					     ^self setNewList. ].
-	selectedNode isCollapsable ifTrue: [ selectedNode collapse.
+	selectedNode := list at: selection.   
+	selectedNode isCollapsable ifTrue: [  selectedNode collapse.
+					      ^self setNewList. ].
+
+	"Modified: 10.10.94 / 16:13:37 / W.Olberding"!
+
+collapseAll 
+	"If possible, collapse the tree at the currently selected node.
+	 A latter #expand will show the next hierarchy level"
+
+	 | selectedNode |
+	selectedNode := list at: selection.   
+	selectedNode isCollapsable ifTrue: [  selectedNode collapseAll.
 					      ^self setNewList. ].
 
 	"Modified: 10.10.94 / 16:13:37 / W.Olberding"!
@@ -240,17 +206,6 @@
 
 	"Modified: 10.10.94 / 16:13:37 / W.Olberding"!
 
-collapse 
-	"If possible, collapse the tree  at the currently selected node.
-	 The tree structure can be restored again with #expand. "
-
-	 | selectedNode |
-	selectedNode := list at: selection.   
-	selectedNode isCollapsable ifTrue: [  selectedNode collapse.
-					      ^self setNewList. ].
-
-	"Modified: 10.10.94 / 16:13:37 / W.Olberding"!
-
 expandAll 
 	"If possible, expand  the tree compleately to all leaves
 	 at the currently selected node."
@@ -262,25 +217,19 @@
 
 	"Modified: 10.10.94 / 16:13:37 / W.Olberding"!
 
-collapseAll 
-	"If possible, collapse the tree at the currently selected node.
-	 A latter #expand will show the next hierarchy level"
+hideShow
+	"If possible, expand or collaps the tree 
+	 at the currently selected node."
 
 	 | selectedNode |
-	selectedNode := list at: selection.   
-	selectedNode isCollapsable ifTrue: [  selectedNode collapseAll.
+	selectedNode := list at: selection.
+	selectedNode isExpandable  ifTrue: [ selectedNode expand.
+					     ^self setNewList. ].
+	selectedNode isCollapsable ifTrue: [ selectedNode collapse.
 					      ^self setNewList. ].
 
 	"Modified: 10.10.94 / 16:13:37 / W.Olberding"! !
 
-!SelectionInHierarchy methodsFor:'testing & debugging'!
-
-root
-
-	^root
-
-	"Modified: 10.10.94 / 16:13:37 / W.Olberding"! !
-
 !SelectionInHierarchy methodsFor:'initialization'!
 
 initialize
@@ -291,4 +240,87 @@
 
 	"Modified: 10.10.94 / 16:13:37 / W.Olberding"! !
 
+!SelectionInHierarchy methodsFor:'private'!
 
+setNewList
+	"Travers the tree and build a new list."
+
+	list :=  root withAllShownChildren.
+	self changed: #list.
+
+	"Modified: 10.10.94 / 16:13:37 / W.Olberding"! !
+
+!SelectionInHierarchy methodsFor:'selection'!
+
+doubleClickSelection: anIndex
+        "Set the current selected object to be the element
+        at anIndex of the selection list.
+        Also expand or collapse the tree at that point."
+
+        self selectionIndex:  anIndex.  
+        self hideShow.
+
+    "Modified: 10.10.1994 / 16:13:36 / W.Olberding"
+    "Modified: 11.10.1996 / 15:19:35 / cg"
+!
+
+selection
+        "Answer the current selection as
+          anIndex of the selection list."
+
+        ^ self selectionIndex
+
+    "Modified: 10.10.1994 / 16:13:36 / W.Olberding"
+    "Modified: 11.10.1996 / 15:21:30 / cg"
+!
+
+selection: anIndex
+        "Set the current selected object to be the element
+        at anIndex of the selection list."
+
+     ^ self selectionIndex:anIndex
+
+    "Modified: 11.10.1996 / 15:21:15 / cg"
+!
+
+selectionIndex
+        "Answer the current selection as
+          anIndex of the selection list."
+
+    ^ selection
+
+    "Modified: 10.10.1994 / 16:13:36 / W.Olberding"
+    "Created: 11.10.1996 / 15:18:44 / cg"
+    "Modified: 11.10.1996 / 15:20:46 / cg"
+!
+
+selectionIndex: anIndex
+        "Set the current selected object to be the element
+        at anIndex of the selection list."
+
+        anIndex isNil 
+            ifTrue:  [ selection := 0]
+            ifFalse: [
+                  (selection = anIndex) 
+                       ifTrue:  [^nil] 
+                       ifFalse: [selection := anIndex ].
+            ].
+        self changed: #selection.
+
+    "Modified: 10.10.1994 / 16:13:36 / W.Olberding"
+    "Created: 11.10.1996 / 15:16:30 / cg"
+! !
+
+!SelectionInHierarchy methodsFor:'testing & debugging'!
+
+root
+
+	^root
+
+	"Modified: 10.10.94 / 16:13:37 / W.Olberding"! !
+
+!SelectionInHierarchy  class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInHierarchy.st,v 1.3 1996-10-11 14:35:45 cg Exp $'
+! !