AbstractHierarchicalItem.st
changeset 5728 6ff85a3c7bb2
parent 5720 b51c3c6bf81e
child 5739 75d2126f9b5d
--- a/AbstractHierarchicalItem.st	Fri Mar 23 15:48:39 2018 +0100
+++ b/AbstractHierarchicalItem.st	Tue Mar 27 09:51:06 2018 +0200
@@ -321,6 +321,32 @@
     "Modified: / 08-03-2018 / 21:06:13 / stefan"
 !
 
+expandLevels:numLevels
+    "expand children numLevels down"
+
+    numLevels == 0 ifTrue:[^ self].
+    self children do:[:each |
+        each expand.
+        each expandLevels:(numLevels - 1).
+    ].
+!
+
+expandLevels:numLevels max:maxNumExpandedHolder
+    "expand children numLevels down"
+
+    numLevels == 0 ifTrue:[^ self].
+    maxNumExpandedHolder value <= 0 ifTrue:[^ self].
+
+    self children do:[:each |
+        each expand.
+    ].
+
+    maxNumExpandedHolder value:(maxNumExpandedHolder value - self children size).
+    self children do:[:each |
+        each expandLevels:(numLevels - 1) max:maxNumExpandedHolder.
+    ].
+!
+
 labelPath
     "return my label-path as an ordered collection of individual labels"