author | Stefan Vogel <sv@exept.de> |
Tue, 18 Feb 2014 16:06:59 +0100 | |
changeset 4511 | b1a6da90fdc5 |
parent 4469 | a4d672240503 |
child 4709 | b9e63b8565c1 |
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 |
|
4260 | 544 |
^ self progressOpenOn:progressModel title:aLabel label:aLabel |
545 |
! |
|
546 |
||
547 |
progressOpenOn:progressModel title:title label:aLabel |
|
548 |
"create and open a progressIndicator dialog window, |
|
549 |
bit do not open it modal; instead, it is opened modeless |
|
550 |
and control returns to the caller. |
|
551 |
The models value is assumed to be 0..1 |
|
552 |
(which is for compatibility and different from ST/X's percentage use) |
|
553 |
Added for VW compatibility (RB)." |
|
554 |
||
1681
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
555 |
|p ra| |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
556 |
|
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
557 |
p := self |
4260 | 558 |
inBoxWithLabel:title |
559 |
icon:nil |
|
560 |
text:aLabel |
|
561 |
abortable:false |
|
562 |
view:nil |
|
563 |
closeWhenDone:false. |
|
1681
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
564 |
|
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
565 |
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
|
566 |
p model:ra. |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
567 |
|
2132 | 568 |
p topView openModeless; waitUntilVisible. |
1681
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
569 |
^ p. |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
570 |
|
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
571 |
"Modified: / 4.2.2000 / 01:25:55 / cg" |
62 | 572 |
! ! |
573 |
||
3999 | 574 |
!ProgressIndicator class methodsFor:'simple public API'! |
3542 | 575 |
|
576 |
displayBusyIndicator:aLabel abortable:abortable at:aPoint during:aBlock |
|
577 |
"easy interface - show progress while evaluating aBlock. |
|
578 |
The block is passed the progressIndicator as argument |
|
579 |
so the block can change the label and/or change the progress value." |
|
580 |
||
3967 | 581 |
^ self |
582 |
displayBusyIndicator:aLabel |
|
583 |
message:aLabel |
|
584 |
abortable:abortable |
|
585 |
at:aPoint |
|
586 |
during:aBlock |
|
587 |
||
588 |
" |
|
589 |
ProgressIndicator |
|
590 |
displayBusyIndicator:'doobidoobidoo...' |
|
591 |
abortable:true |
|
592 |
at:(Screen default center) |
|
593 |
during:[ |
|
594 |
200 to:400 by:5 do:[:i | |
|
595 |
Delay waitForSeconds:0.1. |
|
596 |
] |
|
597 |
]. |
|
598 |
||
599 |
ProgressIndicator |
|
600 |
displayBusyIndicator:'doobidoobidoo...' |
|
601 |
abortable:true |
|
602 |
at:(Screen default center) |
|
603 |
during:[ |
|
604 |
Delay waitForSeconds:3. |
|
605 |
]. |
|
606 |
" |
|
607 |
||
608 |
"Modified: / 12-11-2010 / 18:59:45 / cg" |
|
609 |
! |
|
610 |
||
611 |
displayBusyIndicator:aLabel at:aPoint during:aBlock |
|
612 |
"easy interface - show progress while evaluating aBlock. |
|
613 |
The block is passed a valueHolder, which is to be set to values from |
|
614 |
startValue to endValue during the blocks evaluation. |
|
615 |
This is scaled to 0..100% completion. |
|
616 |
Set the valueHolder to nil, to get a busy-indicator" |
|
617 |
||
618 |
self |
|
619 |
displayBusyIndicator:aLabel |
|
620 |
abortable:false |
|
621 |
at:aPoint |
|
622 |
during:aBlock |
|
623 |
||
624 |
" |
|
625 |
ProgressIndicator |
|
626 |
displayBusyIndicator:'doobidoobidoo...' |
|
627 |
at:(Screen default center) |
|
628 |
during:[ |
|
629 |
200 to:400 by:5 do:[:i | |
|
630 |
Delay waitForSeconds:0.1. |
|
631 |
] |
|
632 |
]. |
|
633 |
" |
|
634 |
! |
|
635 |
||
636 |
displayBusyIndicator:aLabel message:messageString abortable:abortable at:aPoint during:aBlock |
|
637 |
"easy interface - show progress while evaluating aBlock. |
|
638 |
The block is passed the progressIndicator as argument |
|
639 |
so the block can change the label and/or change the progress value." |
|
640 |
||
3542 | 641 |
|p| |
642 |
||
643 |
p := self |
|
644 |
inBoxWithLabel:aLabel |
|
645 |
icon:nil |
|
3967 | 646 |
text:messageString |
3542 | 647 |
abortable:abortable |
648 |
view:nil |
|
649 |
closeWhenDone:true. |
|
650 |
||
4106
94e77b757100
changed: #displayBusyIndicator:message:abortable:at:during:
ab
parents:
4096
diff
changeset
|
651 |
aPoint notNil ifTrue:[ |
94e77b757100
changed: #displayBusyIndicator:message:abortable:at:during:
ab
parents:
4096
diff
changeset
|
652 |
p topView origin:aPoint |
94e77b757100
changed: #displayBusyIndicator:message:abortable:at:during:
ab
parents:
4096
diff
changeset
|
653 |
]. |
94e77b757100
changed: #displayBusyIndicator:message:abortable:at:during:
ab
parents:
4096
diff
changeset
|
654 |
|
3542 | 655 |
p showBusyIndication:true. |
656 |
p showBusyIndicatorDuring:[ |
|
657 |
CannotReturnError catch:[ |
|
658 |
aBlock valueWithOptionalArgument:p. |
|
659 |
] |
|
660 |
] |
|
661 |
||
662 |
" |
|
663 |
ProgressIndicator |
|
664 |
displayBusyIndicator:'doobidoobidoo...' |
|
665 |
abortable:true |
|
666 |
at:(Screen default center) |
|
667 |
during:[ |
|
668 |
200 to:400 by:5 do:[:i | |
|
669 |
Delay waitForSeconds:0.1. |
|
670 |
] |
|
671 |
]. |
|
3626
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
672 |
|
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
673 |
ProgressIndicator |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
674 |
displayBusyIndicator:'doobidoobidoo...' |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
675 |
abortable:true |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
676 |
at:(Screen default center) |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
677 |
during:[ |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
678 |
Delay waitForSeconds:3. |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
679 |
]. |
3542 | 680 |
" |
3967 | 681 |
|
682 |
"Created: / 12-11-2010 / 18:59:13 / cg" |
|
3542 | 683 |
! |
684 |
||
3967 | 685 |
displayBusyIndicator:aLabel message:messageString at:aPoint during:aBlock |
3542 | 686 |
"easy interface - show progress while evaluating aBlock. |
687 |
The block is passed a valueHolder, which is to be set to values from |
|
688 |
startValue to endValue during the blocks evaluation. |
|
689 |
This is scaled to 0..100% completion. |
|
690 |
Set the valueHolder to nil, to get a busy-indicator" |
|
691 |
||
692 |
self |
|
3967 | 693 |
displayBusyIndicator:aLabel |
694 |
message:messageString |
|
3542 | 695 |
abortable:false |
696 |
at:aPoint |
|
697 |
during:aBlock |
|
698 |
||
699 |
" |
|
700 |
ProgressIndicator |
|
701 |
displayBusyIndicator:'doobidoobidoo...' |
|
702 |
at:(Screen default center) |
|
703 |
during:[ |
|
704 |
200 to:400 by:5 do:[:i | |
|
705 |
Delay waitForSeconds:0.1. |
|
706 |
] |
|
707 |
]. |
|
708 |
" |
|
3967 | 709 |
|
710 |
"Created: / 12-11-2010 / 19:01:12 / cg" |
|
3542 | 711 |
! |
712 |
||
713 |
displayProgress:aLabel at:aPoint from:startValue to:endValue during:aBlock |
|
714 |
"easy interface - show progress while evaluating aBlock. |
|
715 |
The block is passed a valueHolder, which is to be set to values from |
|
716 |
startValue to endValue during the blocks evaluation. |
|
717 |
This is scaled to 0..100% completion. |
|
718 |
Set the valueHolder to nil, to get a busy-indicator" |
|
719 |
||
3967 | 720 |
^ self |
721 |
displayProgress:aLabel |
|
722 |
message:aLabel |
|
723 |
at:aPoint |
|
724 |
from:startValue |
|
725 |
to:endValue |
|
726 |
during:aBlock |
|
727 |
||
728 |
" |
|
729 |
ProgressIndicator |
|
730 |
displayProgress:'doobidoobidoo...' |
|
731 |
at:(Screen default center) |
|
732 |
from:200 to:400 |
|
733 |
during:[:val | |
|
734 |
200 to:400 by:5 do:[:i | |
|
735 |
val value:i. |
|
736 |
Delay waitForSeconds:0.1. |
|
737 |
] |
|
738 |
]. |
|
739 |
" |
|
740 |
||
741 |
"Modified: / 12-11-2010 / 19:02:27 / cg" |
|
742 |
! |
|
743 |
||
744 |
displayProgress:aLabel message:messageString at:aPoint from:startValue to:endValue during:aBlock |
|
745 |
"easy interface - show progress while evaluating aBlock. |
|
746 |
The block is passed a valueHolder, which is to be set to values from |
|
747 |
startValue to endValue during the blocks evaluation. |
|
748 |
This is scaled to 0..100% completion. |
|
749 |
Set the valueHolder to nil, to get a busy-indicator" |
|
750 |
||
3542 | 751 |
|p| |
752 |
||
753 |
p := self |
|
754 |
inBoxWithLabel:aLabel |
|
755 |
icon:nil |
|
3967 | 756 |
text:messageString |
3542 | 757 |
abortable:false |
758 |
view:nil |
|
759 |
closeWhenDone:true. |
|
760 |
||
761 |
p showProgressOf:[:progressValue :currentAction | |
|
762 |
|scaler| |
|
763 |
||
764 |
scaler := [:scaledValue | |
|
765 |
|newPercentage oldPercentage oldLabel| |
|
766 |
||
767 |
scaledValue isNil ifTrue:[ |
|
768 |
p showBusyIndication:true |
|
769 |
] ifFalse:[ |
|
770 |
p showBusyIndication:false. |
|
771 |
oldPercentage := progressValue value. |
|
3827
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
772 |
endValue = startValue ifTrue:[ |
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
773 |
newPercentage := 0. |
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
774 |
] ifFalse:[ |
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
775 |
newPercentage := (scaledValue - startValue) / (endValue-startValue) * 100. |
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
776 |
]. |
3542 | 777 |
newPercentage ~= oldPercentage ifTrue:[ |
778 |
progressValue value:newPercentage. |
|
779 |
]. |
|
780 |
oldLabel := currentAction value. |
|
781 |
oldLabel ~= aLabel ifTrue:[ |
|
782 |
currentAction value:aLabel. |
|
783 |
] |
|
784 |
] |
|
785 |
]. |
|
786 |
CannotReturnError catch:[ |
|
787 |
aBlock valueWithOptionalArgument:scaler and:p. |
|
788 |
] |
|
789 |
] |
|
790 |
||
791 |
" |
|
792 |
ProgressIndicator |
|
793 |
displayProgress:'doobidoobidoo...' |
|
794 |
at:(Screen default center) |
|
795 |
from:200 to:400 |
|
796 |
during:[:val | |
|
797 |
200 to:400 by:5 do:[:i | |
|
798 |
val value:i. |
|
799 |
Delay waitForSeconds:0.1. |
|
800 |
] |
|
801 |
]. |
|
802 |
" |
|
3967 | 803 |
|
804 |
"Created: / 12-11-2010 / 19:01:38 / cg" |
|
3542 | 805 |
! |
806 |
||
807 |
displayProgressNotifications:aLabel abortable:abortable at:aPointOrNil during:aBlock |
|
808 |
"easy interface - show progress as provided by progressNotifications |
|
809 |
while evaluating aBlock. |
|
810 |
The block is passed the progressIndicator as optional argument, |
|
811 |
however, progressNotifications are handled and update the percentage." |
|
812 |
||
3967 | 813 |
^ self |
814 |
displayProgressNotifications:aLabel |
|
815 |
message:aLabel |
|
816 |
abortable:abortable |
|
817 |
at:aPointOrNil |
|
818 |
during:aBlock |
|
819 |
||
820 |
||
821 |
" |
|
822 |
ProgressIndicator |
|
823 |
displayProgressNotifications:'doobidoobidoo...' |
|
824 |
abortable:true |
|
825 |
at:nil |
|
826 |
during:[ |
|
827 |
200 to:400 by:5 do:[:i | |
|
828 |
Delay waitForSeconds:0.1. |
|
829 |
ProgressNotification progressPercentage:(i / 4). |
|
830 |
] |
|
831 |
]. |
|
832 |
" |
|
833 |
" |
|
834 |
ProgressIndicator |
|
835 |
displayProgressNotifications:'doobidoobidoo...' |
|
836 |
abortable:true |
|
837 |
at:nil |
|
838 |
during:[ |
|
839 |
Delay waitForSeconds:3. |
|
840 |
]. |
|
841 |
" |
|
842 |
||
843 |
"Modified: / 12-11-2010 / 19:03:09 / cg" |
|
844 |
! |
|
845 |
||
846 |
displayProgressNotifications:aLabel message:messageString abortable:abortable at:aPointOrNil during:aBlock |
|
847 |
"easy interface - show progress as provided by progressNotifications |
|
848 |
while evaluating aBlock. |
|
849 |
The block is passed the progressIndicator as optional argument, |
|
850 |
however, progressNotifications are handled and update the percentage." |
|
851 |
||
3542 | 852 |
|p| |
853 |
||
854 |
p := self |
|
855 |
inBoxWithLabel:aLabel |
|
856 |
icon:nil |
|
3967 | 857 |
text:messageString |
3542 | 858 |
abortable:abortable |
859 |
view:nil |
|
860 |
closeWhenDone:true. |
|
861 |
||
862 |
p showBusyIndicatorDuring:[ |
|
863 |
CannotReturnError catch:[ |
|
864 |
ProgressNotification handle:[:ex | |
|
865 |
p percentage:ex progressValue. |
|
866 |
ex proceed. |
|
867 |
] do:[ |
|
868 |
aBlock valueWithOptionalArgument:p. |
|
869 |
]. |
|
870 |
] |
|
871 |
] |
|
872 |
||
873 |
" |
|
874 |
ProgressIndicator |
|
875 |
displayProgressNotifications:'doobidoobidoo...' |
|
876 |
abortable:true |
|
877 |
at:nil |
|
878 |
during:[ |
|
879 |
200 to:400 by:5 do:[:i | |
|
880 |
Delay waitForSeconds:0.1. |
|
881 |
ProgressNotification progressPercentage:(i / 4). |
|
882 |
] |
|
883 |
]. |
|
884 |
" |
|
3626
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
885 |
" |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
886 |
ProgressIndicator |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
887 |
displayProgressNotifications:'doobidoobidoo...' |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
888 |
abortable:true |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
889 |
at:nil |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
890 |
during:[ |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
891 |
Delay waitForSeconds:3. |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
892 |
]. |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
893 |
" |
3967 | 894 |
|
895 |
"Created: / 12-11-2010 / 19:02:43 / cg" |
|
3542 | 896 |
! ! |
897 |
||
183 | 898 |
!ProgressIndicator methodsFor:'accessing'! |
899 |
||
4088 | 900 |
labelWidget |
901 |
^ connectedLabel |
|
902 |
||
903 |
"Created: / 07-11-2011 / 22:01:00 / cg" |
|
904 |
! |
|
905 |
||
4261 | 906 |
model:aValueHolder |
907 |
"set my percentage holder" |
|
908 |
||
909 |
super model:aValueHolder. |
|
910 |
aValueHolder notNil ifTrue:[ |
|
911 |
self percentage:(model perform:aspectMsg) |
|
912 |
]. |
|
913 |
! |
|
914 |
||
334 | 915 |
percentage:aNumber |
916 |
"set the percentage" |
|
237 | 917 |
|
183 | 918 |
|newPercentage| |
919 |
||
4261 | 920 |
newPercentage := -1. |
921 |
(aNumber notNil and:[aNumber >= 0]) ifTrue:[ |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
922 |
newPercentage := ((aNumber max:0) min:100) rounded. |
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
923 |
]. |
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
924 |
newPercentage ~= percentage ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
925 |
percentage := newPercentage. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
926 |
self invalidateRepairNow:true. |
183 | 927 |
] |
334 | 928 |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
929 |
"Modified: / 6.6.1998 / 19:43:56 / cg" |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
930 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
931 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
932 |
showBusyIndication:aBooleanHolder |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
933 |
"switch between percentage mode (if false) and busy indication (if true)" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
934 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
935 |
aBooleanHolder ~~ showBusy ifTrue:[ |
3969
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
936 |
showBusy notNil ifTrue:[ |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
937 |
showBusy removeDependent:self. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
938 |
]. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
939 |
showBusy := aBooleanHolder. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
940 |
showBusy isValueModel ifTrue:[showBusy addDependent:self]. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
941 |
(showBusy value) ifTrue:[ |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
942 |
self startBusyIndicationProcess. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
943 |
] ifFalse:[ |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
944 |
self stopBusyIndicationProcess |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
945 |
]. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
946 |
shown ifTrue:[self redraw] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
947 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
948 |
|
3969
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
949 |
"Created: / 21-10-1998 / 17:35:16 / cg" |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
950 |
"Modified: / 17-11-2010 / 13:43:51 / cg" |
334 | 951 |
! ! |
952 |
||
2404 | 953 |
!ProgressIndicator methodsFor:'accessing-behavior'! |
954 |
||
955 |
closeTopWhenDone:aBoolean |
|
956 |
"set/clear the close-topView-when-done flag" |
|
957 |
||
958 |
closeTopWhenDone := aBoolean |
|
959 |
||
960 |
"Created: 3.9.1996 / 14:22:03 / cg" |
|
961 |
"Modified: 29.3.1997 / 16:08:19 / cg" |
|
962 |
! |
|
963 |
||
964 |
finishAction:aBlock |
|
965 |
"define an action to be performed when finished" |
|
966 |
||
967 |
finishAction := aBlock |
|
968 |
||
969 |
"Created: 3.9.1996 / 14:15:15 / cg" |
|
970 |
"Modified: 29.3.1997 / 16:08:35 / cg" |
|
971 |
! ! |
|
972 |
||
973 |
!ProgressIndicator methodsFor:'accessing-look'! |
|
334 | 974 |
|
826 | 975 |
backgroundColor |
976 |
"return the percentage displays background color" |
|
977 |
||
978 |
^ bgColor |
|
979 |
||
980 |
! |
|
981 |
||
982 |
backgroundColor:aColor |
|
983 |
"set the percentage displays background color" |
|
984 |
||
993 | 985 |
aColor ~= bgColor ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
986 |
bgColor := aColor. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
987 |
self invalidateRepairNow:true |
826 | 988 |
]. |
989 |
||
993 | 990 |
"Modified: / 20.7.1998 / 23:32:48 / cg" |
826 | 991 |
! |
992 |
||
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
993 |
foregroundColor |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
994 |
"return the percentage displays foreground color" |
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 |
^ fgColor |
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:28 / 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 |
|
334 | 1001 |
foregroundColor:aColor |
1002 |
"set the percentage displays foreground color" |
|
1003 |
||
993 | 1004 |
aColor ~= fgColor ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1005 |
fgColor := aColor. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1006 |
self invalidateRepairNow:true |
336 | 1007 |
]. |
334 | 1008 |
|
993 | 1009 |
"Modified: / 20.7.1998 / 23:27:47 / cg" |
183 | 1010 |
! |
1011 |
||
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1012 |
showPercentage |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1013 |
"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
|
1014 |
|
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1015 |
^ showPercentage |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1016 |
|
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1017 |
"Created: 29.3.1997 / 16:12:39 / cg" |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1018 |
! |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1019 |
|
183 | 1020 |
showPercentage:aBoolean |
334 | 1021 |
"set/clear the flag controlling if the percentage is to be shown numerically" |
1022 |
||
336 | 1023 |
showPercentage := aBoolean. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1024 |
self invalidateRepairNow:true |
334 | 1025 |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
1026 |
"Modified: / 6.6.1998 / 19:28:44 / cg" |
183 | 1027 |
! ! |
1028 |
||
1029 |
!ProgressIndicator methodsFor:'change & update'! |
|
1030 |
||
1031 |
update:aspect with:aParameter from:changedObject |
|
574 | 1032 |
"react upon value changes of my model" |
1033 |
||
183 | 1034 |
(aspect == aspectMsg |
1035 |
and:[changedObject == model]) ifTrue:[ |
|
3748 | 1036 |
self percentage:(model perform:aspectMsg). |
1037 |
^ self |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1038 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1039 |
changedObject == showBusy ifTrue:[ |
3748 | 1040 |
showBusy value |
1041 |
ifTrue:[self startBusyIndicationProcess] |
|
1042 |
ifFalse:[self stopBusyIndicationProcess]. |
|
1043 |
self redraw. |
|
1044 |
^ self |
|
183 | 1045 |
]. |
1046 |
^ super update:aspect with:aParameter from:changedObject |
|
574 | 1047 |
|
3748 | 1048 |
"Modified: / 21-10-1998 / 18:01:52 / cg" |
1049 |
"Modified: / 01-11-2006 / 08:40:50 / janfrog" |
|
183 | 1050 |
! ! |
1051 |
||
1052 |
!ProgressIndicator methodsFor:'drawing'! |
|
1053 |
||
1054 |
redraw |
|
574 | 1055 |
"redraw the percentage bar and optional percentage string" |
1056 |
||
4511 | 1057 |
|s lx rx sx sy sw m2 m w h doBusy oldClip currentDeviceFont| |
183 | 1058 |
|
3748 | 1059 |
self shown ifFalse:[^self]. |
1060 |
||
183 | 1061 |
m := margin + 1. |
863 | 1062 |
m2 := m*2. |
1063 |
||
1064 |
w := width - m2. |
|
1065 |
h := height - m2. |
|
183 | 1066 |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
1067 |
"/ self clear. |
863 | 1068 |
|
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1069 |
doBusy := showBusy value. |
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1070 |
doBusy ifFalse:[ |
3748 | 1071 |
percentage value < 0 ifTrue:[ |
1072 |
self startBusyIndicationProcess. |
|
1073 |
doBusy := true. |
|
1074 |
]. |
|
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1075 |
]. |
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1076 |
|
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1077 |
doBusy ifTrue:[ |
3748 | 1078 |
self paint:bgColor. |
1079 |
self fillRectangleX:m y:m width:w height:h. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1080 |
|
3748 | 1081 |
lx := (w * busyPosition / 100) rounded. |
1082 |
rx := (w * (busyPosition + 20) / 100) rounded. |
|
1083 |
rx := rx min:w. |
|
1084 |
lx := lx max:m. |
|
1085 |
self paint:fgColor. |
|
1086 |
self fillRectangleX:lx y:m width:(rx - lx) height:h. |
|
1087 |
^ self |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1088 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1089 |
|
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1090 |
self stopBusyIndicationProcess. |
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1091 |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1092 |
rx := (w * percentage / 100) rounded. |
826 | 1093 |
self paint:bgColor. |
843 | 1094 |
self fillRectangleX:m+rx y:m width:w-rx height:h. |
183 | 1095 |
|
1096 |
showPercentage ifTrue:[ |
|
3748 | 1097 |
s := percentage printString , ' %'. |
4511 | 1098 |
currentDeviceFont := gc createFontOnDevice. |
1099 |
sw := currentDeviceFont widthOf:s . |
|
3748 | 1100 |
sx := (width - sw) // 2. |
4511 | 1101 |
sy := height // 2 + currentDeviceFont descent + 2. |
347 | 1102 |
|
3748 | 1103 |
rx <= (sx+sw) ifTrue:[ |
1104 |
self paint:Color black. |
|
1105 |
self displayString:s x:sx y:sy. |
|
1106 |
] |
|
183 | 1107 |
]. |
1108 |
||
1109 |
self paint:fgColor. |
|
1110 |
self fillRectangleX:m y:m width:rx height:h. |
|
1111 |
||
1112 |
showPercentage ifTrue:[ |
|
3748 | 1113 |
rx >= sx ifTrue:[ |
4127 | 1114 |
oldClip := self clippingRectangleOrNil. |
3748 | 1115 |
self clippingRectangle:(m@m corner:rx+1 @ h). |
1116 |
self paint:Color white. |
|
1117 |
self displayString:s x:sx y:sy. |
|
4127 | 1118 |
self clippingRectangle:oldClip |
3748 | 1119 |
] |
183 | 1120 |
] |
347 | 1121 |
|
3748 | 1122 |
"Modified: / 12-12-2006 / 18:26:02 / janfrog" |
4127 | 1123 |
"Modified: / 15-05-2012 / 10:58:14 / cg" |
863 | 1124 |
! |
1125 |
||
1126 |
sizeChanged:how |
|
1127 |
super sizeChanged:how. |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1128 |
self invalidate |
863 | 1129 |
|
1130 |
"Created: / 18.4.1998 / 02:34:37 / cg" |
|
865 | 1131 |
"Modified: / 18.4.1998 / 14:09:40 / cg" |
183 | 1132 |
! ! |
1133 |
||
2501 | 1134 |
!ProgressIndicator methodsFor:'initialization & release'! |
183 | 1135 |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1136 |
destroy |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1137 |
busyIndicationProcess notNil ifTrue:[ |
2563 | 1138 |
self stopBusyIndicationProcess |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1139 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1140 |
super destroy. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1141 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1142 |
"Created: / 21.10.1998 / 17:29:58 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1143 |
"Modified: / 21.10.1998 / 17:30:36 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1144 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1145 |
|
574 | 1146 |
initStyle |
1147 |
"initialize styleSheet values" |
|
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1148 |
|
575 | 1149 |
<resource: #style (#'progressIndicator.viewBackground' |
2921 | 1150 |
#'progressIndicator.foregroundColor')> |
574 | 1151 |
|
1152 |
super initStyle. |
|
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1153 |
|
347 | 1154 |
self is3D ifTrue:[ |
2921 | 1155 |
self level:-1 |
347 | 1156 |
]. |
1157 |
||
826 | 1158 |
bgColor := styleSheet colorAt:'progressIndicator.viewBackground' default:Color white. |
574 | 1159 |
fgColor := styleSheet colorAt:'progressIndicator.foregroundColor' default:Color blue. |
4511 | 1160 |
fgColor := fgColor onDevice:self graphicsDevice. |
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1161 |
|
183 | 1162 |
showPercentage := true. |
574 | 1163 |
! |
1164 |
||
1165 |
initialize |
|
826 | 1166 |
|
574 | 1167 |
super initialize. |
826 | 1168 |
|
574 | 1169 |
percentage := 0. |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1170 |
showBusy := false. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1171 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1172 |
"Modified: / 21.10.1998 / 17:33:02 / cg" |
1935
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1173 |
! |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1174 |
|
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1175 |
mapped |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1176 |
super mapped. |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1177 |
(showBusy value) ifTrue:[ |
2563 | 1178 |
self startBusyIndicationProcess. |
1935
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1179 |
]. |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1180 |
! |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1181 |
|
3970 | 1182 |
release |
1183 |
super release. |
|
1184 |
showBusy notNil ifTrue:[showBusy removeDependent:self]. |
|
1185 |
||
1186 |
"Created: / 17-11-2010 / 13:44:45 / cg" |
|
1187 |
! |
|
1188 |
||
1935
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1189 |
unmapped |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1190 |
super unmapped. |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1191 |
(showBusy value) ifTrue:[ |
2563 | 1192 |
self stopBusyIndicationProcess. |
1935
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1193 |
]. |
574 | 1194 |
! ! |
1195 |
||
1196 |
!ProgressIndicator methodsFor:'private'! |
|
1197 |
||
1198 |
connectToTop:top label:label |
|
1199 |
connectedTop := top. |
|
1200 |
connectedLabel := label |
|
1168
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 |
startBusyIndicationProcess |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1204 |
busyIndicationProcess isNil ifTrue:[ |
4216 | 1205 |
busyPosition := 0. |
1206 |
busyDelta := 3. |
|
1207 |
busyIndicationProcess := [ |
|
1208 |
[self realized] whileTrue:[ |
|
1209 |
Delay waitForSeconds:0.1. |
|
1210 |
self shown ifTrue:[ |
|
1211 |
self updateBusyIndicatorPosition. |
|
1212 |
] |
|
1213 |
]. |
|
1214 |
busyIndicationProcess := nil. |
|
1215 |
] fork. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1216 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1217 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1218 |
"Created: / 21.10.1998 / 18:02:35 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1219 |
"Modified: / 21.10.1998 / 18:03:49 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1220 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1221 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1222 |
stopBusyIndicationProcess |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1223 |
busyIndicationProcess notNil ifTrue:[ |
2563 | 1224 |
busyIndicationProcess terminate. |
1225 |
busyIndicationProcess := nil |
|
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 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1228 |
"Created: / 21.10.1998 / 17:30:19 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1229 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1230 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1231 |
updateBusyIndicatorPosition |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1232 |
busyPosition := busyPosition + busyDelta. |
4216 | 1233 |
busyPosition >= 95 ifTrue:[ |
1234 |
busyPosition := -15. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1235 |
]. |
4216 | 1236 |
"/ busyPosition >= 80 ifTrue:[ |
1237 |
"/ busyDelta > 0 ifTrue:[ |
|
1238 |
"/ busyDelta := busyDelta negated. |
|
1239 |
"/ ] |
|
1240 |
"/ ] ifFalse:[ |
|
1241 |
"/ busyPosition <= 0 ifTrue:[ |
|
1242 |
"/ busyDelta < 0 ifTrue:[ |
|
1243 |
"/ busyDelta := busyDelta negated. |
|
1244 |
"/ ] |
|
1245 |
"/ ] |
|
1246 |
"/ ]. |
|
1247 |
self invalidateRepairNow:true |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1248 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1249 |
"Created: / 21.10.1998 / 17:33:28 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1250 |
"Modified: / 21.10.1998 / 17:58:58 / cg" |
183 | 1251 |
! ! |
1252 |
||
1253 |
!ProgressIndicator methodsFor:'queries'! |
|
1254 |
||
1255 |
preferredExtent |
|
574 | 1256 |
"return my preferred extent" |
1257 |
||
3581
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1258 |
"/ If I have an explicit preferredExtent.. |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1259 |
explicitExtent notNil ifTrue:[ |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1260 |
^ explicitExtent |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1261 |
]. |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1262 |
|
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1263 |
"/ If I have a cached preferredExtent value.. |
334 | 1264 |
preferredExtent notNil ifTrue:[ |
3581
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1265 |
^ preferredExtent |
334 | 1266 |
]. |
4511 | 1267 |
^ 100 @ (gc font height + gc font descent + ((margin + 1) * 2)) |
334 | 1268 |
|
574 | 1269 |
"Modified: 22.10.1997 / 21:07:17 / cg" |
183 | 1270 |
! ! |
1271 |
||
62 | 1272 |
!ProgressIndicator methodsFor:'showing progress'! |
1273 |
||
4079 | 1274 |
new_showBusyIndicatorDuring:aBlock |
1275 |
"show progress, while evaluating aBlock. |
|
1276 |
If the receiver has been created with inBox, show the |
|
1277 |
box centered on the screen. If not, the view is assumed to |
|
1278 |
be contained in another view, and no special startup actions |
|
1279 |
are performed. |
|
1280 |
||
1281 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1282 |
||
1283 |
|labelValue p| |
|
1284 |
||
1285 |
connectedLabel notNil ifTrue:[ |
|
1286 |
labelValue := (connectedLabel label ? '') asValue. |
|
1287 |
connectedLabel |
|
1288 |
model:labelValue; |
|
1289 |
aspect:#value; |
|
1290 |
labelMessage:#value. |
|
1291 |
] ifFalse:[ |
|
1292 |
labelValue := '' asValue. |
|
1293 |
]. |
|
1294 |
||
1295 |
"/ the display process |
|
1296 |
p := [ |
|
1297 |
self topView show. |
|
1298 |
] fork. |
|
1299 |
||
1300 |
"/ the worker process |
|
1301 |
||
1302 |
[ |
|
4088 | 1303 |
aBlock valueWithOptionalArgument:labelValue |
4079 | 1304 |
] ensure:[ |
1305 |
p terminate. |
|
1306 |
p := nil. |
|
1307 |
self stopBusyIndicationProcess. |
|
1308 |
closeTopWhenDone ifTrue:[ |
|
1309 |
connectedTop sensor pushEvent:(WindowEvent terminateView:connectedTop). |
|
1310 |
connectedTop hide |
|
1311 |
]. |
|
1312 |
self topView hide. |
|
1313 |
finishAction value |
|
1314 |
]. |
|
1315 |
||
1316 |
" |
|
1317 |
|p| |
|
1318 |
||
1319 |
p := ProgressIndicator inBox. |
|
1320 |
p showBusyIndication:true. |
|
1321 |
p showProgressOf: |
|
1322 |
[:progressValue :currentAction | |
|
1323 |
1 to:200 do:[:percent | |
|
1324 |
(Delay forSeconds:0.05) wait. |
|
1325 |
progressValue value:percent |
|
1326 |
]. |
|
1327 |
]. |
|
1328 |
||
1329 |
'it can be reused ...'. |
|
1330 |
p showBusyIndication:false. |
|
1331 |
p showProgressOf: |
|
1332 |
[:progressValue :currentAction | |
|
1333 |
1 to:100 by:5 do:[:percent | |
|
1334 |
(Delay forSeconds:0.05) wait. |
|
1335 |
progressValue value:percent |
|
1336 |
]. |
|
1337 |
]. |
|
1338 |
||
1339 |
" |
|
1340 |
||
1341 |
"Created: / 14-09-2011 / 18:41:44 / cg" |
|
1342 |
! |
|
1343 |
||
4078 | 1344 |
new_showProgressOf:aBlock |
1345 |
"show progress, while evaluating aBlock. |
|
1346 |
If the receiver has been created with inBox, show the |
|
1347 |
box centered on the screen. If not, the view is assumed to |
|
1348 |
be contained in another view, and no special startup actions |
|
1349 |
are performed. |
|
1350 |
||
1351 |
The block is passed two arguments, the progressValue, |
|
1352 |
which should be set to the percentage from time-to-time |
|
1353 |
within the block and an action value, which should be set to |
|
1354 |
the currently performed action (a string) from time to time. |
|
1355 |
The second valueHolder can be left unchanged. |
|
1356 |
||
1357 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1358 |
||
1359 |
|progressValue labelValue p aborted| |
|
1360 |
||
1361 |
progressValue := 0 asValue. |
|
1362 |
aborted := false. |
|
1363 |
||
1364 |
connectedLabel notNil ifTrue:[ |
|
1365 |
labelValue := (connectedLabel label ? '') asValue. |
|
1366 |
connectedLabel |
|
1367 |
model:labelValue; |
|
1368 |
aspect:#value; |
|
1369 |
labelMessage:#value. |
|
1370 |
] ifFalse:[ |
|
1371 |
labelValue := '' asValue. |
|
1372 |
]. |
|
1373 |
||
1374 |
self model:progressValue. |
|
1375 |
||
1376 |
"/ the display process |
|
1377 |
p := [ |
|
1378 |
self topView show. |
|
1379 |
] fork. |
|
1380 |
||
1381 |
"/ WindowGroup windowGroupQuerySignal handle:[:ex | |
|
1382 |
"/ ex proceedWith:self topView windowGroup |
|
1383 |
"/ ] do:[ |
|
1384 |
[ |
|
1385 |
aBlock value:progressValue value:labelValue |
|
1386 |
] ensure:[ |
|
1387 |
p terminate. |
|
1388 |
p := nil. |
|
1389 |
closeTopWhenDone ifTrue:[ |
|
1390 |
connectedTop sensor pushEvent:(WindowEvent terminateView:connectedTop). |
|
1391 |
connectedTop hide |
|
1392 |
]. |
|
1393 |
self topView hide. |
|
1394 |
finishAction value |
|
1395 |
]. |
|
1396 |
"/ ]. |
|
1397 |
||
1398 |
" |
|
1399 |
|p| |
|
1400 |
||
1401 |
p := ProgressIndicator inBox. |
|
1402 |
p showBusyIndication:true. |
|
1403 |
p showProgressOf: |
|
1404 |
[:progressValue :currentAction | |
|
1405 |
1 to:200 do:[:percent | |
|
1406 |
(Delay forSeconds:0.05) wait. |
|
1407 |
progressValue value:percent |
|
1408 |
]. |
|
1409 |
]. |
|
1410 |
||
1411 |
'it can be reused ...'. |
|
1412 |
p showBusyIndication:false. |
|
1413 |
p showProgressOf: |
|
1414 |
[:progressValue :currentAction | |
|
1415 |
1 to:100 by:5 do:[:percent | |
|
1416 |
(Delay forSeconds:0.05) wait. |
|
1417 |
progressValue value:percent |
|
1418 |
]. |
|
1419 |
]. |
|
1420 |
||
1421 |
" |
|
1422 |
||
1423 |
"Created: / 14-09-2011 / 11:02:21 / cg" |
|
1424 |
! |
|
1425 |
||
4079 | 1426 |
old_showBusyIndicatorDuring:aBlock |
1427 |
"show progress, while evaluating aBlock. |
|
1428 |
If the receiver has been created with inBox, show the |
|
1429 |
box centered on the screen. If not, the view is assumed to |
|
1430 |
be contained in another view, and no special startup actions |
|
1431 |
are performed. |
|
1432 |
||
1433 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1434 |
||
1435 |
|labelValue p| |
|
1436 |
||
1437 |
connectedLabel notNil ifTrue:[ |
|
1438 |
labelValue := (connectedLabel label ? '') asValue. |
|
1439 |
connectedLabel |
|
1440 |
model:labelValue; |
|
1441 |
aspect:#value; |
|
1442 |
labelMessage:#value. |
|
1443 |
] ifFalse:[ |
|
1444 |
labelValue := '' asValue. |
|
1445 |
]. |
|
1446 |
||
1447 |
||
1448 |
"/ the worker process |
|
1449 |
||
1450 |
p := [ |
|
1451 |
[ |
|
1452 |
WindowGroup windowGroupQuerySignal handle:[:ex | |
|
1453 |
ex proceedWith:self topView windowGroup |
|
1454 |
] do:[ |
|
4088 | 1455 |
aBlock valueWithOptionalArgument:labelValue |
4079 | 1456 |
] |
1457 |
] ensure:[ |
|
1458 |
p := nil. |
|
1459 |
self stopBusyIndicationProcess. |
|
1460 |
closeTopWhenDone ifTrue:[ |
|
1461 |
connectedTop hide |
|
1462 |
]. |
|
1463 |
finishAction value. |
|
1464 |
||
1465 |
] |
|
1466 |
] newProcess. |
|
1467 |
||
1468 |
Processor activeProcess |
|
1469 |
withHigherPriorityDo: |
|
1470 |
[ |
|
1471 |
p resume. |
|
1472 |
self topView show. |
|
1473 |
]. |
|
1474 |
p notNil ifTrue:[p terminate]. |
|
1475 |
||
1476 |
" |
|
1477 |
|p| |
|
1478 |
||
1479 |
p := ProgressIndicator inBox. |
|
1480 |
p showBusyIndication:true. |
|
1481 |
p showProgressOf: |
|
1482 |
[:progressValue :currentAction | |
|
1483 |
1 to:200 do:[:percent | |
|
1484 |
(Delay forSeconds:0.05) wait. |
|
1485 |
progressValue value:percent |
|
1486 |
]. |
|
1487 |
]. |
|
1488 |
||
1489 |
'it can be reused ...'. |
|
1490 |
p showBusyIndication:false. |
|
1491 |
p showProgressOf: |
|
1492 |
[:progressValue :currentAction | |
|
1493 |
1 to:100 by:5 do:[:percent | |
|
1494 |
(Delay forSeconds:0.05) wait. |
|
1495 |
progressValue value:percent |
|
1496 |
]. |
|
1497 |
]. |
|
1498 |
||
1499 |
" |
|
1500 |
||
1501 |
"Created: / 14-09-2011 / 18:41:34 / cg" |
|
1502 |
! |
|
1503 |
||
4078 | 1504 |
old_showProgressOf:aBlock |
1505 |
"show progress, while evaluating aBlock. |
|
1506 |
If the receiver has been created with inBox, show the |
|
1507 |
box centered on the screen. If not, the view is assumed to |
|
1508 |
be contained in another view, and no special startup actions |
|
1509 |
are performed. |
|
1510 |
||
1511 |
The block is passed two arguments, the progressValue, |
|
1512 |
which should be set to the percentage from time-to-time |
|
1513 |
within the block and an action value, which should be set to |
|
1514 |
the currently performed action (a string) from time to time. |
|
1515 |
The second valueHolder can be left unchanged. |
|
1516 |
||
1517 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1518 |
||
1519 |
|progressValue labelValue p aborted| |
|
1520 |
||
1521 |
progressValue := 0 asValue. |
|
1522 |
aborted := false. |
|
1523 |
||
1524 |
connectedLabel notNil ifTrue:[ |
|
1525 |
labelValue := (connectedLabel label ? '') asValue. |
|
1526 |
connectedLabel |
|
1527 |
model:labelValue; |
|
1528 |
aspect:#value; |
|
1529 |
labelMessage:#value. |
|
1530 |
] ifFalse:[ |
|
1531 |
labelValue := '' asValue. |
|
1532 |
]. |
|
1533 |
||
1534 |
self model:progressValue. |
|
1535 |
||
1536 |
"/ the worker process |
|
1537 |
||
1538 |
p := [ |
|
1539 |
[ |
|
1540 |
WindowGroup windowGroupQuerySignal handle:[:ex | |
|
1541 |
ex proceedWith:self topView windowGroup |
|
1542 |
] do:[ |
|
4469
a4d672240503
AbortSignal -> AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
4261
diff
changeset
|
1543 |
AbortOperationRequest handle:[:ex | |
4078 | 1544 |
aborted := true |
1545 |
] do:[ |
|
1546 |
aBlock value:progressValue value:labelValue |
|
1547 |
] |
|
1548 |
] |
|
1549 |
] ensure:[ |
|
1550 |
p := nil. |
|
1551 |
closeTopWhenDone ifTrue:[ |
|
1552 |
connectedTop sensor pushEvent:(WindowEvent terminateView:connectedTop). |
|
1553 |
connectedTop hide |
|
1554 |
]. |
|
1555 |
finishAction value |
|
1556 |
] |
|
1557 |
] newProcess. |
|
1558 |
||
1559 |
Processor activeProcess |
|
1560 |
withHigherPriorityDo:[ |
|
1561 |
p resume. |
|
1562 |
self topView show. |
|
1563 |
]. |
|
1564 |
p notNil ifTrue:[p terminate]. |
|
1565 |
aborted ifTrue:[ |
|
4469
a4d672240503
AbortSignal -> AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
4261
diff
changeset
|
1566 |
AbortOperationRequest raiseRequest |
4078 | 1567 |
]. |
1568 |
||
1569 |
" |
|
1570 |
|p| |
|
1571 |
||
1572 |
p := ProgressIndicator inBox. |
|
1573 |
p showBusyIndication:true. |
|
1574 |
p showProgressOf: |
|
1575 |
[:progressValue :currentAction | |
|
1576 |
1 to:200 do:[:percent | |
|
1577 |
(Delay forSeconds:0.05) wait. |
|
1578 |
progressValue value:percent |
|
1579 |
]. |
|
1580 |
]. |
|
1581 |
||
1582 |
'it can be reused ...'. |
|
1583 |
p showBusyIndication:false. |
|
1584 |
p showProgressOf: |
|
1585 |
[:progressValue :currentAction | |
|
1586 |
1 to:100 by:5 do:[:percent | |
|
1587 |
(Delay forSeconds:0.05) wait. |
|
1588 |
progressValue value:percent |
|
1589 |
]. |
|
1590 |
]. |
|
1591 |
||
1592 |
" |
|
1593 |
||
1594 |
"Modified: / 12-09-2011 / 09:57:03 / cg" |
|
1595 |
"Created: / 14-09-2011 / 11:00:12 / cg" |
|
1596 |
! |
|
1597 |
||
2850 | 1598 |
showBusyIndicatorDuring:aBlock |
1599 |
"show progress, while evaluating aBlock. |
|
1600 |
If the receiver has been created with inBox, show the |
|
1601 |
box centered on the screen. If not, the view is assumed to |
|
1602 |
be contained in another view, and no special startup actions |
|
1603 |
are performed. |
|
1604 |
||
1605 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1606 |
||
1607 |
|labelValue p| |
|
1608 |
||
1609 |
connectedLabel notNil ifTrue:[ |
|
1610 |
labelValue := (connectedLabel label ? '') asValue. |
|
1611 |
connectedLabel |
|
1612 |
model:labelValue; |
|
1613 |
aspect:#value; |
|
1614 |
labelMessage:#value. |
|
1615 |
] ifFalse:[ |
|
1616 |
labelValue := '' asValue. |
|
1617 |
]. |
|
1618 |
||
1619 |
||
1620 |
"/ the worker process |
|
1621 |
||
4096
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1622 |
p := |
2850 | 1623 |
[ |
4096
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1624 |
[ |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1625 |
WindowGroup windowGroupQuerySignal handle:[:ex | |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1626 |
ex proceedWith:self topView windowGroup |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1627 |
] do:[ |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1628 |
aBlock valueWithOptionalArgument:labelValue |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1629 |
] |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1630 |
] ensure:[ |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1631 |
p := nil. |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1632 |
self stopBusyIndicationProcess. |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1633 |
closeTopWhenDone ifTrue:[ |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1634 |
connectedTop hide |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1635 |
]. |
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1636 |
finishAction value. |
2850 | 1637 |
] |
4096
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1638 |
] newProcess. |
2850 | 1639 |
|
1640 |
Processor activeProcess |
|
2878 | 1641 |
withHigherPriorityDo: |
1642 |
[ |
|
1643 |
p resume. |
|
1644 |
self topView show. |
|
1645 |
]. |
|
2850 | 1646 |
p notNil ifTrue:[p terminate]. |
1647 |
||
1648 |
" |
|
1649 |
|p| |
|
1650 |
||
1651 |
p := ProgressIndicator inBox. |
|
1652 |
p showBusyIndication:true. |
|
1653 |
p showProgressOf: |
|
1654 |
[:progressValue :currentAction | |
|
1655 |
1 to:200 do:[:percent | |
|
1656 |
(Delay forSeconds:0.05) wait. |
|
1657 |
progressValue value:percent |
|
1658 |
]. |
|
1659 |
]. |
|
1660 |
||
1661 |
'it can be reused ...'. |
|
1662 |
p showBusyIndication:false. |
|
1663 |
p showProgressOf: |
|
1664 |
[:progressValue :currentAction | |
|
1665 |
1 to:100 by:5 do:[:percent | |
|
1666 |
(Delay forSeconds:0.05) wait. |
|
1667 |
progressValue value:percent |
|
1668 |
]. |
|
1669 |
]. |
|
1670 |
||
1671 |
" |
|
1672 |
||
4088 | 1673 |
"Modified: / 07-11-2011 / 21:53:46 / cg" |
4096
da15cc568c0a
comment/format in: #showBusyIndicatorDuring:
Claus Gittinger <cg@exept.de>
parents:
4088
diff
changeset
|
1674 |
"Modified (format): / 08-01-2012 / 12:00:39 / cg" |
2850 | 1675 |
! |
1676 |
||
62 | 1677 |
showProgressOf:aBlock |
1678 |
"show progress, while evaluating aBlock. |
|
1679 |
If the receiver has been created with inBox, show the |
|
1680 |
box centered on the screen. If not, the view is assumed to |
|
1681 |
be contained in another view, and no special startup actions |
|
1682 |
are performed. |
|
1683 |
||
1684 |
The block is passed two arguments, the progressValue, |
|
1685 |
which should be set to the percentage from time-to-time |
|
1686 |
within the block and an action value, which should be set to |
|
1687 |
the currently performed action (a string) from time to time. |
|
1688 |
The second valueHolder can be left unchanged. |
|
1689 |
||
1690 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1691 |
||
4078 | 1692 |
"/ ^ self old_showProgressOf:aBlock |
1693 |
^ self new_showProgressOf:aBlock |
|
62 | 1694 |
|
1695 |
" |
|
1696 |
|p| |
|
1697 |
||
1698 |
p := ProgressIndicator inBox. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1699 |
p showBusyIndication:true. |
62 | 1700 |
p showProgressOf: |
2837 | 1701 |
[:progressValue :currentAction | |
1702 |
1 to:200 do:[:percent | |
|
1703 |
(Delay forSeconds:0.05) wait. |
|
1704 |
progressValue value:percent |
|
1705 |
]. |
|
1706 |
]. |
|
62 | 1707 |
|
1708 |
'it can be reused ...'. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1709 |
p showBusyIndication:false. |
62 | 1710 |
p showProgressOf: |
2837 | 1711 |
[:progressValue :currentAction | |
1712 |
1 to:100 by:5 do:[:percent | |
|
1713 |
(Delay forSeconds:0.05) wait. |
|
1714 |
progressValue value:percent |
|
1715 |
]. |
|
1716 |
]. |
|
62 | 1717 |
|
1718 |
" |
|
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
1719 |
|
4078 | 1720 |
"Modified: / 14-09-2011 / 17:03:08 / cg" |
62 | 1721 |
! ! |
1722 |
||
334 | 1723 |
!ProgressIndicator class methodsFor:'documentation'! |
50 | 1724 |
|
183 | 1725 |
version |
4511 | 1726 |
^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.77 2014-02-18 15:06:59 stefan Exp $' |
3827
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
1727 |
! |
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
1728 |
|
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
1729 |
version_CVS |
4511 | 1730 |
^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.77 2014-02-18 15:06:59 stefan Exp $' |
50 | 1731 |
! ! |
4216 | 1732 |