author | Claus Gittinger <cg@exept.de> |
Sat, 07 Dec 2019 13:19:15 +0100 | |
changeset 19346 | 67bcfdfc08d2 |
parent 19272 | 2d83635cfddd |
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 |
" |
|
17168 | 12 |
"{ Package: 'stx:libtool' }" |
2744 | 13 |
|
17168 | 14 |
"{ NameSpace: Smalltalk }" |
2699 | 15 |
|
981 | 16 |
SimpleView subclass:#SystemStatusMonitor |
17 |
instanceVariableNames:'listView listUpdateDelay updateDelay updateBlock listUpdateBlock |
|
18 |
updateProcess' |
|
19 |
classVariableNames:'' |
|
20 |
poolDictionaries:'' |
|
1053 | 21 |
category:'Monitors-ST/X' |
981 | 22 |
! |
23 |
||
2744 | 24 |
!SystemStatusMonitor class methodsFor:'documentation'! |
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
17168 | 38 |
! |
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
Abstract class providing common code for list-based status monitors. |
|
43 |
||
44 |
[disclaimer:] |
|
45 |
these are some of the oldest tools in the system, written in the early 90's. |
|
46 |
They do in no way reflect the way GUIs are designed/written these days. |
|
19110 | 47 |
However, after all those years, they are still very very useful (and not found in many other systems) |
17168 | 48 |
" |
2744 | 49 |
! ! |
981 | 50 |
|
51 |
!SystemStatusMonitor class methodsFor:'defaults'! |
|
52 |
||
53 |
defaultIcon |
|
54 |
^ StandardSystemView defaultIcon |
|
55 |
||
56 |
"Created: 23.1.1997 / 02:52:25 / cg" |
|
57 |
! |
|
58 |
||
59 |
defaultLabel |
|
60 |
^ 'Status Monitor' |
|
61 |
||
62 |
"Created: 23.1.1997 / 02:52:43 / cg" |
|
63 |
! ! |
|
64 |
||
17225 | 65 |
!SystemStatusMonitor class methodsFor:'menu specs'! |
66 |
||
18501 | 67 |
fileMenu |
68 |
"This resource specification was automatically generated |
|
69 |
by the MenuEditor of ST/X." |
|
70 |
||
71 |
"Do not manually edit this!! If it is corrupted, |
|
72 |
the MenuEditor may not be able to read the specification." |
|
73 |
||
74 |
||
75 |
" |
|
76 |
MenuEditor new openOnClass:SystemStatusMonitor andSelector:#fileMenu |
|
77 |
(Menu new fromLiteralArrayEncoding:(SystemStatusMonitor fileMenu)) startUp |
|
78 |
" |
|
79 |
||
80 |
<resource: #menu> |
|
81 |
||
82 |
^ |
|
83 |
#(Menu |
|
84 |
( |
|
85 |
(MenuItem |
|
86 |
label: 'Exit' |
|
87 |
itemValue: closeRequestToTopView |
|
88 |
) |
|
89 |
) |
|
90 |
nil |
|
91 |
nil |
|
92 |
) |
|
93 |
! |
|
94 |
||
17225 | 95 |
mainMenu |
96 |
"This resource specification was automatically generated |
|
97 |
by the MenuEditor of ST/X." |
|
98 |
||
99 |
"Do not manually edit this!! If it is corrupted, |
|
100 |
the MenuEditor may not be able to read the specification." |
|
101 |
||
102 |
||
103 |
" |
|
104 |
MenuEditor new openOnClass:SystemStatusMonitor andSelector:#mainMenu |
|
105 |
(Menu new fromLiteralArrayEncoding:(SystemStatusMonitor mainMenu)) startUp |
|
106 |
" |
|
107 |
||
108 |
<resource: #menu> |
|
109 |
||
110 |
^ |
|
111 |
#(Menu |
|
112 |
( |
|
113 |
(MenuItem |
|
114 |
label: 'File' |
|
18501 | 115 |
submenuChannel: fileMenu |
116 |
) |
|
117 |
(MenuItem |
|
118 |
label: 'View' |
|
119 |
submenuChannel: viewMenu |
|
120 |
) |
|
121 |
) |
|
122 |
nil |
|
123 |
nil |
|
124 |
) |
|
125 |
! |
|
126 |
||
127 |
viewMenu |
|
128 |
"This resource specification was automatically generated |
|
129 |
by the MenuEditor of ST/X." |
|
130 |
||
131 |
"Do not manually edit this!! If it is corrupted, |
|
132 |
the MenuEditor may not be able to read the specification." |
|
133 |
||
134 |
||
135 |
" |
|
136 |
MenuEditor new openOnClass:SystemStatusMonitor andSelector:#viewMenu |
|
137 |
(Menu new fromLiteralArrayEncoding:(SystemStatusMonitor viewMenu)) startUp |
|
138 |
" |
|
139 |
||
140 |
<resource: #menu> |
|
141 |
||
142 |
^ |
|
143 |
#(Menu |
|
144 |
( |
|
145 |
(MenuItem |
|
146 |
label: 'Update Interval...' |
|
147 |
itemValue: menuChangeUpdateInterval |
|
17225 | 148 |
) |
149 |
) |
|
150 |
nil |
|
151 |
nil |
|
152 |
) |
|
153 |
! ! |
|
154 |
||
981 | 155 |
!SystemStatusMonitor class methodsFor:'startup'! |
156 |
||
17168 | 157 |
isAbstract |
158 |
"return true, if this is an abstract class." |
|
159 |
||
160 |
^ self == SystemStatusMonitor |
|
161 |
! |
|
162 |
||
1823 | 163 |
isVisualStartable |
2844 | 164 |
"return true, if this application can be started via #open. |
17168 | 165 |
(to allow start of a subclass instance via double-click in the browser)" |
2844 | 166 |
|
1823 | 167 |
^ self ~~ SystemStatusMonitor |
168 |
||
169 |
"Created: / 10.8.1998 / 16:02:23 / cg" |
|
170 |
"Modified: / 10.8.1998 / 16:02:41 / cg" |
|
171 |
! |
|
172 |
||
981 | 173 |
open |
17225 | 174 |
|top menuPanel menu monitor| |
981 | 175 |
|
176 |
top := StandardSystemView new. |
|
17225 | 177 |
|
178 |
monitor := self in:top. |
|
179 |
monitor layout:(LayoutFrame |
|
180 |
leftFraction:0 offset:0 |
|
181 |
rightFraction:1 offset:0 |
|
182 |
topFraction:0 offset:30 |
|
183 |
bottomFraction:1 offset:0). |
|
184 |
||
185 |
menuPanel := MenuPanel in:top. |
|
186 |
menuPanel layout:(LayoutFrame |
|
187 |
leftFraction:0 offset:0 |
|
188 |
rightFraction:1 offset:0 |
|
189 |
topFraction:0 offset:0 |
|
190 |
bottomFraction:0 offset:30). |
|
191 |
menuPanel verticalLayout:false. |
|
192 |
menu := self mainMenu decodeAsLiteralArray. |
|
193 |
menu findGuiResourcesIn:monitor. |
|
194 |
menu receiver:monitor. |
|
195 |
menuPanel menu:menu. |
|
196 |
||
981 | 197 |
top extent:monitor preferredExtent. |
19211 | 198 |
top label:(self classResources string:self defaultLabel). |
981 | 199 |
top icon:self defaultIcon. |
2410 | 200 |
top open. |
201 |
||
202 |
^ monitor |
|
981 | 203 |
|
204 |
" |
|
205 |
ProcessMonitor open |
|
206 |
" |
|
207 |
||
208 |
"Created: 23.1.1997 / 02:53:42 / cg" |
|
209 |
! ! |
|
210 |
||
211 |
!SystemStatusMonitor methodsFor:'destroying'! |
|
212 |
||
3825 | 213 |
release |
981 | 214 |
updateBlock notNil ifTrue:[ |
3825 | 215 |
Processor removeTimedBlock:updateBlock. |
216 |
updateBlock := nil. |
|
981 | 217 |
]. |
3825 | 218 |
listUpdateBlock notNil ifTrue:[ |
219 |
Processor removeTimedBlock:listUpdateBlock. |
|
220 |
listUpdateBlock := nil. |
|
221 |
]. |
|
222 |
updateProcess notNil ifTrue:[ |
|
223 |
updateProcess terminate. |
|
224 |
updateProcess := nil. |
|
225 |
]. |
|
226 |
super release |
|
981 | 227 |
|
228 |
"Created: 23.1.1997 / 02:26:50 / cg" |
|
229 |
! ! |
|
230 |
||
231 |
!SystemStatusMonitor methodsFor:'drawing'! |
|
232 |
||
17168 | 233 |
titleLine |
234 |
self subclassResponsibility |
|
235 |
! |
|
236 |
||
6157 | 237 |
updateList |
238 |
self subclassResponsibility |
|
239 |
! |
|
240 |
||
241 |
updateStatus:arg |
|
242 |
self subclassResponsibility |
|
243 |
! |
|
244 |
||
981 | 245 |
updateView |
246 |
self updateList. |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
247 |
self updateStatus:nil |
981 | 248 |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
249 |
"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
|
250 |
"Modified: / 14.12.1999 / 20:47:37 / cg" |
981 | 251 |
! ! |
252 |
||
253 |
!SystemStatusMonitor methodsFor:'events'! |
|
254 |
||
255 |
canHandle:key |
|
256 |
^ key == #InspectIt |
|
257 |
||
258 |
"Created: 23.1.1997 / 02:27:15 / cg" |
|
259 |
! |
|
260 |
||
261 |
keyPress:key x:x y:y |
|
262 |
<resource: #keyboard ( #InspectIt ) > |
|
263 |
||
264 |
key == #InspectIt ifTrue:[ |
|
1897 | 265 |
^ self inspectSelection. |
981 | 266 |
]. |
267 |
^ super keyPress:key x:x y:y |
|
268 |
||
269 |
"Modified: 23.1.1997 / 02:27:27 / cg" |
|
270 |
"Created: 23.1.1997 / 02:27:45 / cg" |
|
271 |
! ! |
|
272 |
||
273 |
!SystemStatusMonitor methodsFor:'initialization'! |
|
274 |
||
275 |
initialize |
|
276 |
|v| |
|
277 |
||
278 |
super initialize. |
|
279 |
||
280 |
v := HVScrollableView for:SelectionInListView miniScrollerH:true in:self. |
|
281 |
v origin:0.0@0.0 corner:1.0@1.0. |
|
282 |
||
283 |
listView := v scrolledView. |
|
1273
3a8a91e6c5fa
give my listView a fixed font.
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
284 |
listView font:(EditTextView defaultFont). |
981 | 285 |
listView menuHolder:self; menuPerformer:self; menuMessage:#statusMenu. |
286 |
||
287 |
listView multipleSelectOk:true. |
|
1897 | 288 |
"/ listView toggleSelect:true. |
981 | 289 |
listView delegate:(KeyboardForwarder toView:self). |
290 |
listView doubleClickAction:[:line | self doubleClicked]. |
|
291 |
||
292 |
updateDelay := 0.5. |
|
293 |
listUpdateDelay := 5. |
|
294 |
||
295 |
"/ event mode is no longer used; |
|
296 |
"/ this event support may vanish |
|
297 |
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
|
298 |
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
|
299 |
listUpdateBlock := [self updateList]. |
981 | 300 |
]. |
301 |
||
302 |
" |
|
303 |
ProcessMonitor open |
|
304 |
" |
|
305 |
||
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
306 |
"Modified: / 14.12.1999 / 20:47:57 / cg" |
981 | 307 |
! |
308 |
||
309 |
mapped |
|
310 |
super mapped. |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
311 |
self updateStatus:nil. |
981 | 312 |
self updateList. |
313 |
||
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
314 |
"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
|
315 |
"Modified: / 14.12.1999 / 20:47:54 / cg" |
981 | 316 |
! |
317 |
||
318 |
realize |
|
319 |
super realize. |
|
320 |
||
321 |
self startUpdateProcess. |
|
322 |
||
323 |
"Created: 23.1.1997 / 02:30:28 / cg" |
|
324 |
! |
|
325 |
||
326 |
reinitialize |
|
327 |
updateProcess := nil. |
|
328 |
super reinitialize. |
|
329 |
self startUpdateProcess. |
|
330 |
||
331 |
"Modified: 22.12.1995 / 22:51:14 / cg" |
|
332 |
"Created: 23.1.1997 / 02:30:43 / cg" |
|
333 |
! |
|
334 |
||
335 |
startUpdateProcess |
|
336 |
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
|
337 |
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
|
338 |
Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay. |
981 | 339 |
] ifFalse:[ |
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
340 |
updateProcess := [ |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
341 |
[ |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
342 |
|id cnt myDelay| |
992 | 343 |
|
3024 | 344 |
myDelay := Delay forSeconds:updateDelay. |
981 | 345 |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
346 |
" |
3024 | 347 |
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
|
348 |
every half second, the status is updated. |
19272 | 349 |
every listUpdateDelay (5s), the list of processes is built up again |
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
350 |
" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
351 |
[true] whileTrue:[ |
3024 | 352 |
((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
|
353 |
myDelay wait. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
354 |
self updateStatus:nil. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
355 |
]. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
356 |
myDelay wait. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
357 |
self updateList. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
358 |
] |
6156 | 359 |
] ifCurtailed:[ |
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
360 |
updateProcess := nil |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
361 |
] |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
362 |
] 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
|
363 |
updateProcess name:'monitor [' , |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
364 |
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
|
365 |
'] update'. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
366 |
" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
367 |
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
|
368 |
" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
369 |
Processor activeProcess priority:(Processor userSchedulingPriority + 2) |
981 | 370 |
]. |
371 |
||
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
372 |
"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
|
373 |
"Modified: / 14.12.1999 / 20:47:50 / cg" |
981 | 374 |
! ! |
375 |
||
17225 | 376 |
!SystemStatusMonitor methodsFor:'menu'! |
377 |
||
378 |
closeRequestToTopView |
|
379 |
self topView closeRequest |
|
380 |
! |
|
381 |
||
18501 | 382 |
menuChangeUpdateInterval |
383 |
|newInterval| |
|
384 |
||
385 |
newInterval := Dialog request:'Update interval (seconds):' initialAnswer:updateDelay printString. |
|
386 |
newInterval isEmptyOrNil ifTrue:[^ self]. |
|
387 |
updateDelay := Number readFrom:newInterval onError:[updateDelay]. |
|
388 |
||
389 |
"Created: / 29-10-2018 / 15:20:47 / Claus Gittinger" |
|
390 |
! |
|
391 |
||
17225 | 392 |
selectionIndicesDo:aBlock |
393 |
"evaluate aBlock on all selected indices" |
|
394 |
||
395 |
|sel| |
|
396 |
||
397 |
sel := listView selection. |
|
398 |
sel isNil ifTrue:[^ self]. |
|
399 |
||
400 |
(sel isKindOf:Collection) ifTrue:[ |
|
401 |
sel do:aBlock |
|
402 |
] ifFalse:[ |
|
403 |
aBlock value:sel. |
|
404 |
]. |
|
405 |
||
406 |
"Created: 23.1.1997 / 03:11:24 / cg" |
|
407 |
! ! |
|
408 |
||
409 |
!SystemStatusMonitor methodsFor:'private'! |
|
410 |
||
19346 | 411 |
hasSelection |
412 |
^ [ listView selection notEmptyOrNil ]. |
|
413 |
||
414 |
! |
|
415 |
||
17225 | 416 |
installDelayedUpdate |
417 |
updateBlock notNil ifTrue:[ |
|
418 |
Processor removeTimedBlock:listUpdateBlock. |
|
419 |
Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay |
|
420 |
]. |
|
421 |
! ! |
|
422 |
||
981 | 423 |
!SystemStatusMonitor methodsFor:'queries'! |
424 |
||
18521 | 425 |
computePreferredExtent |
981 | 426 |
"return my preferred extent" |
427 |
||
17225 | 428 |
^ ((self font widthOf:self titleLine) + 400) @ 250 |
981 | 429 |
|
18521 | 430 |
"Created: / 09-11-2018 / 20:01:19 / Claus Gittinger" |
981 | 431 |
! ! |
432 |
||
17168 | 433 |
!SystemStatusMonitor methodsFor:'user actions'! |
434 |
||
435 |
doubleClicked |
|
436 |
"intentionally blank here - to be redefined in subclasses" |
|
437 |
||
438 |
^ self |
|
439 |
! |
|
440 |
||
441 |
inspectSelection |
|
442 |
"intentionally blank here - to be redefined in subclasses" |
|
443 |
||
444 |
^ self |
|
445 |
! ! |
|
446 |
||
981 | 447 |
!SystemStatusMonitor class methodsFor:'documentation'! |
448 |
||
449 |
version |
|
17168 | 450 |
^ '$Header$' |
18503 | 451 |
! |
452 |
||
453 |
version_CVS |
|
454 |
^ '$Header$' |
|
981 | 455 |
! ! |
17168 | 456 |