VDBThreadGroupPresenter.st
changeset 219 6ab12a17ca3b
parent 212 62bb14c71a71
child 264 23960fcb9dac
--- a/VDBThreadGroupPresenter.st	Wed Mar 17 12:22:55 2021 +0000
+++ b/VDBThreadGroupPresenter.st	Tue May 18 11:21:13 2021 +0100
@@ -91,6 +91,40 @@
     ^ threadGroup
 ! !
 
+!VDBThreadGroupPresenter methodsFor:'change & update'!
+
+updateChildren
+    | childrenToRemove childrenToAdd |
+
+    children isNil ifTrue: [ ^ self ].
+    childrenToRemove := children copy.
+    childrenToAdd := #().
+
+    threadGroup threads do: [:thread |  
+        | child |
+
+        child := children detect: [:each | each thread == thread ] ifNone: nil.
+        child notNil ifTrue: [ 
+            childrenToRemove remove: child.
+            child updateChildren.
+        ] ifFalse: [ 
+            child := VDBThreadPresenter new
+                        setThread: thread;
+                        parent: self;
+                        yourself.
+            childrenToAdd := childrenToAdd copyWith: child.
+        ].
+    ].
+    childrenToRemove notEmpty ifTrue: [ 
+        self removeAll: childrenToRemove.
+    ].
+    childrenToAdd notEmpty ifTrue: [ 
+        self addAll: childrenToAdd.
+    ].
+
+    "Modified: / 17-05-2021 / 16:24:15 / Jan Vrany <jan.vrany@labware.com>"
+! !
+
 !VDBThreadGroupPresenter methodsFor:'initialization'!
 
 setThreadGroup: aGDBThreadGroup