author | Claus Gittinger <cg@exept.de> |
Tue, 14 Dec 2004 16:01:03 +0100 | |
changeset 6156 | 2b0398bd0ed6 |
parent 3825 | 291fef465a5b |
child 6157 | 333cde2a5ec7 |
permissions | -rw-r--r-- |
2744 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
2699 | 13 |
"{ Package: 'stx:libtool' }" |
14 |
||
981 | 15 |
SimpleView subclass:#SystemStatusMonitor |
16 |
instanceVariableNames:'listView listUpdateDelay updateDelay updateBlock listUpdateBlock |
|
17 |
updateProcess' |
|
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
1053 | 20 |
category:'Monitors-ST/X' |
981 | 21 |
! |
22 |
||
2744 | 23 |
!SystemStatusMonitor class methodsFor:'documentation'! |
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! ! |
|
981 | 38 |
|
39 |
!SystemStatusMonitor class methodsFor:'defaults'! |
|
40 |
||
41 |
defaultIcon |
|
42 |
^ StandardSystemView defaultIcon |
|
43 |
||
44 |
"Created: 23.1.1997 / 02:52:25 / cg" |
|
45 |
! |
|
46 |
||
47 |
defaultLabel |
|
48 |
^ 'Status Monitor' |
|
49 |
||
50 |
"Created: 23.1.1997 / 02:52:43 / cg" |
|
51 |
! ! |
|
52 |
||
53 |
!SystemStatusMonitor class methodsFor:'startup'! |
|
54 |
||
1823 | 55 |
isVisualStartable |
2844 | 56 |
"return true, if this application can be started via #open. |
57 |
(to allow start of a change browser via double-click in the browser)" |
|
58 |
||
1823 | 59 |
^ self ~~ SystemStatusMonitor |
60 |
||
61 |
"Created: / 10.8.1998 / 16:02:23 / cg" |
|
62 |
"Modified: / 10.8.1998 / 16:02:41 / cg" |
|
63 |
! |
|
64 |
||
981 | 65 |
open |
66 |
|top monitor| |
|
67 |
||
68 |
top := StandardSystemView new. |
|
69 |
monitor := self origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
70 |
top extent:monitor preferredExtent. |
|
71 |
top label:self defaultLabel. |
|
72 |
top icon:self defaultIcon. |
|
2410 | 73 |
top open. |
74 |
||
75 |
^ monitor |
|
981 | 76 |
|
77 |
" |
|
78 |
ProcessMonitor open |
|
79 |
" |
|
80 |
||
81 |
"Created: 23.1.1997 / 02:53:42 / cg" |
|
82 |
! ! |
|
83 |
||
84 |
!SystemStatusMonitor methodsFor:'destroying'! |
|
85 |
||
3825 | 86 |
release |
981 | 87 |
updateBlock notNil ifTrue:[ |
3825 | 88 |
Processor removeTimedBlock:updateBlock. |
89 |
updateBlock := nil. |
|
981 | 90 |
]. |
3825 | 91 |
listUpdateBlock notNil ifTrue:[ |
92 |
Processor removeTimedBlock:listUpdateBlock. |
|
93 |
listUpdateBlock := nil. |
|
94 |
]. |
|
95 |
updateProcess notNil ifTrue:[ |
|
96 |
updateProcess terminate. |
|
97 |
updateProcess := nil. |
|
98 |
]. |
|
99 |
super release |
|
981 | 100 |
|
101 |
"Created: 23.1.1997 / 02:26:50 / cg" |
|
102 |
! ! |
|
103 |
||
104 |
!SystemStatusMonitor methodsFor:'drawing'! |
|
105 |
||
106 |
updateView |
|
107 |
self updateList. |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
108 |
self updateStatus:nil |
981 | 109 |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
110 |
"Created: / 23.1.1997 / 02:27:05 / cg" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
111 |
"Modified: / 14.12.1999 / 20:47:37 / cg" |
981 | 112 |
! ! |
113 |
||
114 |
!SystemStatusMonitor methodsFor:'events'! |
|
115 |
||
116 |
canHandle:key |
|
117 |
^ key == #InspectIt |
|
118 |
||
119 |
"Created: 23.1.1997 / 02:27:15 / cg" |
|
120 |
! |
|
121 |
||
122 |
keyPress:key x:x y:y |
|
123 |
<resource: #keyboard ( #InspectIt ) > |
|
124 |
||
125 |
key == #InspectIt ifTrue:[ |
|
1897 | 126 |
^ self inspectSelection. |
981 | 127 |
]. |
128 |
^ super keyPress:key x:x y:y |
|
129 |
||
130 |
"Modified: 23.1.1997 / 02:27:27 / cg" |
|
131 |
"Created: 23.1.1997 / 02:27:45 / cg" |
|
132 |
! ! |
|
133 |
||
134 |
!SystemStatusMonitor methodsFor:'initialization'! |
|
135 |
||
136 |
initialize |
|
137 |
|v| |
|
138 |
||
139 |
super initialize. |
|
140 |
||
141 |
v := HVScrollableView for:SelectionInListView miniScrollerH:true in:self. |
|
142 |
v origin:0.0@0.0 corner:1.0@1.0. |
|
143 |
||
144 |
listView := v scrolledView. |
|
1273
3a8a91e6c5fa
give my listView a fixed font.
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
145 |
listView font:(EditTextView defaultFont). |
981 | 146 |
listView menuHolder:self; menuPerformer:self; menuMessage:#statusMenu. |
147 |
||
148 |
listView multipleSelectOk:true. |
|
1897 | 149 |
"/ listView toggleSelect:true. |
981 | 150 |
listView delegate:(KeyboardForwarder toView:self). |
151 |
listView doubleClickAction:[:line | self doubleClicked]. |
|
152 |
||
153 |
updateDelay := 0.5. |
|
154 |
listUpdateDelay := 5. |
|
155 |
||
156 |
"/ event mode is no longer used; |
|
157 |
"/ this event support may vanish |
|
158 |
Processor isPureEventDriven ifTrue:[ |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
159 |
updateBlock := [self updateStatus:nil]. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
160 |
listUpdateBlock := [self updateList]. |
981 | 161 |
]. |
162 |
||
163 |
" |
|
164 |
ProcessMonitor open |
|
165 |
" |
|
166 |
||
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
167 |
"Modified: / 14.12.1999 / 20:47:57 / cg" |
981 | 168 |
! |
169 |
||
170 |
mapped |
|
171 |
super mapped. |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
172 |
self updateStatus:nil. |
981 | 173 |
self updateList. |
174 |
||
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
175 |
"Created: / 23.1.1997 / 02:30:05 / cg" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
176 |
"Modified: / 14.12.1999 / 20:47:54 / cg" |
981 | 177 |
! |
178 |
||
179 |
realize |
|
180 |
super realize. |
|
181 |
||
182 |
self startUpdateProcess. |
|
183 |
||
184 |
"Created: 23.1.1997 / 02:30:28 / cg" |
|
185 |
! |
|
186 |
||
187 |
reinitialize |
|
188 |
updateProcess := nil. |
|
189 |
super reinitialize. |
|
190 |
self startUpdateProcess. |
|
191 |
||
192 |
"Modified: 22.12.1995 / 22:51:14 / cg" |
|
193 |
"Created: 23.1.1997 / 02:30:43 / cg" |
|
194 |
! |
|
195 |
||
196 |
startUpdateProcess |
|
197 |
updateBlock notNil ifTrue:[ |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
198 |
Processor addTimedBlock:updateBlock afterSeconds:updateDelay. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
199 |
Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay. |
981 | 200 |
] ifFalse:[ |
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
201 |
updateProcess := [ |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
202 |
[ |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
203 |
|id cnt myDelay| |
992 | 204 |
|
3024 | 205 |
myDelay := Delay forSeconds:updateDelay. |
981 | 206 |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
207 |
" |
3024 | 208 |
every updateDelay (0.5), we look which process runs; |
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
209 |
every half second, the status is updated. |
3024 | 210 |
every listUpdateDelay (5s), the list of processes is |
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
211 |
built up again |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
212 |
" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
213 |
[true] whileTrue:[ |
3024 | 214 |
((listUpdateDelay // updateDelay) max:2) - 1 timesRepeat:[ |
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
215 |
myDelay wait. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
216 |
self updateStatus:nil. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
217 |
]. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
218 |
myDelay wait. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
219 |
self updateList. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
220 |
] |
6156 | 221 |
] ifCurtailed:[ |
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
222 |
updateProcess := nil |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
223 |
] |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
224 |
] forkAt:(Processor userSchedulingPriority + 1). |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
225 |
updateProcess name:'monitor [' , |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
226 |
Processor activeProcess id printString , |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
227 |
'] update'. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
228 |
" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
229 |
raise my own priority |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
230 |
" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
231 |
Processor activeProcess priority:(Processor userSchedulingPriority + 2) |
981 | 232 |
]. |
233 |
||
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
234 |
"Created: / 23.1.1997 / 02:30:58 / cg" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
235 |
"Modified: / 14.12.1999 / 20:47:50 / cg" |
981 | 236 |
! ! |
237 |
||
238 |
!SystemStatusMonitor methodsFor:'queries'! |
|
239 |
||
240 |
preferredExtent |
|
241 |
"return my preferred extent" |
|
242 |
||
2699 | 243 |
^ (font widthOf:self titleLine) + 40 @ 200 |
981 | 244 |
|
245 |
"Modified: 23.1.1997 / 02:35:01 / cg" |
|
246 |
"Created: 23.1.1997 / 02:51:24 / cg" |
|
247 |
! ! |
|
248 |
||
249 |
!SystemStatusMonitor class methodsFor:'documentation'! |
|
250 |
||
251 |
version |
|
6156 | 252 |
^ '$Header: /cvs/stx/stx/libtool/SystemStatusMonitor.st,v 1.16 2004-12-14 15:01:03 cg Exp $' |
981 | 253 |
! ! |