author | Claus Gittinger <cg@exept.de> |
Tue, 15 May 2012 11:53:23 +0200 | |
changeset 4127 | 219b27d668e1 |
parent 4106 | 94e77b757100 |
child 4216 | 7059be9d898c |
permissions | -rw-r--r-- |
62 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
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 |
" |
|
2563 | 12 |
"{ Package: 'stx:libwidg2' }" |
1789 | 13 |
|
50 | 14 |
View subclass:#ProgressIndicator |
826 | 15 |
instanceVariableNames:'percentage showPercentage fgColor bgColor connectedTop |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
16 |
connectedLabel collector finishAction closeTopWhenDone showBusy |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
17 |
busyPosition busyDelta busyIndicationProcess' |
183 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Views-Misc' |
|
50 | 21 |
! |
22 |
||
334 | 23 |
!ProgressIndicator class methodsFor:'documentation'! |
50 | 24 |
|
62 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
50 | 39 |
documentation |
40 |
" |
|
41 |
a view showing a rectangle filled according the percentage value. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
42 |
Can be used as a progress indicator a la MSwindows; |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
43 |
it can also be configured as a non-percentage busy indication |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
44 |
via the showBusyIndication flag (a la netscape). |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
45 |
|
574 | 46 |
Can be used as a widget within an application, or |
47 |
via the convenient #inBox: instance creation messages, |
|
48 |
which shows a progressDisplay in a modalBox, while some |
|
49 |
action is performed. |
|
50 |
See examples. |
|
183 | 51 |
|
52 |
[author:] |
|
2563 | 53 |
Claus Gittinger |
183 | 54 |
|
55 |
[see also:] |
|
2563 | 56 |
ActionWaitBox AnimatedLabel |
50 | 57 |
" |
58 |
! |
|
59 |
||
60 |
examples |
|
61 |
" |
|
62 | 62 |
basic (internal) interface |
63 |
(if progress indicator is to be used in a complex box ...): |
|
50 | 64 |
|
183 | 65 |
Before you get frustrated - see the convenient-interface examples |
66 |
at the end ;-) |
|
67 |
||
4088 | 68 |
[exBegin] |
50 | 69 |
|top p h| |
70 |
||
62 | 71 |
top := ModalBox new. |
50 | 72 |
top extent:300@100. |
73 |
top label:'Progress'. |
|
74 |
p := ProgressIndicator in:top. |
|
75 |
p origin:(0.0@0.5) corner:(1.0@0.5). |
|
76 |
p level:-1. |
|
62 | 77 |
h := p preferredExtent y. |
50 | 78 |
p topInset:(h // 2) negated; |
4088 | 79 |
bottomInset:(h // 2) negated; |
80 |
leftInset:5; |
|
81 |
rightInset:5. |
|
50 | 82 |
|
83 |
[ |
|
4088 | 84 |
1 to:100 do:[:val | |
85 |
(Delay forSeconds:0.05) wait. |
|
86 |
p percentage:val |
|
87 |
]. |
|
88 |
top hide. |
|
62 | 89 |
] fork. |
90 |
top open. |
|
4088 | 91 |
[exEnd] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
92 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
93 |
as a busy indicator |
4088 | 94 |
[exBegin] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
95 |
|top p h| |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
96 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
97 |
top := ModalBox new. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
98 |
top extent:300@100. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
99 |
top label:'Busy'. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
100 |
p := ProgressIndicator in:top. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
101 |
p origin:(0.0@0.5) corner:(1.0@0.5). |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
102 |
p level:-1. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
103 |
h := p preferredExtent y. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
104 |
p topInset:(h // 2) negated; |
4088 | 105 |
bottomInset:(h // 2) negated; |
106 |
leftInset:5; |
|
107 |
rightInset:5. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
108 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
109 |
p showBusyIndication:true. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
110 |
[ |
4088 | 111 |
'do something here ....'. |
112 |
(Delay forSeconds:5) wait. |
|
113 |
top hide. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
114 |
] fork. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
115 |
top open. |
4088 | 116 |
[exEnd] |
50 | 117 |
|
118 |
changing colors, turning percentage display off: |
|
4088 | 119 |
[exBegin] |
50 | 120 |
|top p h| |
121 |
||
122 |
top := StandardSystemView new. |
|
123 |
top extent:300@100. |
|
124 |
top label:'Progress'. |
|
125 |
p := ProgressIndicator in:top. |
|
126 |
p origin:(0.0@0.5) corner:(1.0@0.5). |
|
127 |
p level:-1. |
|
128 |
p showPercentage:false. |
|
129 |
p foregroundColor:(Color red). |
|
130 |
h := 10. |
|
131 |
p topInset:(h // 2) negated; |
|
4088 | 132 |
bottomInset:(h // 2) negated; |
133 |
leftInset:5; |
|
134 |
rightInset:5. |
|
50 | 135 |
top open. |
136 |
[ |
|
4088 | 137 |
1 to:100 do:[:val | |
138 |
(Delay forSeconds:0.05) wait. |
|
139 |
p percentage:val |
|
140 |
] |
|
50 | 141 |
] fork |
4088 | 142 |
[exEnd] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
143 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
144 |
as a busy indicator and percentage display (as in netscape) |
4088 | 145 |
[exBegin] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
146 |
|top p h| |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
147 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
148 |
top := ModalBox new. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
149 |
top extent:300@60. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
150 |
top label:'Busy'. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
151 |
p := ProgressIndicator in:top. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
152 |
p origin:(0.0@0.5) corner:(1.0@0.5). |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
153 |
p level:-1. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
154 |
p showPercentage:false. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
155 |
p backgroundColor:(Color cyan). |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
156 |
h := p preferredExtent y. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
157 |
p topInset:(h // 3) negated; |
4088 | 158 |
bottomInset:(h // 3) negated; |
159 |
leftInset:5; |
|
160 |
rightInset:5. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
161 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
162 |
p showBusyIndication:true. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
163 |
[ |
4088 | 164 |
top label:'Busy'. |
165 |
1 to:100 do:[:i | |
|
166 |
(Delay forSeconds:0.05) wait. |
|
167 |
]. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
168 |
|
4088 | 169 |
top label:'Percentage'. |
170 |
p showBusyIndication:false. |
|
171 |
1 to:100 do:[:i | |
|
172 |
(Delay forSeconds:0.05) wait. |
|
173 |
p percentage:i. |
|
174 |
]. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
175 |
|
4088 | 176 |
top hide. |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
177 |
] fork. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
178 |
top open. |
4088 | 179 |
[exEnd] |
50 | 180 |
|
181 |
with border (2D look): |
|
4088 | 182 |
[exBegin] |
50 | 183 |
|top p h| |
184 |
||
185 |
top := StandardSystemView new. |
|
186 |
top extent:300@100. |
|
187 |
top label:'Progress'. |
|
188 |
p := ProgressIndicator in:top. |
|
189 |
p origin:(0.0@0.5) corner:(1.0@0.5). |
|
190 |
p borderWidth:1. |
|
62 | 191 |
h := p preferredExtent y. |
50 | 192 |
p topInset:(h // 2) negated; |
4088 | 193 |
bottomInset:(h // 2) negated; |
194 |
leftInset:5; |
|
195 |
rightInset:5. |
|
50 | 196 |
top open. |
197 |
[ |
|
4088 | 198 |
1 to:100 do:[:val | |
199 |
(Delay forSeconds:0.05) wait. |
|
200 |
p percentage:val |
|
201 |
] |
|
50 | 202 |
] fork |
4088 | 203 |
[exEnd] |
50 | 204 |
|
205 |
||
206 |
getting progress from a model: |
|
4088 | 207 |
[exBegin] |
50 | 208 |
|model top p h| |
209 |
||
210 |
model := 0 asValue. |
|
211 |
||
212 |
top := StandardSystemView new. |
|
213 |
top extent:300@100. |
|
214 |
top label:'Progress'. |
|
215 |
p := ProgressIndicator in:top. |
|
216 |
p model:model. |
|
217 |
p origin:(0.0@0.5) corner:(1.0@0.5). |
|
218 |
p level:-1. |
|
62 | 219 |
h := p preferredExtent y. |
50 | 220 |
p topInset:(h // 2) negated; |
4088 | 221 |
bottomInset:(h // 2) negated; |
222 |
leftInset:5; |
|
223 |
rightInset:5. |
|
50 | 224 |
top open. |
225 |
||
226 |
[ |
|
4088 | 227 |
1 to:100 do:[:val | |
228 |
(Delay forSeconds:0.05) wait. |
|
229 |
model value:val |
|
230 |
] |
|
50 | 231 |
] fork |
4088 | 232 |
[exEnd] |
50 | 233 |
|
62 | 234 |
|
50 | 235 |
concrete example: |
236 |
search all files in the source directory for a string |
|
237 |
using grep. Show progress while doing so. |
|
4088 | 238 |
[exBegin] |
50 | 239 |
|top p h names done| |
240 |
||
241 |
top := StandardSystemView new. |
|
242 |
top extent:300@100. |
|
243 |
top label:'Searching ...'. |
|
244 |
p := ProgressIndicator in:top. |
|
245 |
p origin:(0.0@0.5) corner:(1.0@0.5). |
|
246 |
p level:-1. |
|
62 | 247 |
h := p preferredExtent y. |
50 | 248 |
p topInset:(h // 2) negated; |
4088 | 249 |
bottomInset:(h // 2) negated; |
250 |
leftInset:5; |
|
251 |
rightInset:5. |
|
50 | 252 |
top openWithPriority:(Processor activePriority + 1). |
253 |
||
254 |
names := 'source' asFilename directoryContents. |
|
255 |
done := 0. |
|
256 |
names do:[:aName | |
|
4088 | 257 |
|fn stream line| |
50 | 258 |
|
4088 | 259 |
p percentage:(done / names size * 100). |
260 |
fn := ('source/' , aName) asFilename. |
|
261 |
fn isDirectory ifFalse:[ |
|
262 |
stream := fn readStream. |
|
263 |
[stream atEnd] whileFalse:[ |
|
264 |
line := stream nextLine. |
|
265 |
(line findString:'subclass:') ~~ 0 ifTrue:[ |
|
266 |
Transcript showCR:line |
|
267 |
]. |
|
268 |
]. |
|
269 |
stream close. |
|
270 |
]. |
|
271 |
done := done + 1 |
|
50 | 272 |
]. |
273 |
||
274 |
top destroy |
|
4088 | 275 |
[exEnd] |
62 | 276 |
|
277 |
||
278 |
using the convenient inBox-interface |
|
279 |
||
280 |
(this creates a box and an activity label and evaluates a block |
|
281 |
to indicate ...) |
|
282 |
||
283 |
basic interface demonstration: |
|
4088 | 284 |
[exBegin] |
62 | 285 |
|p| |
286 |
||
287 |
p := ProgressIndicator |
|
4088 | 288 |
inBoxWithLabel:'doing something ...' |
289 |
abortable:true. |
|
62 | 290 |
p showProgressOf: |
4088 | 291 |
[:progressValue :currentAction | |
62 | 292 |
|
4088 | 293 |
1 to:100 do:[:val | |
294 |
(Delay forSeconds:0.05) wait. |
|
295 |
val == 25 ifTrue:[ |
|
296 |
currentAction value:'still going ...' |
|
297 |
]. |
|
298 |
val == 50 ifTrue:[ |
|
299 |
currentAction value:'halfway through ...' |
|
300 |
]. |
|
301 |
val == 75 ifTrue:[ |
|
302 |
currentAction value:'almost finished ...' |
|
303 |
]. |
|
304 |
progressValue value:val |
|
305 |
] |
|
306 |
] |
|
307 |
[exEnd] |
|
62 | 308 |
|
309 |
||
310 |
above search example using this convenient interface: |
|
4088 | 311 |
[exBegin] |
62 | 312 |
|p| |
313 |
||
183 | 314 |
p := ProgressIndicator |
4088 | 315 |
inBoxWithLabel:'searching files ...' |
316 |
abortable:false. |
|
62 | 317 |
p showProgressOf: |
4088 | 318 |
[:progressValue :currentAction | |
319 |
|names nDone| |
|
62 | 320 |
|
4088 | 321 |
names := 'source' asFilename directoryContents. |
322 |
nDone := 0. |
|
323 |
names do:[:aName | |
|
324 |
|fn stream line| |
|
183 | 325 |
|
4088 | 326 |
progressValue value:(nDone / names size * 100). |
327 |
currentAction value:'searching ' , 'source/' , aName , ' ...'. |
|
62 | 328 |
|
4088 | 329 |
fn := ('source/' , aName) asFilename. |
330 |
fn isDirectory ifFalse:[ |
|
331 |
stream := fn readStream. |
|
332 |
[stream atEnd] whileFalse:[ |
|
333 |
line := stream nextLine. |
|
334 |
(line findString:'subclass:') ~~ 0 ifTrue:[ |
|
335 |
Transcript showCR:line |
|
336 |
]. |
|
337 |
]. |
|
338 |
stream close. |
|
339 |
]. |
|
340 |
nDone := nDone + 1 |
|
341 |
]. |
|
342 |
]. |
|
343 |
[exEnd] |
|
62 | 344 |
|
345 |
||
346 |
a nice example: copying files a la windows ... |
|
183 | 347 |
the following copies all files to /dev/null. |
4088 | 348 |
[exBegin] |
62 | 349 |
|p| |
350 |
||
351 |
(ProgressIndicator |
|
4088 | 352 |
inBoxWithLabel:'copy files to /dev/null ...' |
353 |
abortable:true) |
|
354 |
showProgressOf: |
|
355 |
[:progressValue :currentAction | |
|
356 |
|files nFiles nDone| |
|
62 | 357 |
|
4088 | 358 |
files := '.' asFilename directoryContents. |
359 |
nFiles := files size. |
|
360 |
nDone := 0. |
|
361 |
files do:[:aFileName | |
|
362 |
|percent| |
|
50 | 363 |
|
4088 | 364 |
nDone := nDone + 1. |
365 |
percent := nDone / nFiles * 100. |
|
366 |
progressValue value:percent. |
|
367 |
aFileName asFilename isDirectory ifTrue:[ |
|
368 |
Transcript showCR:('skipping ' , aFileName , ' ...'). |
|
369 |
currentAction value:('skipping ' , aFileName , ' ...'). |
|
370 |
] ifFalse:[ |
|
371 |
Transcript showCR:('copying ' , aFileName , ' ...'). |
|
372 |
currentAction value:('copying ' , aFileName , ' ...'). |
|
373 |
Object errorSignal handle:[:ex | |
|
374 |
self warn:'an error occurred while copying ' , aFileName. |
|
375 |
ex return |
|
376 |
] do:[ |
|
377 |
aFileName asFilename copyTo:'/dev/null'. |
|
378 |
] |
|
379 |
]. |
|
380 |
]. |
|
381 |
]. |
|
382 |
[exEnd] |
|
383 |
||
384 |
[exBegin] |
|
385 |
ProgressIndicator |
|
386 |
displayBusyIndicator:'Test...' |
|
387 |
at:(Screen default center) |
|
388 |
during:[:p | |
|
389 |
p labelWidget label:'bla...'. |
|
390 |
Delay waitForSeconds:0.5. |
|
391 |
||
392 |
1 to:3 do:[:idx | |
|
393 |
Delay waitForSeconds:0.5. |
|
394 |
p labelWidget label:('bla %1...' bindWith:idx). |
|
395 |
]. |
|
396 |
Delay waitForSeconds:0.5. |
|
397 |
p labelWidget label:'blabla...'. |
|
398 |
Delay waitForSeconds:0.5. |
|
399 |
]. |
|
400 |
[exEnd] |
|
183 | 401 |
" |
50 | 402 |
! ! |
403 |
||
334 | 404 |
!ProgressIndicator class methodsFor:'instance creation'! |
62 | 405 |
|
406 |
inBox |
|
574 | 407 |
"create a topView containing an instance of myself, |
408 |
for later use with #showProgressOf:" |
|
409 |
||
410 |
^ self inBoxWithLabel:'executing ...' abortable:false |
|
411 |
||
412 |
"Modified: 22.10.1997 / 21:08:37 / cg" |
|
62 | 413 |
! |
414 |
||
415 |
inBoxWithLabel:aLabel |
|
416 |
"create a topView containing an instance of myself, |
|
417 |
for later use with #showProgressOf:" |
|
418 |
||
419 |
^ self inBoxWithLabel:aLabel abortable:false |
|
420 |
! |
|
421 |
||
422 |
inBoxWithLabel:aLabel abortable:abortable |
|
423 |
"create a topView containing an instance of myself, |
|
424 |
for later use with #showProgressOf:" |
|
425 |
||
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
426 |
^ self |
634 | 427 |
inBoxWithLabel:aLabel |
428 |
text:'' |
|
429 |
abortable:abortable |
|
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
430 |
|
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
431 |
"Modified: 17.7.1996 / 15:14:58 / cg" |
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
432 |
! |
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
433 |
|
237 | 434 |
inBoxWithLabel:aLabel icon:anIcon text:text abortable:abortable view:additionalView closeWhenDone:closeWhenDoneBoolean |
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
435 |
"create a topView containing an instance of myself, |
3542 | 436 |
return the new instance, for later use with #showProgressOf:" |
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
437 |
|
2436 | 438 |
|top p l y y2| |
62 | 439 |
|
440 |
top := Dialog new. |
|
441 |
top label:aLabel. |
|
442 |
top cursor:(Cursor wait). |
|
3542 | 443 |
|
826 | 444 |
y2 := 0. |
237 | 445 |
anIcon notNil ifTrue:[ |
3425
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
446 |
y := top yPosition. |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
447 |
l := top addTextLabel:anIcon. |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
448 |
l borderWidth:0. |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
449 |
l adjust:#left. |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
450 |
l cursor:(Cursor wait). |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
451 |
y2 := top yPosition. |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
452 |
top yPosition:y. |
237 | 453 |
]. |
454 |
||
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
455 |
l := top addTextLabel:text. |
62 | 456 |
l borderWidth:0. |
74 | 457 |
l adjust:#left. |
62 | 458 |
l cursor:(Cursor wait). |
826 | 459 |
anIcon notNil ifTrue: [l leftInset:(anIcon width + 10)]. |
237 | 460 |
|
461 |
top yPosition:(top yPosition max:y2). |
|
62 | 462 |
|
463 |
top addVerticalSpace. |
|
464 |
||
465 |
p := ProgressIndicator new. |
|
3425
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
466 |
p extent:(1.0 @ p preferredHeight). |
62 | 467 |
p level:-1. |
468 |
p leftInset:5; |
|
469 |
rightInset:5. |
|
470 |
p cursor:(Cursor wait). |
|
237 | 471 |
p closeTopWhenDone:closeWhenDoneBoolean. |
62 | 472 |
p connectToTop:top label:l. |
473 |
||
474 |
top addComponent:p. |
|
475 |
||
237 | 476 |
additionalView notNil ifTrue:[ |
3425
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
477 |
top addComponent:additionalView. |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
478 |
additionalView extent:(1.0 @ additionalView preferredHeight). |
237 | 479 |
]. |
480 |
||
62 | 481 |
abortable ifTrue:[ |
3425
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
482 |
top addVerticalSpace. |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
483 |
top addAbortButton |
62 | 484 |
]. |
3542 | 485 |
abortable ifFalse:[ |
486 |
"/ top beUndecorated. -- buggy for now; sets wrong height (caption not included ?) |
|
487 |
"/ would need the following kludge: |
|
488 |
"/ top preferredExtent:(top preferredExtent + (0@30)). |
|
489 |
]. |
|
62 | 490 |
|
491 |
^ p |
|
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
492 |
|
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
493 |
"Created: 17.7.1996 / 15:14:33 / cg" |
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
494 |
"Modified: 17.7.1996 / 15:16:58 / cg" |
237 | 495 |
! |
496 |
||
497 |
inBoxWithLabel:aLabel text:text abortable:abortable |
|
498 |
"create a topView containing an instance of myself, |
|
499 |
for later use with #showProgressOf:" |
|
500 |
||
501 |
^ self |
|
634 | 502 |
inBoxWithLabel:aLabel |
503 |
text:text |
|
504 |
abortable:abortable |
|
505 |
view:nil |
|
237 | 506 |
|
507 |
! |
|
508 |
||
509 |
inBoxWithLabel:aLabel text:text abortable:abortable view:additionalView |
|
510 |
"create a topView containing an instance of myself, |
|
511 |
for later use with #showProgressOf:" |
|
512 |
||
513 |
^ self |
|
634 | 514 |
inBoxWithLabel:aLabel |
515 |
text:text |
|
516 |
abortable:abortable |
|
517 |
view:additionalView |
|
518 |
closeWhenDone:true |
|
237 | 519 |
|
520 |
! |
|
521 |
||
522 |
inBoxWithLabel:aLabel text:text abortable:abortable view:additionalView closeWhenDone:closeWhenDoneBoolean |
|
523 |
"create a topView containing an instance of myself, |
|
524 |
for later use with #showProgressOf:" |
|
525 |
||
526 |
^ self |
|
634 | 527 |
inBoxWithLabel:aLabel |
528 |
icon:nil |
|
529 |
text:text |
|
530 |
abortable:abortable |
|
531 |
view:additionalView |
|
532 |
closeWhenDone:closeWhenDoneBoolean |
|
237 | 533 |
|
1681
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
534 |
! |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
535 |
|
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
536 |
progressOpenOn:progressModel label:aLabel |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
537 |
"create and open a progressIndicator dialog window, |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
538 |
bit do not open it modal; instead, it is opened modeless |
1834
ba170c21ed76
defaultExtent computation fixed
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
539 |
and control returns to the caller. |
1681
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
540 |
The models value is assumed to be 0..1 |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
541 |
(which is for compatibility and different from ST/X's percentage use) |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
542 |
Added for VW compatibility (RB)." |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
543 |
|
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
544 |
|p ra| |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
545 |
|
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
546 |
p := self |
2563 | 547 |
inBoxWithLabel:aLabel |
548 |
icon:nil |
|
549 |
text:aLabel |
|
550 |
abortable:false |
|
551 |
view:nil |
|
552 |
closeWhenDone:false. |
|
1681
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
553 |
|
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
554 |
ra := RangeAdaptor on:progressModel start:0 stop:0.01 grid:nil. |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
555 |
p model:ra. |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
556 |
|
2132 | 557 |
p topView openModeless; waitUntilVisible. |
1681
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
558 |
^ p. |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
559 |
|
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
560 |
"Modified: / 4.2.2000 / 01:25:55 / cg" |
62 | 561 |
! ! |
562 |
||
3999 | 563 |
!ProgressIndicator class methodsFor:'simple public API'! |
3542 | 564 |
|
565 |
displayBusyIndicator:aLabel abortable:abortable at:aPoint during:aBlock |
|
566 |
"easy interface - show progress while evaluating aBlock. |
|
567 |
The block is passed the progressIndicator as argument |
|
568 |
so the block can change the label and/or change the progress value." |
|
569 |
||
3967 | 570 |
^ self |
571 |
displayBusyIndicator:aLabel |
|
572 |
message:aLabel |
|
573 |
abortable:abortable |
|
574 |
at:aPoint |
|
575 |
during:aBlock |
|
576 |
||
577 |
" |
|
578 |
ProgressIndicator |
|
579 |
displayBusyIndicator:'doobidoobidoo...' |
|
580 |
abortable:true |
|
581 |
at:(Screen default center) |
|
582 |
during:[ |
|
583 |
200 to:400 by:5 do:[:i | |
|
584 |
Delay waitForSeconds:0.1. |
|
585 |
] |
|
586 |
]. |
|
587 |
||
588 |
ProgressIndicator |
|
589 |
displayBusyIndicator:'doobidoobidoo...' |
|
590 |
abortable:true |
|
591 |
at:(Screen default center) |
|
592 |
during:[ |
|
593 |
Delay waitForSeconds:3. |
|
594 |
]. |
|
595 |
" |
|
596 |
||
597 |
"Modified: / 12-11-2010 / 18:59:45 / cg" |
|
598 |
! |
|
599 |
||
600 |
displayBusyIndicator:aLabel at:aPoint during:aBlock |
|
601 |
"easy interface - show progress while evaluating aBlock. |
|
602 |
The block is passed a valueHolder, which is to be set to values from |
|
603 |
startValue to endValue during the blocks evaluation. |
|
604 |
This is scaled to 0..100% completion. |
|
605 |
Set the valueHolder to nil, to get a busy-indicator" |
|
606 |
||
607 |
self |
|
608 |
displayBusyIndicator:aLabel |
|
609 |
abortable:false |
|
610 |
at:aPoint |
|
611 |
during:aBlock |
|
612 |
||
613 |
" |
|
614 |
ProgressIndicator |
|
615 |
displayBusyIndicator:'doobidoobidoo...' |
|
616 |
at:(Screen default center) |
|
617 |
during:[ |
|
618 |
200 to:400 by:5 do:[:i | |
|
619 |
Delay waitForSeconds:0.1. |
|
620 |
] |
|
621 |
]. |
|
622 |
" |
|
623 |
! |
|
624 |
||
625 |
displayBusyIndicator:aLabel message:messageString abortable:abortable at:aPoint during:aBlock |
|
626 |
"easy interface - show progress while evaluating aBlock. |
|
627 |
The block is passed the progressIndicator as argument |
|
628 |
so the block can change the label and/or change the progress value." |
|
629 |
||
3542 | 630 |
|p| |
631 |
||
632 |
p := self |
|
633 |
inBoxWithLabel:aLabel |
|
634 |
icon:nil |
|
3967 | 635 |
text:messageString |
3542 | 636 |
abortable:abortable |
637 |
view:nil |
|
638 |
closeWhenDone:true. |
|
639 |
||
4106
94e77b757100
changed: #displayBusyIndicator:message:abortable:at:during:
ab
parents:
4096
diff
changeset
|
640 |
aPoint notNil ifTrue:[ |
94e77b757100
changed: #displayBusyIndicator:message:abortable:at:during:
ab
parents:
4096
diff
changeset
|
641 |
p topView origin:aPoint |
94e77b757100
changed: #displayBusyIndicator:message:abortable:at:during:
ab
parents:
4096
diff
changeset
|
642 |
]. |
94e77b757100
changed: #displayBusyIndicator:message:abortable:at:during:
ab
parents:
4096
diff
changeset
|
643 |
|
3542 | 644 |
p showBusyIndication:true. |
645 |
p showBusyIndicatorDuring:[ |
|
646 |
CannotReturnError catch:[ |
|
647 |
aBlock valueWithOptionalArgument:p. |
|
648 |
] |
|
649 |
] |
|
650 |
||
651 |
" |
|
652 |
ProgressIndicator |
|
653 |
displayBusyIndicator:'doobidoobidoo...' |
|
654 |
abortable:true |
|
655 |
at:(Screen default center) |
|
656 |
during:[ |
|
657 |
200 to:400 by:5 do:[:i | |
|
658 |
Delay waitForSeconds:0.1. |
|
659 |
] |
|
660 |
]. |
|
3626
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
661 |
|
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
662 |
ProgressIndicator |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
663 |
displayBusyIndicator:'doobidoobidoo...' |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
664 |
abortable:true |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
665 |
at:(Screen default center) |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
666 |
during:[ |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
667 |
Delay waitForSeconds:3. |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
668 |
]. |
3542 | 669 |
" |
3967 | 670 |
|
671 |
"Created: / 12-11-2010 / 18:59:13 / cg" |
|
3542 | 672 |
! |
673 |
||
3967 | 674 |
displayBusyIndicator:aLabel message:messageString at:aPoint during:aBlock |
3542 | 675 |
"easy interface - show progress while evaluating aBlock. |
676 |
The block is passed a valueHolder, which is to be set to values from |
|
677 |
startValue to endValue during the blocks evaluation. |
|
678 |
This is scaled to 0..100% completion. |
|
679 |
Set the valueHolder to nil, to get a busy-indicator" |
|
680 |
||
681 |
self |
|
3967 | 682 |
displayBusyIndicator:aLabel |
683 |
message:messageString |
|
3542 | 684 |
abortable:false |
685 |
at:aPoint |
|
686 |
during:aBlock |
|
687 |
||
688 |
" |
|
689 |
ProgressIndicator |
|
690 |
displayBusyIndicator:'doobidoobidoo...' |
|
691 |
at:(Screen default center) |
|
692 |
during:[ |
|
693 |
200 to:400 by:5 do:[:i | |
|
694 |
Delay waitForSeconds:0.1. |
|
695 |
] |
|
696 |
]. |
|
697 |
" |
|
3967 | 698 |
|
699 |
"Created: / 12-11-2010 / 19:01:12 / cg" |
|
3542 | 700 |
! |
701 |
||
702 |
displayProgress:aLabel at:aPoint from:startValue to:endValue during:aBlock |
|
703 |
"easy interface - show progress while evaluating aBlock. |
|
704 |
The block is passed a valueHolder, which is to be set to values from |
|
705 |
startValue to endValue during the blocks evaluation. |
|
706 |
This is scaled to 0..100% completion. |
|
707 |
Set the valueHolder to nil, to get a busy-indicator" |
|
708 |
||
3967 | 709 |
^ self |
710 |
displayProgress:aLabel |
|
711 |
message:aLabel |
|
712 |
at:aPoint |
|
713 |
from:startValue |
|
714 |
to:endValue |
|
715 |
during:aBlock |
|
716 |
||
717 |
" |
|
718 |
ProgressIndicator |
|
719 |
displayProgress:'doobidoobidoo...' |
|
720 |
at:(Screen default center) |
|
721 |
from:200 to:400 |
|
722 |
during:[:val | |
|
723 |
200 to:400 by:5 do:[:i | |
|
724 |
val value:i. |
|
725 |
Delay waitForSeconds:0.1. |
|
726 |
] |
|
727 |
]. |
|
728 |
" |
|
729 |
||
730 |
"Modified: / 12-11-2010 / 19:02:27 / cg" |
|
731 |
! |
|
732 |
||
733 |
displayProgress:aLabel message:messageString at:aPoint from:startValue to:endValue during:aBlock |
|
734 |
"easy interface - show progress while evaluating aBlock. |
|
735 |
The block is passed a valueHolder, which is to be set to values from |
|
736 |
startValue to endValue during the blocks evaluation. |
|
737 |
This is scaled to 0..100% completion. |
|
738 |
Set the valueHolder to nil, to get a busy-indicator" |
|
739 |
||
3542 | 740 |
|p| |
741 |
||
742 |
p := self |
|
743 |
inBoxWithLabel:aLabel |
|
744 |
icon:nil |
|
3967 | 745 |
text:messageString |
3542 | 746 |
abortable:false |
747 |
view:nil |
|
748 |
closeWhenDone:true. |
|
749 |
||
750 |
p showProgressOf:[:progressValue :currentAction | |
|
751 |
|scaler| |
|
752 |
||
753 |
scaler := [:scaledValue | |
|
754 |
|newPercentage oldPercentage oldLabel| |
|
755 |
||
756 |
scaledValue isNil ifTrue:[ |
|
757 |
p showBusyIndication:true |
|
758 |
] ifFalse:[ |
|
759 |
p showBusyIndication:false. |
|
760 |
oldPercentage := progressValue value. |
|
3827
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
761 |
endValue = startValue ifTrue:[ |
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
762 |
newPercentage := 0. |
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
763 |
] ifFalse:[ |
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
764 |
newPercentage := (scaledValue - startValue) / (endValue-startValue) * 100. |
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
765 |
]. |
3542 | 766 |
newPercentage ~= oldPercentage ifTrue:[ |
767 |
progressValue value:newPercentage. |
|
768 |
]. |
|
769 |
oldLabel := currentAction value. |
|
770 |
oldLabel ~= aLabel ifTrue:[ |
|
771 |
currentAction value:aLabel. |
|
772 |
] |
|
773 |
] |
|
774 |
]. |
|
775 |
CannotReturnError catch:[ |
|
776 |
aBlock valueWithOptionalArgument:scaler and:p. |
|
777 |
] |
|
778 |
] |
|
779 |
||
780 |
" |
|
781 |
ProgressIndicator |
|
782 |
displayProgress:'doobidoobidoo...' |
|
783 |
at:(Screen default center) |
|
784 |
from:200 to:400 |
|
785 |
during:[:val | |
|
786 |
200 to:400 by:5 do:[:i | |
|
787 |
val value:i. |
|
788 |
Delay waitForSeconds:0.1. |
|
789 |
] |
|
790 |
]. |
|
791 |
" |
|
3967 | 792 |
|
793 |
"Created: / 12-11-2010 / 19:01:38 / cg" |
|
3542 | 794 |
! |
795 |
||
796 |
displayProgressNotifications:aLabel abortable:abortable at:aPointOrNil during:aBlock |
|
797 |
"easy interface - show progress as provided by progressNotifications |
|
798 |
while evaluating aBlock. |
|
799 |
The block is passed the progressIndicator as optional argument, |
|
800 |
however, progressNotifications are handled and update the percentage." |
|
801 |
||
3967 | 802 |
^ self |
803 |
displayProgressNotifications:aLabel |
|
804 |
message:aLabel |
|
805 |
abortable:abortable |
|
806 |
at:aPointOrNil |
|
807 |
during:aBlock |
|
808 |
||
809 |
||
810 |
" |
|
811 |
ProgressIndicator |
|
812 |
displayProgressNotifications:'doobidoobidoo...' |
|
813 |
abortable:true |
|
814 |
at:nil |
|
815 |
during:[ |
|
816 |
200 to:400 by:5 do:[:i | |
|
817 |
Delay waitForSeconds:0.1. |
|
818 |
ProgressNotification progressPercentage:(i / 4). |
|
819 |
] |
|
820 |
]. |
|
821 |
" |
|
822 |
" |
|
823 |
ProgressIndicator |
|
824 |
displayProgressNotifications:'doobidoobidoo...' |
|
825 |
abortable:true |
|
826 |
at:nil |
|
827 |
during:[ |
|
828 |
Delay waitForSeconds:3. |
|
829 |
]. |
|
830 |
" |
|
831 |
||
832 |
"Modified: / 12-11-2010 / 19:03:09 / cg" |
|
833 |
! |
|
834 |
||
835 |
displayProgressNotifications:aLabel message:messageString abortable:abortable at:aPointOrNil during:aBlock |
|
836 |
"easy interface - show progress as provided by progressNotifications |
|
837 |
while evaluating aBlock. |
|
838 |
The block is passed the progressIndicator as optional argument, |
|
839 |
however, progressNotifications are handled and update the percentage." |
|
840 |
||
3542 | 841 |
|p| |
842 |
||
843 |
p := self |
|
844 |
inBoxWithLabel:aLabel |
|
845 |
icon:nil |
|
3967 | 846 |
text:messageString |
3542 | 847 |
abortable:abortable |
848 |
view:nil |
|
849 |
closeWhenDone:true. |
|
850 |
||
851 |
p showBusyIndicatorDuring:[ |
|
852 |
CannotReturnError catch:[ |
|
853 |
ProgressNotification handle:[:ex | |
|
854 |
p percentage:ex progressValue. |
|
855 |
ex proceed. |
|
856 |
] do:[ |
|
857 |
aBlock valueWithOptionalArgument:p. |
|
858 |
]. |
|
859 |
] |
|
860 |
] |
|
861 |
||
862 |
" |
|
863 |
ProgressIndicator |
|
864 |
displayProgressNotifications:'doobidoobidoo...' |
|
865 |
abortable:true |
|
866 |
at:nil |
|
867 |
during:[ |
|
868 |
200 to:400 by:5 do:[:i | |
|
869 |
Delay waitForSeconds:0.1. |
|
870 |
ProgressNotification progressPercentage:(i / 4). |
|
871 |
] |
|
872 |
]. |
|
873 |
" |
|
3626
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
874 |
" |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
875 |
ProgressIndicator |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
876 |
displayProgressNotifications:'doobidoobidoo...' |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
877 |
abortable:true |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
878 |
at:nil |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
879 |
during:[ |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
880 |
Delay waitForSeconds:3. |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
881 |
]. |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
882 |
" |
3967 | 883 |
|
884 |
"Created: / 12-11-2010 / 19:02:43 / cg" |
|
3542 | 885 |
! ! |
886 |
||
183 | 887 |
!ProgressIndicator methodsFor:'accessing'! |
888 |
||
4088 | 889 |
labelWidget |
890 |
^ connectedLabel |
|
891 |
||
892 |
"Created: / 07-11-2011 / 22:01:00 / cg" |
|
893 |
! |
|
894 |
||
334 | 895 |
percentage:aNumber |
896 |
"set the percentage" |
|
237 | 897 |
|
183 | 898 |
|newPercentage| |
899 |
||
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
900 |
aNumber < 0 ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
901 |
newPercentage := -1. |
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
902 |
] ifFalse:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
903 |
newPercentage := ((aNumber max:0) min:100) rounded. |
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
904 |
]. |
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
905 |
newPercentage ~= percentage ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
906 |
percentage := newPercentage. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
907 |
self invalidateRepairNow:true. |
183 | 908 |
] |
334 | 909 |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
910 |
"Modified: / 6.6.1998 / 19:43:56 / cg" |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
911 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
912 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
913 |
showBusyIndication:aBooleanHolder |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
914 |
"switch between percentage mode (if false) and busy indication (if true)" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
915 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
916 |
aBooleanHolder ~~ showBusy ifTrue:[ |
3969
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
917 |
showBusy notNil ifTrue:[ |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
918 |
showBusy removeDependent:self. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
919 |
]. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
920 |
showBusy := aBooleanHolder. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
921 |
showBusy isValueModel ifTrue:[showBusy addDependent:self]. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
922 |
(showBusy value) ifTrue:[ |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
923 |
self startBusyIndicationProcess. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
924 |
] ifFalse:[ |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
925 |
self stopBusyIndicationProcess |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
926 |
]. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
927 |
shown ifTrue:[self redraw] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
928 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
929 |
|
3969
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
930 |
"Created: / 21-10-1998 / 17:35:16 / cg" |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
931 |
"Modified: / 17-11-2010 / 13:43:51 / cg" |
334 | 932 |
! ! |
933 |
||
2404 | 934 |
!ProgressIndicator methodsFor:'accessing-behavior'! |
935 |
||
936 |
closeTopWhenDone:aBoolean |
|
937 |
"set/clear the close-topView-when-done flag" |
|
938 |
||
939 |
closeTopWhenDone := aBoolean |
|
940 |
||
941 |
"Created: 3.9.1996 / 14:22:03 / cg" |
|
942 |
"Modified: 29.3.1997 / 16:08:19 / cg" |
|
943 |
! |
|
944 |
||
945 |
finishAction:aBlock |
|
946 |
"define an action to be performed when finished" |
|
947 |
||
948 |
finishAction := aBlock |
|
949 |
||
950 |
"Created: 3.9.1996 / 14:15:15 / cg" |
|
951 |
"Modified: 29.3.1997 / 16:08:35 / cg" |
|
952 |
! ! |
|
953 |
||
954 |
!ProgressIndicator methodsFor:'accessing-look'! |
|
334 | 955 |
|
826 | 956 |
backgroundColor |
957 |
"return the percentage displays background color" |
|
958 |
||
959 |
^ bgColor |
|
960 |
||
961 |
! |
|
962 |
||
963 |
backgroundColor:aColor |
|
964 |
"set the percentage displays background color" |
|
965 |
||
993 | 966 |
aColor ~= bgColor ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
967 |
bgColor := aColor. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
968 |
self invalidateRepairNow:true |
826 | 969 |
]. |
970 |
||
993 | 971 |
"Modified: / 20.7.1998 / 23:32:48 / cg" |
826 | 972 |
! |
973 |
||
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
974 |
foregroundColor |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
975 |
"return the percentage displays foreground color" |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
976 |
|
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
977 |
^ fgColor |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
978 |
|
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
979 |
"Created: 29.3.1997 / 16:12:28 / cg" |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
980 |
! |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
981 |
|
334 | 982 |
foregroundColor:aColor |
983 |
"set the percentage displays foreground color" |
|
984 |
||
993 | 985 |
aColor ~= fgColor ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
986 |
fgColor := aColor. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
987 |
self invalidateRepairNow:true |
336 | 988 |
]. |
334 | 989 |
|
993 | 990 |
"Modified: / 20.7.1998 / 23:27:47 / cg" |
183 | 991 |
! |
992 |
||
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
993 |
showPercentage |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
994 |
"return the flag controlling if the percentage is to be shown numerically" |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
995 |
|
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
996 |
^ showPercentage |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
997 |
|
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
998 |
"Created: 29.3.1997 / 16:12:39 / cg" |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
999 |
! |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1000 |
|
183 | 1001 |
showPercentage:aBoolean |
334 | 1002 |
"set/clear the flag controlling if the percentage is to be shown numerically" |
1003 |
||
336 | 1004 |
showPercentage := aBoolean. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1005 |
self invalidateRepairNow:true |
334 | 1006 |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
1007 |
"Modified: / 6.6.1998 / 19:28:44 / cg" |
183 | 1008 |
! ! |
1009 |
||
1010 |
!ProgressIndicator methodsFor:'change & update'! |
|
1011 |
||
1012 |
update:aspect with:aParameter from:changedObject |
|
574 | 1013 |
"react upon value changes of my model" |
1014 |
||
183 | 1015 |
(aspect == aspectMsg |
1016 |
and:[changedObject == model]) ifTrue:[ |
|
3748 | 1017 |
self percentage:(model perform:aspectMsg). |
1018 |
^ self |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1019 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1020 |
changedObject == showBusy ifTrue:[ |
3748 | 1021 |
showBusy value |
1022 |
ifTrue:[self startBusyIndicationProcess] |
|
1023 |
ifFalse:[self stopBusyIndicationProcess]. |
|
1024 |
self redraw. |
|
1025 |
^ self |
|
183 | 1026 |
]. |
1027 |
^ super update:aspect with:aParameter from:changedObject |
|
574 | 1028 |
|
3748 | 1029 |
"Modified: / 21-10-1998 / 18:01:52 / cg" |
1030 |
"Modified: / 01-11-2006 / 08:40:50 / janfrog" |
|
183 | 1031 |
! ! |
1032 |
||
1033 |
!ProgressIndicator methodsFor:'drawing'! |
|
1034 |
||
1035 |
redraw |
|
574 | 1036 |
"redraw the percentage bar and optional percentage string" |
1037 |
||
4127 | 1038 |
|s lx rx sx sy sw m2 m w h doBusy oldClip| |
183 | 1039 |
|
3748 | 1040 |
self shown ifFalse:[^self]. |
1041 |
||
183 | 1042 |
m := margin + 1. |
863 | 1043 |
m2 := m*2. |
1044 |
||
1045 |
w := width - m2. |
|
1046 |
h := height - m2. |
|
183 | 1047 |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
1048 |
"/ self clear. |
863 | 1049 |
|
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1050 |
doBusy := showBusy value. |
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1051 |
doBusy ifFalse:[ |
3748 | 1052 |
percentage value < 0 ifTrue:[ |
1053 |
self startBusyIndicationProcess. |
|
1054 |
doBusy := true. |
|
1055 |
]. |
|
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1056 |
]. |
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1057 |
|
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1058 |
doBusy ifTrue:[ |
3748 | 1059 |
self paint:bgColor. |
1060 |
self fillRectangleX:m y:m width:w height:h. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1061 |
|
3748 | 1062 |
lx := (w * busyPosition / 100) rounded. |
1063 |
rx := (w * (busyPosition + 20) / 100) rounded. |
|
1064 |
rx := rx min:w. |
|
1065 |
lx := lx max:m. |
|
1066 |
self paint:fgColor. |
|
1067 |
self fillRectangleX:lx y:m width:(rx - lx) height:h. |
|
1068 |
^ self |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1069 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1070 |
|
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1071 |
self stopBusyIndicationProcess. |
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1072 |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1073 |
rx := (w * percentage / 100) rounded. |
826 | 1074 |
self paint:bgColor. |
843 | 1075 |
self fillRectangleX:m+rx y:m width:w-rx height:h. |
183 | 1076 |
|
1077 |
showPercentage ifTrue:[ |
|
3748 | 1078 |
s := percentage printString , ' %'. |
1079 |
font := font onDevice:device. |
|
1080 |
sw := font widthOf:s . |
|
1081 |
sx := (width - sw) // 2. |
|
1082 |
sy := height // 2 + font descent + 2. |
|
347 | 1083 |
|
3748 | 1084 |
rx <= (sx+sw) ifTrue:[ |
1085 |
self paint:Color black. |
|
1086 |
self displayString:s x:sx y:sy. |
|
1087 |
] |
|
183 | 1088 |
]. |
1089 |
||
1090 |
self paint:fgColor. |
|
1091 |
self fillRectangleX:m y:m width:rx height:h. |
|
1092 |
||
1093 |
showPercentage ifTrue:[ |
|
3748 | 1094 |
rx >= sx ifTrue:[ |
4127 | 1095 |
oldClip := self clippingRectangleOrNil. |
3748 | 1096 |
self clippingRectangle:(m@m corner:rx+1 @ h). |
1097 |
self paint:Color white. |
|
1098 |
self displayString:s x:sx y:sy. |
|
4127 | 1099 |
self clippingRectangle:oldClip |
3748 | 1100 |
] |
183 | 1101 |
] |
347 | 1102 |
|
3748 | 1103 |
"Modified: / 12-12-2006 / 18:26:02 / janfrog" |
4127 | 1104 |
"Modified: / 15-05-2012 / 10:58:14 / cg" |
863 | 1105 |
! |
1106 |
||
1107 |
sizeChanged:how |
|
1108 |
super sizeChanged:how. |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1109 |
self invalidate |
863 | 1110 |
|
1111 |
"Created: / 18.4.1998 / 02:34:37 / cg" |
|
865 | 1112 |
"Modified: / 18.4.1998 / 14:09:40 / cg" |
183 | 1113 |
! ! |
1114 |
||
2501 | 1115 |
!ProgressIndicator methodsFor:'initialization & release'! |
183 | 1116 |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1117 |
destroy |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1118 |
busyIndicationProcess notNil ifTrue:[ |
2563 | 1119 |
self stopBusyIndicationProcess |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1120 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1121 |
super destroy. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1122 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1123 |
"Created: / 21.10.1998 / 17:29:58 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1124 |
"Modified: / 21.10.1998 / 17:30:36 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1125 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1126 |
|
574 | 1127 |
initStyle |
1128 |
"initialize styleSheet values" |
|
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1129 |
|
575 | 1130 |
<resource: #style (#'progressIndicator.viewBackground' |
2921 | 1131 |
#'progressIndicator.foregroundColor')> |
574 | 1132 |
|
1133 |
super initStyle. |
|
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1134 |
|
347 | 1135 |
self is3D ifTrue:[ |
2921 | 1136 |
self level:-1 |
347 | 1137 |
]. |
1138 |
||
826 | 1139 |
bgColor := styleSheet colorAt:'progressIndicator.viewBackground' default:Color white. |
574 | 1140 |
fgColor := styleSheet colorAt:'progressIndicator.foregroundColor' default:Color blue. |
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1141 |
fgColor := fgColor onDevice:device. |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1142 |
|
183 | 1143 |
showPercentage := true. |
574 | 1144 |
! |
1145 |
||
1146 |
initialize |
|
826 | 1147 |
|
574 | 1148 |
super initialize. |
826 | 1149 |
|
574 | 1150 |
percentage := 0. |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1151 |
showBusy := false. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1152 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1153 |
"Modified: / 21.10.1998 / 17:33:02 / cg" |
1935
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1154 |
! |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1155 |
|
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1156 |
mapped |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1157 |
super mapped. |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1158 |
(showBusy value) ifTrue:[ |
2563 | 1159 |
self startBusyIndicationProcess. |
1935
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1160 |
]. |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1161 |
! |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1162 |
|
3970 | 1163 |
release |
1164 |
super release. |
|
1165 |
showBusy notNil ifTrue:[showBusy removeDependent:self]. |
|
1166 |
||
1167 |
"Created: / 17-11-2010 / 13:44:45 / cg" |
|
1168 |
! |
|
1169 |
||
1935
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1170 |
unmapped |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1171 |
super unmapped. |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1172 |
(showBusy value) ifTrue:[ |
2563 | 1173 |
self stopBusyIndicationProcess. |
1935
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1174 |
]. |
574 | 1175 |
! ! |
1176 |
||
1177 |
!ProgressIndicator methodsFor:'private'! |
|
1178 |
||
1179 |
connectToTop:top label:label |
|
1180 |
connectedTop := top. |
|
1181 |
connectedLabel := label |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1182 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1183 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1184 |
startBusyIndicationProcess |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1185 |
busyIndicationProcess isNil ifTrue:[ |
2563 | 1186 |
busyPosition := 0. |
1187 |
busyDelta := 5. |
|
1188 |
busyIndicationProcess := [ |
|
1189 |
[self realized] whileTrue:[ |
|
1190 |
Delay waitForSeconds:0.2. |
|
1191 |
self shown ifTrue:[ |
|
1192 |
self updateBusyIndicatorPosition. |
|
1193 |
] |
|
1194 |
]. |
|
1195 |
busyIndicationProcess := nil. |
|
1196 |
] fork. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1197 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1198 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1199 |
"Created: / 21.10.1998 / 18:02:35 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1200 |
"Modified: / 21.10.1998 / 18:03:49 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1201 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1202 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1203 |
stopBusyIndicationProcess |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1204 |
busyIndicationProcess notNil ifTrue:[ |
2563 | 1205 |
busyIndicationProcess terminate. |
1206 |
busyIndicationProcess := nil |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1207 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1208 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1209 |
"Created: / 21.10.1998 / 17:30:19 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1210 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1211 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1212 |
updateBusyIndicatorPosition |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1213 |
busyPosition := busyPosition + busyDelta. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1214 |
busyPosition >= 80 ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1215 |
busyDelta > 0 ifTrue:[ |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1216 |
busyDelta := busyDelta negated. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1217 |
] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1218 |
] ifFalse:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1219 |
busyPosition <= 0 ifTrue:[ |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1220 |
busyDelta < 0 ifTrue:[ |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1221 |
busyDelta := busyDelta negated. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1222 |
] |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1223 |
] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1224 |
]. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1225 |
self invalidate |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1226 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1227 |
"Created: / 21.10.1998 / 17:33:28 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1228 |
"Modified: / 21.10.1998 / 17:58:58 / cg" |
183 | 1229 |
! ! |
1230 |
||
1231 |
!ProgressIndicator methodsFor:'queries'! |
|
1232 |
||
1233 |
preferredExtent |
|
574 | 1234 |
"return my preferred extent" |
1235 |
||
3581
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1236 |
"/ If I have an explicit preferredExtent.. |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1237 |
explicitExtent notNil ifTrue:[ |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1238 |
^ explicitExtent |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1239 |
]. |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1240 |
|
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1241 |
"/ If I have a cached preferredExtent value.. |
334 | 1242 |
preferredExtent notNil ifTrue:[ |
3581
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1243 |
^ preferredExtent |
334 | 1244 |
]. |
183 | 1245 |
^ 100 @ (font height + font descent + ((margin + 1) * 2)) |
334 | 1246 |
|
574 | 1247 |
"Modified: 22.10.1997 / 21:07:17 / cg" |
183 | 1248 |
! ! |
1249 |
||
62 | 1250 |
!ProgressIndicator methodsFor:'showing progress'! |
1251 |
||
4079 | 1252 |
new_showBusyIndicatorDuring:aBlock |
1253 |
"show progress, while evaluating aBlock. |
|
1254 |
If the receiver has been created with inBox, show the |
|
1255 |
box centered on the screen. If not, the view is assumed to |
|
1256 |
be contained in another view, and no special startup actions |
|
1257 |
are performed. |
|
1258 |
||
1259 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1260 |
||
1261 |
|labelValue p| |
|
1262 |
||
1263 |
connectedLabel notNil ifTrue:[ |
|
1264 |
labelValue := (connectedLabel label ? '') asValue. |
|
1265 |
connectedLabel |
|
1266 |
model:labelValue; |
|
1267 |
aspect:#value; |
|
1268 |
labelMessage:#value. |
|
1269 |
] ifFalse:[ |
|
1270 |
labelValue := '' asValue. |
|
1271 |
]. |
|
1272 |
||
1273 |
"/ the display process |
|
1274 |
p := [ |
|
1275 |
self topView show. |
|
1276 |
] fork. |
|
1277 |
||
1278 |
"/ the worker process |
|
1279 |
||
1280 |
[ |
|
4088 | 1281 |
aBlock valueWithOptionalArgument:labelValue |
4079 | 1282 |
] ensure:[ |
1283 |
p terminate. |
|
1284 |
p := nil. |
|
1285 |
self stopBusyIndicationProcess. |
|
1286 |
closeTopWhenDone ifTrue:[ |
|
1287 |
connectedTop sensor pushEvent:(WindowEvent terminateView:connectedTop). |
|
1288 |
connectedTop hide |
|
1289 |
]. |
|
1290 |
self topView hide. |
|
1291 |
finishAction value |
|
1292 |
]. |
|
1293 |
||
1294 |
" |
|
1295 |
|p| |
|
1296 |
||
1297 |
p := ProgressIndicator inBox. |
|
1298 |
p showBusyIndication:true. |
|
1299 |
p showProgressOf: |
|
1300 |
[:progressValue :currentAction | |
|
1301 |
1 to:200 do:[:percent | |
|
1302 |
(Delay forSeconds:0.05) wait. |
|
1303 |
progressValue value:percent |
|
1304 |
]. |
|
1305 |
]. |
|
1306 |
||
1307 |
'it can be reused ...'. |
|
1308 |
p showBusyIndication:false. |
|
1309 |
p showProgressOf: |
|
1310 |
[:progressValue :currentAction | |
|
1311 |
1 to:100 by:5 do:[:percent | |
|
1312 |
(Delay forSeconds:0.05) wait. |
|
1313 |
progressValue value:percent |
|
1314 |
]. |
|
1315 |
]. |
|
1316 |
||
1317 |
" |
|
1318 |
||
1319 |
"Created: / 14-09-2011 / 18:41:44 / cg" |
|
1320 |
! |
|
1321 |
||
4078 | 1322 |
new_showProgressOf:aBlock |
1323 |
"show progress, while evaluating aBlock. |
|
1324 |
If the receiver has been created with inBox, show the |
|
1325 |
box centered on the screen. If not, the view is assumed to |
|
1326 |
be contained in another view, and no special startup actions |
|
1327 |
are performed. |
|
1328 |
||
1329 |
The block is passed two arguments, the progressValue, |
|
1330 |
which should be set to the percentage from time-to-time |
|
1331 |
within the block and an action value, which should be set to |
|
1332 |
the currently performed action (a string) from time to time. |
|
1333 |
The second valueHolder can be left unchanged. |
|
1334 |
||
1335 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1336 |
||
1337 |
|progressValue labelValue p aborted| |
|
1338 |
||
1339 |
progressValue := 0 asValue. |
|
1340 |
aborted := false. |
|
1341 |
||
1342 |
connectedLabel notNil ifTrue:[ |
|
1343 |
labelValue := (connectedLabel label ? '') asValue. |
|
1344 |
connectedLabel |
|
1345 |
model:labelValue; |
|
1346 |
aspect:#value; |
|
1347 |
labelMessage:#value. |
|
1348 |
] ifFalse:[ |
|
1349 |
labelValue := '' asValue. |
|
1350 |
]. |
|
1351 |
||
1352 |
self model:progressValue. |
|
1353 |
||
1354 |
"/ the display process |
|
1355 |
p := [ |
|
1356 |
self topView show. |
|
1357 |
] fork. |
|
1358 |
||
1359 |
"/ WindowGroup windowGroupQuerySignal handle:[:ex | |
|
1360 |
"/ ex proceedWith:self topView windowGroup |
|
1361 |
"/ ] do:[ |
|
1362 |
[ |
|
1363 |
aBlock value:progressValue value:labelValue |
|
1364 |
] ensure:[ |
|
1365 |
p terminate. |
|
1366 |
p := nil. |
|
1367 |
closeTopWhenDone ifTrue:[ |
|
1368 |
connectedTop sensor pushEvent:(WindowEvent terminateView:connectedTop). |
|
1369 |
connectedTop hide |
|
1370 |
]. |
|
1371 |
self topView hide. |
|
1372 |
finishAction value |
|
1373 |
]. |
|
1374 |
"/ ]. |
|
1375 |
||
1376 |
" |
|
1377 |
|p| |
|
1378 |
||
1379 |
p := ProgressIndicator inBox. |
|
1380 |
p showBusyIndication:true. |
|
1381 |
p showProgressOf: |
|
1382 |
[:progressValue :currentAction | |
|
1383 |
1 to:200 do:[:percent | |
|
1384 |
(Delay forSeconds:0.05) wait. |
|
1385 |
progressValue value:percent |
|
1386 |
]. |
|
1387 |
]. |
|
1388 |
||
1389 |
'it can be reused ...'. |
|
1390 |
p showBusyIndication:false. |
|
1391 |
p showProgressOf: |
|
1392 |
[:progressValue :currentAction | |
|
1393 |
1 to:100 by:5 do:[:percent | |
|
1394 |
(Delay forSeconds:0.05) wait. |
|
1395 |
progressValue value:percent |
|
1396 |
]. |
|
1397 |
]. |
|
1398 |
||
1399 |
" |
|
1400 |
||
1401 |
"Created: / 14-09-2011 / 11:02:21 / cg" |
|
1402 |
! |
|
1403 |
||
4079 | 1404 |
old_showBusyIndicatorDuring:aBlock |
1405 |
"show progress, while evaluating aBlock. |
|
1406 |
If the receiver has been created with inBox, show the |
|
1407 |
box centered on the screen. If not, the view is assumed to |
|
1408 |
be contained in another view, and no special startup actions |
|
1409 |
are performed. |
|
1410 |
||
1411 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1412 |
||
1413 |
|labelValue p| |
|
1414 |
||
1415 |
connectedLabel notNil ifTrue:[ |
|
1416 |
labelValue := (connectedLabel label ? '') asValue. |
|
1417 |
connectedLabel |
|
1418 |
model:labelValue; |
|
1419 |
aspect:#value; |
|
1420 |
labelMessage:#value. |
|
1421 |
] ifFalse:[ |
|
1422 |
labelValue := '' asValue. |
|
1423 |
]. |
|
1424 |
||
1425 |
||
1426 |
"/ the worker process |
|
1427 |
||
1428 |
p := [ |
|
1429 |
[ |
|
1430 |
WindowGroup windowGroupQuerySignal handle:[:ex | |
|
1431 |
ex proceedWith:self topView windowGroup |
|
1432 |
] do:[ |
|
4088 | 1433 |
aBlock valueWithOptionalArgument:labelValue |
4079 | 1434 |
] |
1435 |
] ensure:[ |
|
1436 |
p := nil. |
|
1437 |
self stopBusyIndicationProcess. |
|
1438 |
closeTopWhenDone ifTrue:[ |
|
1439 |
connectedTop hide |
|
1440 |
]. |
|
1441 |
finishAction value. |
|
1442 |
||
1443 |
] |
|
1444 |
] newProcess. |
|
1445 |
||
1446 |
Processor activeProcess |
|
1447 |
withHigherPriorityDo: |
|
1448 |
[ |
|
1449 |
p resume. |
|
1450 |
self topView show. |
|
1451 |
]. |
|
1452 |
p notNil ifTrue:[p terminate]. |
|
1453 |
||
1454 |
" |
|
1455 |
|p| |
|
1456 |
||
1457 |
p := ProgressIndicator inBox. |
|
1458 |
p showBusyIndication:true. |
|
1459 |
p showProgressOf: |
|
1460 |
[:progressValue :currentAction | |
|
1461 |
1 to:200 do:[:percent | |
|
1462 |
(Delay forSeconds:0.05) wait. |
|
1463 |
progressValue value:percent |
|
1464 |
]. |
|
1465 |
]. |
|
1466 |
||
1467 |
'it can be reused ...'. |
|
1468 |
p showBusyIndication:false. |
|
1469 |
p showProgressOf: |
|
1470 |
[:progressValue :currentAction | |
|
1471 |
1 to:100 by:5 do:[:percent | |
|
1472 |
(Delay forSeconds:0.05) wait. |
|
1473 |
progressValue value:percent |
|
1474 |
]. |
|
1475 |
]. |
|
1476 |
||
1477 |
" |
|
1478 |
||
1479 |
"Created: / 14-09-2011 / 18:41:34 / cg" |
|
1480 |
! |
|
1481 |
||
4078 | 1482 |
old_showProgressOf:aBlock |
1483 |
"show progress, while evaluating aBlock. |
|
1484 |
If the receiver has been created with inBox, show the |
|
1485 |
box centered on the screen. If not, the view is assumed to |
|
1486 |
be contained in another view, and no special startup actions |
|
1487 |
are performed. |
|
1488 |
||
1489 |
The block is passed two arguments, the progressValue, |
|
1490 |
which should be set to the percentage from time-to-time |
|
1491 |
within the block and an action value, which should be set to |
|
1492 |
the currently performed action (a string) from time to time. |
|
1493 |
The second valueHolder can be left unchanged. |
|
1494 |
||
1495 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1496 |
||
1497 |
|progressValue labelValue p aborted| |
|
1498 |
||
1499 |
progressValue := 0 asValue. |
|
1500 |
aborted := false. |
|
1501 |
||
1502 |
connectedLabel notNil ifTrue:[ |
|
1503 |
labelValue := (connectedLabel label ? '') asValue. |
|
1504 |
connectedLabel |
|
1505 |
model:labelValue; |
|
1506 |
aspect:#value; |
|
1507 |
labelMessage:#value. |
|
1508 |
] ifFalse:[ |
|
1509 |
labelValue := '' asValue. |
|
1510 |
]. |
|
1511 |
||
1512 |
self model:progressValue. |
|
1513 |
||
1514 |
"/ the worker process |
|
1515 |
||
1516 |
p := [ |
|
1517 |
[ |
|
1518 |
WindowGroup windowGroupQuerySignal handle:[:ex | |
|
1519 |
ex proceedWith:self topView windowGroup |
|
1520 |
] do:[ |
|
1521 |
AbortSignal handle:[:ex | |
|
1522 |
aborted := true |
|
1523 |
] do:[ |
|
1524 |
aBlock value:progressValue value:labelValue |
|
1525 |
] |
|
1526 |
] |
|
1527 |
] ensure:[ |
|
1528 |
p := nil. |
|
1529 |
closeTopWhenDone ifTrue:[ |
|
1530 |
connectedTop sensor pushEvent:(WindowEvent terminateView:connectedTop). |
|
1531 |
connectedTop hide |
|
1532 |
]. |
|
1533 |
finishAction value |
|
1534 |
] |
|
1535 |
] newProcess. |
|
1536 |
||
1537 |
Processor activeProcess |
|
1538 |
withHigherPriorityDo:[ |
|
1539 |
p resume. |
|
1540 |
self topView show. |
|
1541 |
]. |
|
1542 |
p notNil ifTrue:[p terminate]. |
|
1543 |
aborted ifTrue:[ |
|
1544 |
AbortSignal raiseRequest |
|
1545 |
]. |
|
1546 |
||
1547 |
" |
|
1548 |
|p| |
|
1549 |
||
1550 |
p := ProgressIndicator inBox. |
|
1551 |
p showBusyIndication:true. |
|
1552 |
p showProgressOf: |
|
1553 |
[:progressValue :currentAction | |
|
1554 |
1 to:200 do:[:percent | |
|
1555 |
(Delay forSeconds:0.05) wait. |
|
1556 |
progressValue value:percent |
|
1557 |
]. |
|
1558 |
]. |
|
1559 |
||
1560 |
'it can be reused ...'. |
|
1561 |
p showBusyIndication:false. |
|
1562 |
p showProgressOf: |
|
1563 |
[:progressValue :currentAction | |
|
1564 |
1 to:100 by:5 do:[:percent | |
|
1565 |
(Delay forSeconds:0.05) wait. |
|
1566 |
progressValue value:percent |
|
1567 |
]. |
|
1568 |
]. |
|
1569 |
||
1570 |
" |
|
1571 |
||
1572 |
"Modified: / 12-09-2011 / 09:57:03 / cg" |
|
1573 |
"Created: / 14-09-2011 / 11:00:12 / cg" |
|
1574 |
! |
|
1575 |
||
2850 | 1576 |
showBusyIndicatorDuring:aBlock |
1577 |
"show progress, while evaluating aBlock. |
|
1578 |
If the receiver has been created with inBox, show the |
|
1579 |
box centered on the screen. If not, the view is assumed to |
|
1580 |
be contained in another view, and no special startup actions |
|
1581 |
are performed. |
|
1582 |
||
1583 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1584 |
||
1585 |
|labelValue p| |
|
1586 |
||
1587 |
connectedLabel notNil ifTrue:[ |
|
1588 |
labelValue := (connectedLabel label ? '') asValue. |
|
1589 |
connectedLabel |
|
1590 |
model:labelValue; |
|
1591 |
aspect:#value; |
|
1592 |
labelMessage:#value. |
|
1593 |
] ifFalse:[ |
|
1594 |
labelValue := '' asValue. |
|
1595 |
]. |
|
1596 |
||
1597 |
||
1598 |
"/ the worker process |
|
1599 |
||
4096
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1600 |
p := |
2850 | 1601 |
[ |
4096
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1602 |
[ |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1603 |
WindowGroup windowGroupQuerySignal handle:[:ex | |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1604 |
ex proceedWith:self topView windowGroup |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1605 |
] do:[ |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1606 |
aBlock valueWithOptionalArgument:labelValue |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1607 |
] |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1608 |
] ensure:[ |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1609 |
p := nil. |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1610 |
self stopBusyIndicationProcess. |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1611 |
closeTopWhenDone ifTrue:[ |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1612 |
connectedTop hide |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1613 |
]. |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1614 |
finishAction value. |
2850 | 1615 |
] |
4096
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1616 |
] newProcess. |
2850 | 1617 |
|
1618 |
Processor activeProcess |
|
2878 | 1619 |
withHigherPriorityDo: |
1620 |
[ |
|
1621 |
p resume. |
|
1622 |
self topView show. |
|
1623 |
]. |
|
2850 | 1624 |
p notNil ifTrue:[p terminate]. |
1625 |
||
1626 |
" |
|
1627 |
|p| |
|
1628 |
||
1629 |
p := ProgressIndicator inBox. |
|
1630 |
p showBusyIndication:true. |
|
1631 |
p showProgressOf: |
|
1632 |
[:progressValue :currentAction | |
|
1633 |
1 to:200 do:[:percent | |
|
1634 |
(Delay forSeconds:0.05) wait. |
|
1635 |
progressValue value:percent |
|
1636 |
]. |
|
1637 |
]. |
|
1638 |
||
1639 |
'it can be reused ...'. |
|
1640 |
p showBusyIndication:false. |
|
1641 |
p showProgressOf: |
|
1642 |
[:progressValue :currentAction | |
|
1643 |
1 to:100 by:5 do:[:percent | |
|
1644 |
(Delay forSeconds:0.05) wait. |
|
1645 |
progressValue value:percent |
|
1646 |
]. |
|
1647 |
]. |
|
1648 |
||
1649 |
" |
|
1650 |
||
4088 | 1651 |
"Modified: / 07-11-2011 / 21:53:46 / cg" |
4096
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1652 |
"Modified (format): / 08-01-2012 / 12:00:39 / cg" |
2850 | 1653 |
! |
1654 |
||
62 | 1655 |
showProgressOf:aBlock |
1656 |
"show progress, while evaluating aBlock. |
|
1657 |
If the receiver has been created with inBox, show the |
|
1658 |
box centered on the screen. If not, the view is assumed to |
|
1659 |
be contained in another view, and no special startup actions |
|
1660 |
are performed. |
|
1661 |
||
1662 |
The block is passed two arguments, the progressValue, |
|
1663 |
which should be set to the percentage from time-to-time |
|
1664 |
within the block and an action value, which should be set to |
|
1665 |
the currently performed action (a string) from time to time. |
|
1666 |
The second valueHolder can be left unchanged. |
|
1667 |
||
1668 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1669 |
||
4078 | 1670 |
"/ ^ self old_showProgressOf:aBlock |
1671 |
^ self new_showProgressOf:aBlock |
|
62 | 1672 |
|
1673 |
" |
|
1674 |
|p| |
|
1675 |
||
1676 |
p := ProgressIndicator inBox. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1677 |
p showBusyIndication:true. |
62 | 1678 |
p showProgressOf: |
2837 | 1679 |
[:progressValue :currentAction | |
1680 |
1 to:200 do:[:percent | |
|
1681 |
(Delay forSeconds:0.05) wait. |
|
1682 |
progressValue value:percent |
|
1683 |
]. |
|
1684 |
]. |
|
62 | 1685 |
|
1686 |
'it can be reused ...'. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1687 |
p showBusyIndication:false. |
62 | 1688 |
p showProgressOf: |
2837 | 1689 |
[:progressValue :currentAction | |
1690 |
1 to:100 by:5 do:[:percent | |
|
1691 |
(Delay forSeconds:0.05) wait. |
|
1692 |
progressValue value:percent |
|
1693 |
]. |
|
1694 |
]. |
|
62 | 1695 |
|
1696 |
" |
|
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
1697 |
|
4078 | 1698 |
"Modified: / 14-09-2011 / 17:03:08 / cg" |
62 | 1699 |
! ! |
1700 |
||
334 | 1701 |
!ProgressIndicator class methodsFor:'documentation'! |
50 | 1702 |
|
183 | 1703 |
version |
4127 | 1704 |
^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.72 2012-05-15 09:53:23 cg Exp $' |
3827
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
1705 |
! |
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
1706 |
|
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
1707 |
version_CVS |
4127 | 1708 |
^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.72 2012-05-15 09:53:23 cg Exp $' |
50 | 1709 |
! ! |