#FEATURE by cg
class: AbstractHierarchicalItem
added:
#allExpandedItemsDo:
#allParents
#labelPath
--- 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"