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