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