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