avoid loosing the selection when the list is updated
authorClaus Gittinger <cg@exept.de>
Tue, 14 Dec 1999 21:15:14 +0100
changeset 2487 4ac80975b91d
parent 2486 29a320ed5f2a
child 2488 65689c6d5bd6
avoid loosing the selection when the list is updated
ProcessMonitor.st
SemaphoreMonitor.st
--- a/ProcessMonitor.st	Tue Dec 14 15:33:52 1999 +0100
+++ b/ProcessMonitor.st	Tue Dec 14 21:15:14 1999 +0100
@@ -132,8 +132,7 @@
                          ]
                      ].
         newList ~= processes ifTrue:[
-            processes := WeakArray withAll:newList.
-            self updateStatus
+            self updateStatus:newList
         ].
     ].
     updateBlock notNil ifTrue:[
@@ -141,11 +140,11 @@
         Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay
     ].
 
-    "Modified: 3.7.1996 / 13:37:29 / stefan"
-    "Modified: 21.8.1997 / 15:40:40 / cg"
+    "Modified: / 3.7.1996 / 13:37:29 / stefan"
+    "Modified: / 14.12.1999 / 20:50:14 / cg"
 !
 
-updateStatus
+updateStatus:newProcessList
     "update status display of processes"
 
     |oldList list line dIndex interrupted contextCount 
@@ -159,19 +158,24 @@
 
     shown ifTrue:[
         oldList := listView list.
+
+        oldSelection := listView selection.
+        oldSelection notNil ifTrue:[
+            oldSelection := oldSelection collect:[:idx | |pI|
+                                            pI := idx-numHeaderLines.
+                                            (pI > processes size or:[pI < 1]) ifTrue:[
+                                                nil
+                                            ] ifFalse:[
+                                                processes at:pI
+                                            ]
+                                         ].
+            newSelection := OrderedCollection new.
+        ].
+
+        newProcessList notNil ifTrue:[
+            processes := WeakArray withAll:newProcessList.
+        ].
         processes notNil ifTrue:[
-            oldSelection := listView selection.
-            oldSelection notNil ifTrue:[
-                oldSelection := oldSelection collect:[:idx | |pI|
-                                                pI := idx-numHeaderLines.
-                                                (pI > processes size or:[pI < 1]) ifTrue:[
-                                                    nil
-                                                ] ifFalse:[
-                                                    processes at:pI
-                                                ]
-                                             ].
-                newSelection := OrderedCollection new.
-            ].
 
             list := OrderedCollection new:(processes size + numHeaderLines).
             list add:self titleLine.
@@ -417,7 +421,8 @@
     ]
 
     "Modified: / 3.7.1996 / 13:56:01 / stefan"
-    "Modified: / 7.9.1998 / 20:06:30 / cg"
+    "Created: / 14.12.1999 / 20:47:12 / cg"
+    "Modified: / 14.12.1999 / 20:50:59 / cg"
 ! !
 
 !ProcessMonitor methodsFor:'initialization'!
@@ -732,5 +737,5 @@
 !ProcessMonitor class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/ProcessMonitor.st,v 1.71 1999-12-08 21:22:37 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/ProcessMonitor.st,v 1.72 1999-12-14 20:15:02 cg Exp $'
 ! !
--- a/SemaphoreMonitor.st	Tue Dec 14 15:33:52 1999 +0100
+++ b/SemaphoreMonitor.st	Tue Dec 14 21:15:14 1999 +0100
@@ -90,8 +90,7 @@
         newList sort:[:s1 :s2 | s1 identityHash < s2 identityHash].
 
         newList ~= semaphores ifTrue:[
-            semaphores := WeakArray withAll:newList.
-            self updateStatus
+            self updateStatus:newList
         ].
     ].
     updateBlock notNil ifTrue:[
@@ -99,12 +98,12 @@
         Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay
     ].
 
-    "Modified: 3.7.1996 / 13:37:29 / stefan"
-    "Created: 23.1.1997 / 02:44:48 / cg"
-    "Modified: 23.1.1997 / 04:10:22 / cg"
+    "Modified: / 3.7.1996 / 13:37:29 / stefan"
+    "Created: / 23.1.1997 / 02:44:48 / cg"
+    "Modified: / 14.12.1999 / 20:52:44 / cg"
 !
 
-updateStatus
+updateStatus:newSemaphoreList
     "update status display of semaphores"
 
     |oldList list oldSelection newSelection|
@@ -117,6 +116,9 @@
             newSelection := OrderedCollection new.
         ].
 
+        newSemaphoreList notNil ifTrue:[
+            semaphores := WeakArray withAll:newSemaphoreList.
+        ].
         semaphores notNil ifTrue:[
             list := OrderedCollection new:(semaphores size + 2).
             list add:self titleLine.
@@ -202,7 +204,8 @@
     ]
 
     "Modified: / 3.7.1996 / 13:56:01 / stefan"
-    "Modified: / 17.8.1998 / 10:22:50 / cg"
+    "Created: / 14.12.1999 / 20:52:29 / cg"
+    "Modified: / 14.12.1999 / 20:53:14 / cg"
 ! !
 
 !SemaphoreMonitor methodsFor:'menu'!
@@ -352,5 +355,5 @@
 !SemaphoreMonitor class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/SemaphoreMonitor.st,v 1.14 1998-08-17 08:22:56 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/SemaphoreMonitor.st,v 1.15 1999-12-14 20:15:14 cg Exp $'
 ! !