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