#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Fri, 20 Oct 2017 14:15:24 +0200
changeset 5629 afcdc42d662f
parent 5628 afbbddcc2951
child 5630 fa152610de50
#FEATURE by cg class: TreeItem added: #allParents #label #labelPath #parentsDo:
TreeItem.st
--- a/TreeItem.st	Fri Oct 20 11:27:31 2017 +0200
+++ b/TreeItem.st	Fri Oct 20 14:15:24 2017 +0200
@@ -291,6 +291,22 @@
     "Modified (comment): / 04-02-2017 / 20:24:16 / cg"
 !
 
+label
+    "for protocol compatibility with herarchical item"
+    
+    ^ self name
+
+    "Created: / 20-10-2017 / 11:30:15 / cg"
+!
+
+labelPath
+    "for protocol compatibility with herarchical item"
+
+    ^ ({self} , self allParents) reverse collect:#label
+
+    "Created: / 20-10-2017 / 11:30:07 / cg"
+!
+
 level
     "get the nesting level"
 
@@ -441,6 +457,18 @@
 
 !TreeItem methodsFor:'accessing-hierarchy'!
 
+allParents
+    "return a collection of all parents (in parent, grandparent, ... order)"
+
+    |parents|
+
+    parents := OrderedCollection new.
+    self parentsDo:[:p | parents add:p].
+    ^ parents.
+
+    "Created: / 20-10-2017 / 11:31:06 / cg"
+!
+
 collapse 
     "hide all my children
     "
@@ -471,6 +499,20 @@
     self children notEmpty ifTrue:[
         children do:[:aChild| aChild expandAll ]
     ]
+!
+
+parentsDo:aBlock
+    "evaluate a block for each parent"
+
+    |prnt|
+
+    prnt := self.
+
+    [(prnt := prnt parent) notNil] whileTrue:[
+        aBlock value:prnt
+    ].
+
+    "Created: / 20-10-2017 / 11:31:41 / cg"
 ! !
 
 !TreeItem methodsFor:'accessing-mvc'!