#DOCUMENTATION by cg
class: AbstractHierarchicalItem
comment/format in:
#allParents
#parentsDetect:
#parentsDo:
changed:
#parentsDetect:ifNone:
#recursiveSetExpandedAndAddToListHelper:
--- a/AbstractHierarchicalItem.st Sat Oct 13 09:42:02 2018 +0200
+++ b/AbstractHierarchicalItem.st Thu Oct 18 00:36:02 2018 +0200
@@ -1289,7 +1289,7 @@
!AbstractHierarchicalItem methodsFor:'enumerating parents'!
allParents
- "return a collection of all parents (in parent, grandparent, ... order)"
+ "return a collection of all parents (bottom to top, ie. in parent, grandparent, ... order)"
|parents|
@@ -1301,24 +1301,18 @@
!
parentsDetect:aBlock
- "find the first parent, for which evaluation of the block returns
+ "find the first parent (bottom to top), for which evaluation of the block returns
true; if none does so, report an error"
^ self parentsDetect:aBlock ifNone:[self errorNotFound]
!
parentsDetect:aBlock ifNone:anExceptionBlock
- "find the first parent, for which evaluation of the block returns
+ "find the first parent (bottom to top), for which evaluation of the block returns
true; if none does so, return the evaluation of anExceptionBlock"
- |prnt|
-
- prnt := self.
-
- self synchronized:[
- [(prnt := prnt parent) notNil and:[prnt isHierarchicalItem]] whileTrue:[
- (aBlock value:prnt) ifTrue:[^ prnt]
- ]
+ self parentsDo:[:prnt |
+ (aBlock value:prnt) ifTrue:[^ prnt]
].
^ anExceptionBlock value
@@ -1326,7 +1320,7 @@
!
parentsDo:aBlock
- "evaluate a block for each parent"
+ "evaluate a block for each parent (bottom to top)"
|prnt|
@@ -1714,13 +1708,19 @@
Helper; not synchronized - should only be called internally
within a synchronized region."
- self setExpanded:true.
-
- self nonCriticalFrom:1 to:nil do:[:eachChild|
- aList add:eachChild.
-
- eachChild canRecursiveExpand ifTrue:[
- eachChild recursiveSetExpandedAndAddToListHelper:aList.
+ |toDo toExpand|
+
+ toDo := OrderedCollection with:self.
+ [ toDo notEmpty ] whileTrue:[
+ toExpand := toDo removeFirst.
+ toExpand setExpanded:true.
+
+ toExpand nonCriticalFrom:1 to:nil do:[:eachChild|
+ aList add:eachChild.
+
+ eachChild canRecursiveExpand ifTrue:[
+ toDo add:eachChild
+ ].
].
].