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