supports dynamic read behavior for contents, label, children, and icon of tree items
authortz
Sat, 14 Feb 1998 17:15:32 +0100
changeset 762 df337e82f064
parent 761 d0cf8f76f1b6
child 763 dd29c58e8ea6
supports dynamic read behavior for contents, label, children, and icon of tree items
SelInTree.st
SelectionInTree.st
--- a/SelInTree.st	Sat Feb 14 17:13:58 1998 +0100
+++ b/SelInTree.st	Sat Feb 14 17:15:32 1998 +0100
@@ -13,7 +13,8 @@
 
 
 Model subclass:#SelectionInTree
-	instanceVariableNames:'root list selection showRoot'
+	instanceVariableNames:'root list selection showRoot contentsAction labelAction
+		childrenAction iconAction'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Interface-Support-Models'
@@ -71,15 +72,80 @@
 root:aRoot
     "set a new root
     "
+    root notNil ifTrue: [
+        root tree: nil
+    ].
+
     (root := aRoot) notNil ifTrue:[
-        root parent:nil
-    ].
+        root parent:nil.
+        root tree: self.
+    ]. 
     self recomputeList.
 
 ! !
 
 !SelectionInTree methodsFor:'accessing behavior'!
 
+childrenAction
+    "get children action block
+    "
+    ^childrenAction
+!
+
+childrenAction:aBlock
+    "set children action block
+    "
+    childrenAction := aBlock.
+
+    self changed:#list.
+    
+!
+
+contentsAction
+    "get contents action block
+    "
+    ^contentsAction
+!
+
+contentsAction:aBlock
+    "set contents action block
+    "
+    contentsAction := aBlock.
+
+    self changed:#list.
+    
+!
+
+iconAction
+    "get icon action block
+    "
+    ^iconAction
+!
+
+iconAction:aBlock
+    "set icon action block
+    "
+    iconAction := aBlock.
+
+    self changed:#list.
+    
+!
+
+labelAction
+    "get label action block
+    "
+    ^labelAction
+!
+
+labelAction:aBlock
+    "set label action block
+    "
+    labelAction := aBlock.
+
+    self changed:#list.
+    
+!
+
 showRoot
     "list with or without root
     "
@@ -239,6 +305,13 @@
     ].
 
 
+!
+
+update:something with:aParameter from:aModel
+
+    self dependents do:[:aDependent|
+        aDependent update:something with:aParameter from:aModel
+    ]
 ! !
 
 !SelectionInTree methodsFor:'enumerating'!
@@ -269,7 +342,7 @@
     list := OrderedCollection new.
 
     root notNil ifTrue:[
-        showRoot ifTrue:[
+        showRoot ifTrue:[   
             list add:root
         ].
         root recomputeList:list
@@ -335,5 +408,5 @@
 !SelectionInTree class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/Attic/SelInTree.st,v 1.8 1998-02-13 13:56:35 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/Attic/SelInTree.st,v 1.9 1998-02-14 16:15:32 tz Exp $'
 ! !
--- a/SelectionInTree.st	Sat Feb 14 17:13:58 1998 +0100
+++ b/SelectionInTree.st	Sat Feb 14 17:15:32 1998 +0100
@@ -13,7 +13,8 @@
 
 
 Model subclass:#SelectionInTree
-	instanceVariableNames:'root list selection showRoot'
+	instanceVariableNames:'root list selection showRoot contentsAction labelAction
+		childrenAction iconAction'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Interface-Support-Models'
@@ -71,15 +72,80 @@
 root:aRoot
     "set a new root
     "
+    root notNil ifTrue: [
+        root tree: nil
+    ].
+
     (root := aRoot) notNil ifTrue:[
-        root parent:nil
-    ].
+        root parent:nil.
+        root tree: self.
+    ]. 
     self recomputeList.
 
 ! !
 
 !SelectionInTree methodsFor:'accessing behavior'!
 
+childrenAction
+    "get children action block
+    "
+    ^childrenAction
+!
+
+childrenAction:aBlock
+    "set children action block
+    "
+    childrenAction := aBlock.
+
+    self changed:#list.
+    
+!
+
+contentsAction
+    "get contents action block
+    "
+    ^contentsAction
+!
+
+contentsAction:aBlock
+    "set contents action block
+    "
+    contentsAction := aBlock.
+
+    self changed:#list.
+    
+!
+
+iconAction
+    "get icon action block
+    "
+    ^iconAction
+!
+
+iconAction:aBlock
+    "set icon action block
+    "
+    iconAction := aBlock.
+
+    self changed:#list.
+    
+!
+
+labelAction
+    "get label action block
+    "
+    ^labelAction
+!
+
+labelAction:aBlock
+    "set label action block
+    "
+    labelAction := aBlock.
+
+    self changed:#list.
+    
+!
+
 showRoot
     "list with or without root
     "
@@ -239,6 +305,13 @@
     ].
 
 
+!
+
+update:something with:aParameter from:aModel
+
+    self dependents do:[:aDependent|
+        aDependent update:something with:aParameter from:aModel
+    ]
 ! !
 
 !SelectionInTree methodsFor:'enumerating'!
@@ -269,7 +342,7 @@
     list := OrderedCollection new.
 
     root notNil ifTrue:[
-        showRoot ifTrue:[
+        showRoot ifTrue:[   
             list add:root
         ].
         root recomputeList:list
@@ -335,5 +408,5 @@
 !SelectionInTree class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTree.st,v 1.8 1998-02-13 13:56:35 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTree.st,v 1.9 1998-02-14 16:15:32 tz Exp $'
 ! !