#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Mon, 16 Oct 2017 14:23:26 +0200
changeset 5623 bc0518c6c923
parent 5621 bc187db92ab4
child 5624 c8e2d911f9c4
#FEATURE by cg class: AbstractHierarchicalItem added: #allExpandedItemsDo: #allParents #labelPath
AbstractHierarchicalItem.st
--- a/AbstractHierarchicalItem.st	Wed Oct 11 14:00:04 2017 +0200
+++ b/AbstractHierarchicalItem.st	Mon Oct 16 14:23:26 2017 +0200
@@ -320,6 +320,15 @@
     ].
 !
 
+labelPath
+    "return my label-path as an ordered collection of individual labels"
+
+    ^ ({self} , self allParents) reverse collect:#label
+
+    "Created: / 16-10-2017 / 13:09:10 / cg"
+    "Modified: / 16-10-2017 / 14:16:46 / cg"
+!
+
 makeVisible
     "expand all my parents"
 
@@ -897,6 +906,19 @@
 
 !AbstractHierarchicalItem methodsFor:'enumerating'!
 
+allExpandedItemsDo:aBlock
+    "recursively enumerate all expanded nodes 
+     (depth first; parent before children)"
+    
+    self recursiveDo:[:each |
+        each isExpanded ifTrue:[
+            aBlock value:each.
+        ].
+    ].
+
+    "Created: / 16-10-2017 / 14:19:00 / cg"
+!
+
 collect:aBlock
     "for each child in the receiver (non recursive), evaluate the argument, aBlock
      and return a new collection with the results"
@@ -1108,6 +1130,18 @@
 
 !AbstractHierarchicalItem methodsFor:'enumerating parents'!
 
+allParents
+    "return a collection of all parents (in parent, grandparent, ... order)"
+
+    |parents|
+
+    parents := OrderedCollection new.
+    self parentsDo:[:p | parents add:p].
+    ^ parents.
+
+    "Created: / 16-10-2017 / 13:08:45 / cg"
+!
+
 parentsDetect:aBlock
     "find the first parent, for which evaluation of the block returns
      true; if none does so, report an error"