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