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