author | Claus Gittinger <cg@exept.de> |
Fri, 16 Dec 2016 13:00:25 +0100 | |
changeset 17168 | 26ea2eb499bf |
parent 6157 | 333cde2a5ec7 |
child 17215 | 4a42de8e888a |
child 17225 | 2313780b08fb |
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 |
||
64 |
!SystemStatusMonitor class methodsFor:'startup'! |
|
65 |
||
17168 | 66 |
isAbstract |
67 |
"return true, if this is an abstract class." |
|
68 |
||
69 |
^ self == SystemStatusMonitor |
|
70 |
! |
|
71 |
||
1823 | 72 |
isVisualStartable |
2844 | 73 |
"return true, if this application can be started via #open. |
17168 | 74 |
(to allow start of a subclass instance via double-click in the browser)" |
2844 | 75 |
|
1823 | 76 |
^ self ~~ SystemStatusMonitor |
77 |
||
78 |
"Created: / 10.8.1998 / 16:02:23 / cg" |
|
79 |
"Modified: / 10.8.1998 / 16:02:41 / cg" |
|
80 |
! |
|
81 |
||
981 | 82 |
open |
83 |
|top monitor| |
|
84 |
||
85 |
top := StandardSystemView new. |
|
86 |
monitor := self origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
87 |
top extent:monitor preferredExtent. |
|
88 |
top label:self defaultLabel. |
|
89 |
top icon:self defaultIcon. |
|
2410 | 90 |
top open. |
91 |
||
92 |
^ monitor |
|
981 | 93 |
|
94 |
" |
|
95 |
ProcessMonitor open |
|
96 |
" |
|
97 |
||
98 |
"Created: 23.1.1997 / 02:53:42 / cg" |
|
99 |
! ! |
|
100 |
||
101 |
!SystemStatusMonitor methodsFor:'destroying'! |
|
102 |
||
3825 | 103 |
release |
981 | 104 |
updateBlock notNil ifTrue:[ |
3825 | 105 |
Processor removeTimedBlock:updateBlock. |
106 |
updateBlock := nil. |
|
981 | 107 |
]. |
3825 | 108 |
listUpdateBlock notNil ifTrue:[ |
109 |
Processor removeTimedBlock:listUpdateBlock. |
|
110 |
listUpdateBlock := nil. |
|
111 |
]. |
|
112 |
updateProcess notNil ifTrue:[ |
|
113 |
updateProcess terminate. |
|
114 |
updateProcess := nil. |
|
115 |
]. |
|
116 |
super release |
|
981 | 117 |
|
118 |
"Created: 23.1.1997 / 02:26:50 / cg" |
|
119 |
! ! |
|
120 |
||
121 |
!SystemStatusMonitor methodsFor:'drawing'! |
|
122 |
||
17168 | 123 |
titleLine |
124 |
self subclassResponsibility |
|
125 |
! |
|
126 |
||
6157 | 127 |
updateList |
128 |
self subclassResponsibility |
|
129 |
! |
|
130 |
||
131 |
updateStatus:arg |
|
132 |
self subclassResponsibility |
|
133 |
! |
|
134 |
||
981 | 135 |
updateView |
136 |
self updateList. |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
137 |
self updateStatus:nil |
981 | 138 |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
139 |
"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
|
140 |
"Modified: / 14.12.1999 / 20:47:37 / cg" |
981 | 141 |
! ! |
142 |
||
143 |
!SystemStatusMonitor methodsFor:'events'! |
|
144 |
||
145 |
canHandle:key |
|
146 |
^ key == #InspectIt |
|
147 |
||
148 |
"Created: 23.1.1997 / 02:27:15 / cg" |
|
149 |
! |
|
150 |
||
151 |
keyPress:key x:x y:y |
|
152 |
<resource: #keyboard ( #InspectIt ) > |
|
153 |
||
154 |
key == #InspectIt ifTrue:[ |
|
1897 | 155 |
^ self inspectSelection. |
981 | 156 |
]. |
157 |
^ super keyPress:key x:x y:y |
|
158 |
||
159 |
"Modified: 23.1.1997 / 02:27:27 / cg" |
|
160 |
"Created: 23.1.1997 / 02:27:45 / cg" |
|
161 |
! ! |
|
162 |
||
163 |
!SystemStatusMonitor methodsFor:'initialization'! |
|
164 |
||
165 |
initialize |
|
166 |
|v| |
|
167 |
||
168 |
super initialize. |
|
169 |
||
170 |
v := HVScrollableView for:SelectionInListView miniScrollerH:true in:self. |
|
171 |
v origin:0.0@0.0 corner:1.0@1.0. |
|
172 |
||
173 |
listView := v scrolledView. |
|
1273
3a8a91e6c5fa
give my listView a fixed font.
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
174 |
listView font:(EditTextView defaultFont). |
981 | 175 |
listView menuHolder:self; menuPerformer:self; menuMessage:#statusMenu. |
176 |
||
177 |
listView multipleSelectOk:true. |
|
1897 | 178 |
"/ listView toggleSelect:true. |
981 | 179 |
listView delegate:(KeyboardForwarder toView:self). |
180 |
listView doubleClickAction:[:line | self doubleClicked]. |
|
181 |
||
182 |
updateDelay := 0.5. |
|
183 |
listUpdateDelay := 5. |
|
184 |
||
185 |
"/ event mode is no longer used; |
|
186 |
"/ this event support may vanish |
|
187 |
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
|
188 |
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
|
189 |
listUpdateBlock := [self updateList]. |
981 | 190 |
]. |
191 |
||
192 |
" |
|
193 |
ProcessMonitor open |
|
194 |
" |
|
195 |
||
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
196 |
"Modified: / 14.12.1999 / 20:47:57 / cg" |
981 | 197 |
! |
198 |
||
199 |
mapped |
|
200 |
super mapped. |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
201 |
self updateStatus:nil. |
981 | 202 |
self updateList. |
203 |
||
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
204 |
"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
|
205 |
"Modified: / 14.12.1999 / 20:47:54 / cg" |
981 | 206 |
! |
207 |
||
208 |
realize |
|
209 |
super realize. |
|
210 |
||
211 |
self startUpdateProcess. |
|
212 |
||
213 |
"Created: 23.1.1997 / 02:30:28 / cg" |
|
214 |
! |
|
215 |
||
216 |
reinitialize |
|
217 |
updateProcess := nil. |
|
218 |
super reinitialize. |
|
219 |
self startUpdateProcess. |
|
220 |
||
221 |
"Modified: 22.12.1995 / 22:51:14 / cg" |
|
222 |
"Created: 23.1.1997 / 02:30:43 / cg" |
|
223 |
! |
|
224 |
||
225 |
startUpdateProcess |
|
226 |
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
|
227 |
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
|
228 |
Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay. |
981 | 229 |
] ifFalse:[ |
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
230 |
updateProcess := [ |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
231 |
[ |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
232 |
|id cnt myDelay| |
992 | 233 |
|
3024 | 234 |
myDelay := Delay forSeconds:updateDelay. |
981 | 235 |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
236 |
" |
3024 | 237 |
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
|
238 |
every half second, the status is updated. |
3024 | 239 |
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
|
240 |
built up again |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
241 |
" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
242 |
[true] whileTrue:[ |
3024 | 243 |
((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
|
244 |
myDelay wait. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
245 |
self updateStatus:nil. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
246 |
]. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
247 |
myDelay wait. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
248 |
self updateList. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
249 |
] |
6156 | 250 |
] ifCurtailed:[ |
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
251 |
updateProcess := nil |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
252 |
] |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
253 |
] 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
|
254 |
updateProcess name:'monitor [' , |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
255 |
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
|
256 |
'] update'. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
257 |
" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
258 |
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
|
259 |
" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
260 |
Processor activeProcess priority:(Processor userSchedulingPriority + 2) |
981 | 261 |
]. |
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:58 / 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:50 / cg" |
981 | 265 |
! ! |
266 |
||
267 |
!SystemStatusMonitor methodsFor:'queries'! |
|
268 |
||
269 |
preferredExtent |
|
270 |
"return my preferred extent" |
|
271 |
||
17168 | 272 |
^ ((self font widthOf:self titleLine) + 40) @ 250 |
981 | 273 |
|
274 |
"Modified: 23.1.1997 / 02:35:01 / cg" |
|
275 |
"Created: 23.1.1997 / 02:51:24 / cg" |
|
276 |
! ! |
|
277 |
||
17168 | 278 |
!SystemStatusMonitor methodsFor:'user actions'! |
279 |
||
280 |
doubleClicked |
|
281 |
"intentionally blank here - to be redefined in subclasses" |
|
282 |
||
283 |
^ self |
|
284 |
! |
|
285 |
||
286 |
inspectSelection |
|
287 |
"intentionally blank here - to be redefined in subclasses" |
|
288 |
||
289 |
^ self |
|
290 |
! ! |
|
291 |
||
981 | 292 |
!SystemStatusMonitor class methodsFor:'documentation'! |
293 |
||
294 |
version |
|
17168 | 295 |
^ '$Header$' |
981 | 296 |
! ! |
17168 | 297 |