--- a/HierarchicalItem.st Thu Aug 26 11:20:54 1999 +0200
+++ b/HierarchicalItem.st Fri Aug 27 17:34:38 1999 +0200
@@ -451,6 +451,18 @@
^ aList
!
+addAll:aList sortBlock:aBlock
+ "add children sorted
+ "
+ aList notNil ifTrue:[
+ aBlock isNil ifTrue:[
+ ^ self addAll:aList
+ ].
+ aList do:[:el|self add:el sortBlock:aBlock]
+ ].
+ ^ aList
+!
+
addAllFirst:aCollectionOfItems
"add children at the beginning
"
@@ -493,6 +505,21 @@
]
!
+removeAll:aList
+ "remove all children in the collection
+ "
+ |index|
+
+ aList size ~~ 0 ifTrue:[
+ aList do:[:el|
+ index := self identityIndexOf:el.
+ index ~~ 0 ifTrue:[
+ self removeIndex:index
+ ]
+ ]
+ ]
+!
+
removeFromIndex:startIndex toIndex:stopIndex
"remove the children from startIndex up to and including
the child under stopIndex.
@@ -998,6 +1025,26 @@
^ children identityIndexOf:aChild startingAt:startIndex
].
^ 0
+!
+
+recursiveDetect:aOneArgBlock
+ "recursive find the first child, for which evaluation
+ of the block returns true; if none nil is returned
+ "
+ |child|
+
+ self children notNil ifTrue:[
+ children do:[:aChild|
+ (aOneArgBlock value:aChild) ifTrue:[
+ ^ aChild
+ ].
+
+ (child := aChild recursiveDetect:aOneArgBlock) notNil ifTrue:[
+ ^ child
+ ]
+ ]
+ ].
+ ^ nil
! !
!HierarchicalItem::Example class methodsFor:'instance creation'!
@@ -1138,5 +1185,5 @@
!HierarchicalItem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItem.st,v 1.7 1999-08-26 09:20:54 tm Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItem.st,v 1.8 1999-08-27 15:34:38 tm Exp $'
! !