ProcessMonitorV2.st
changeset 8651 56eb7da15507
parent 8408 d4725dafc068
child 8652 c7ab5e1b64ca
--- a/ProcessMonitorV2.st	Sun Jun 14 09:33:24 2009 +0200
+++ b/ProcessMonitorV2.st	Sun Jun 14 10:07:14 2009 +0200
@@ -892,40 +892,42 @@
 
     ^
      #(Menu
-	(
-	 (MenuItem
-	    enabled: hasSelectionHolder
-	    label: 'Inspect Process'
-	    itemValue: inspectSelection
-	    translateLabel: true
-	  )
-	 (MenuItem
-	    enabled: hasSelectionWithApplicationProcessHolder
-	    label: 'Inspect Application'
-	    itemValue: inspectApplication
-	    translateLabel: true
-	  )
-	 (MenuItem
-	    label: '-'
-	  )
-	 (MenuItem
-	    enabled: hasSelectionWithApplicationProcessHolder
-	    label: 'Browse Application'
-	    itemValue: browseApplication
-	    translateLabel: true
-	  )
-	 (MenuItem
-	    label: '-'
-	  )
-	 (MenuItem
-	    enabled: hasSelectionHolder
-	    label: 'Debug'
-	    itemValue: debugProcess
-	    translateLabel: true
-	  )
-	 )
-	nil
-	nil
+        (
+         (MenuItem
+            enabled: hasSelectionHolder
+            label: 'Inspect Process'
+            itemValue: inspectSelection
+            translateLabel: true
+          )
+         (MenuItem
+            enabled: hasSelectionWithApplicationProcessHolder
+            label: 'Inspect Application'
+            itemValue: inspectApplication
+            translateLabel: true
+          )
+         (MenuItem
+            label: '-'
+          )
+         (MenuItem
+            enabled: hasSelectionWithApplicationProcessHolder
+            label: 'Browse Application'
+            itemValue: browseApplication
+            translateLabel: true
+          )
+         (MenuItem
+            label: '-'
+            isVisible: allowModificationsAndHasDebugger
+          )
+         (MenuItem
+            enabled: hasSelectionHolder
+            label: 'Debug'
+            itemValue: debugProcess
+            translateLabel: true
+            isVisible: allowModificationsAndHasDebugger
+          )
+         )
+        nil
+        nil
       )
 
     "Modified: / 07-06-2007 / 12:49:58 / cg"
@@ -1259,7 +1261,7 @@
             itemValue: debugProcess
             translateLabel: true
             isButton: true
-            isVisible: allowModifications
+            isVisible: allowModificationsAndHasDebugger
             labelImage: (ResourceRetriever ProcessMonitorV2 processDebug22x22Icon)
           )
          (MenuItem
@@ -1654,15 +1656,11 @@
 !ProcessMonitorV2 methodsFor:'accessing'!
 
 visibleBlock
-    "return the value of the instance variable 'visibleBlock' (automatically generated)"
-
     ^ visibleBlock
 !
 
-visibleBlock:something
-    "set the value of the instance variable 'visibleBlock' (automatically generated)"
-
-    visibleBlock := something.
+visibleBlock:aProcessVisibleFilterBlock
+    visibleBlock := aProcessVisibleFilterBlock.
 ! !
 
 !ProcessMonitorV2 methodsFor:'actions'!
@@ -1792,6 +1790,12 @@
     ^ allowModifications
 !
 
+allowModificationsAndHasDebugger
+    ^ BlockValue
+        forLogical:(self allowModifications)
+        and:[ Debugger notNil ]
+!
+
 currentSortOrder
     "return/create the 'currentSortOrder' value holder (automatically generated)"
 
@@ -2204,6 +2208,19 @@
 
 !ProcessMonitorV2 methodsFor:'initialization & release'!
 
+commonPostOpen
+
+    super commonPostOpen.
+
+    builder window addDependent:self.
+    self viewedColumnsChanged.
+    self updateList.
+    self startUpdateProcess.
+    self selectionChanged.
+    self sortProcessListBy:#idVal.
+    self windowGroup addPreEventHook:self.
+!
+
 initialize
 
     super initialize.
@@ -2234,19 +2251,6 @@
     processTable wantsFocusWithPointerEnter.
 !
 
-postOpenWith:aBuilder
-
-    super postOpenWith:aBuilder.
-
-    aBuilder window addDependent:self.
-    self viewedColumnsChanged.
-    self updateList.
-    self startUpdateProcess.
-    self selectionChanged.
-    self sortProcessListBy:#idVal.
-    self windowGroup addPreEventHook:self.
-!
-
 release
     updateBlock notNil ifTrue:[
 	Processor removeTimedBlock:updateBlock.
@@ -2454,6 +2458,8 @@
 debugProcess
     "open a debugger on the selected process(es)"
 
+    Debugger isNil ifTrue:[ ^ self ].
+
     self selectedProcessesDo:[:p |
        Debugger openOn:p
     ]
@@ -2464,6 +2470,8 @@
 debugWhenResumed
     "open a debugger when the selected process(es) is resumed"
 
+    Debugger isNil ifTrue:[ ^ self ].
+
     self selectedProcessesDo:[:p |
        p addInterruptAction:[Debugger enter]
     ]
@@ -2808,40 +2816,42 @@
 
 startUpdateProcess
     updateBlock notNil ifTrue:[
-	Processor addTimedBlock:updateBlock afterSeconds:self scaledUpdateContentsDelayTime.
-	Processor addTimedBlock:listUpdateBlock afterSeconds:self scaledUpdateListDelayTime.
+        Processor addTimedBlock:updateBlock afterSeconds:self scaledUpdateContentsDelayTime.
+        Processor addTimedBlock:listUpdateBlock afterSeconds:self scaledUpdateListDelayTime.
     ] ifFalse:[
-	updateProcess := [
-	    [
-		|id cnt myDelay|
-
-		myDelay := Delay forSeconds:self scaledUpdateContentsDelayTime.
-
-		"
-		 every updateDelay (0.5), we look which process runs;
-		 every half second, the status is updated.
-		 every listUpdateDelay (5s), the list of processes is
-		 built up again
-		"
-		[true] whileTrue:[
-		    ((self scaledUpdateListDelayTime // self scaledUpdateContentsDelayTime) max:2) - 1 timesRepeat:[
-			myDelay wait.
-			self updateStatus:nil.
-		    ].
-		    myDelay wait.
-		    self updateList.
-		]
-	    ] valueOnUnwindDo:[
-		updateProcess := nil
-	    ]
-	]  forkAt:(Processor userSchedulingPriority + 1).
-	updateProcess name:'monitor [' ,
-			   Processor activeProcess id printString ,
-			   '] update'.
-	"
-	 raise my own priority
-	"
-	Processor activeProcess priority:(Processor userSchedulingPriority + 2)
+        self assert:updateProcess isNil.
+
+        updateProcess := [
+            [
+                |id cnt myDelay|
+
+                myDelay := Delay forSeconds:self scaledUpdateContentsDelayTime.
+
+                "
+                 every updateDelay (0.5), we look which process runs;
+                 every half second, the status is updated.
+                 every listUpdateDelay (5s), the list of processes is
+                 built up again
+                "
+                [true] whileTrue:[
+                    ((self scaledUpdateListDelayTime // self scaledUpdateContentsDelayTime) max:2) - 1 timesRepeat:[
+                        myDelay wait.
+                        self updateStatus:nil.
+                    ].
+                    myDelay wait.
+                    self updateList.
+                ]
+            ] valueOnUnwindDo:[
+                updateProcess := nil
+            ]
+        ]  forkAt:(Processor userSchedulingPriority + 1).
+        updateProcess name:'monitor [' ,
+                           Processor activeProcess id printString ,
+                           '] update'.
+        "
+         raise my own priority
+        "
+        Processor activeProcess priority:(Processor userSchedulingPriority + 2)
     ].
 !
 
@@ -2955,15 +2965,15 @@
     |newList|
 
     processTable shown ifTrue:[
-	newList := self getProcessList.
-	visibleBlock notNil ifTrue:[
-	    newList := newList select:[:aProc|visibleBlock value:aProc]
-	].
-	self updateStatus:newList.
+        newList := self getProcessList.
+        visibleBlock notNil ifTrue:[
+            newList := newList select:visibleBlock
+        ].
+        self updateStatus:newList.
     ].
     updateBlock notNil ifTrue:[
-	Processor removeTimedBlock:listUpdateBlock.
-	Processor addTimedBlock:listUpdateBlock afterSeconds:self scaledUpdateListDelayTime.
+        Processor removeTimedBlock:listUpdateBlock.
+        Processor addTimedBlock:listUpdateBlock afterSeconds:self scaledUpdateListDelayTime.
     ].
 !
 
@@ -3257,5 +3267,5 @@
 !ProcessMonitorV2 class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/ProcessMonitorV2.st,v 1.44 2008-11-09 11:30:03 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/ProcessMonitorV2.st,v 1.45 2009-06-14 08:07:14 cg Exp $'
 ! !