ProgressIndicator.st
changeset 4078 91d764cf9cbd
parent 4077 221b121afa23
child 4079 29b468da8728
equal deleted inserted replaced
4077:221b121afa23 4078:91d764cf9cbd
  1218     "Modified: 22.10.1997 / 21:07:17 / cg"
  1218     "Modified: 22.10.1997 / 21:07:17 / cg"
  1219 ! !
  1219 ! !
  1220 
  1220 
  1221 !ProgressIndicator methodsFor:'showing progress'!
  1221 !ProgressIndicator methodsFor:'showing progress'!
  1222 
  1222 
  1223 showBusyIndicatorDuring:aBlock
  1223 new_showProgressOf:aBlock
  1224     "show progress, while evaluating aBlock.
  1224     "show progress, while evaluating aBlock.
  1225      If the receiver has been created with inBox, show the
  1225      If the receiver has been created with inBox, show the
  1226      box centered on the screen. If not, the view is assumed to
  1226      box centered on the screen. If not, the view is assumed to
  1227      be contained in another view, and no special startup actions
  1227      be contained in another view, and no special startup actions
  1228      are performed.
  1228      are performed.
  1229 
  1229 
       
  1230      The block is passed two arguments, the progressValue,
       
  1231      which should be set to the percentage from time-to-time
       
  1232      within the block and an action value, which should be set to
       
  1233      the currently performed action (a string) from time to time.
       
  1234      The second valueHolder can be left unchanged.
       
  1235 
  1230      Caveat: cannot (currently) suppress close of the box ..."
  1236      Caveat: cannot (currently) suppress close of the box ..."
  1231 
  1237 
  1232     |labelValue p|
  1238     |progressValue labelValue p aborted|
       
  1239 
       
  1240     progressValue := 0 asValue.
       
  1241     aborted := false.
  1233 
  1242 
  1234     connectedLabel notNil ifTrue:[
  1243     connectedLabel notNil ifTrue:[
  1235         labelValue := (connectedLabel label ? '') asValue.
  1244         labelValue := (connectedLabel label ? '') asValue.
  1236         connectedLabel 
  1245         connectedLabel 
  1237             model:labelValue;
  1246             model:labelValue;
  1239             labelMessage:#value.
  1248             labelMessage:#value.
  1240     ] ifFalse:[
  1249     ] ifFalse:[
  1241         labelValue := '' asValue.
  1250         labelValue := '' asValue.
  1242     ].
  1251     ].
  1243 
  1252 
  1244 
  1253     self model:progressValue.
  1245     "/ the worker process
  1254 
  1246 
  1255     "/ the display process
  1247     p := [
  1256     p := [
       
  1257             self topView show.
       
  1258          ] fork.
       
  1259 
       
  1260 "/    WindowGroup windowGroupQuerySignal handle:[:ex |
       
  1261 "/        ex proceedWith:self topView windowGroup
       
  1262 "/    ] do:[
  1248         [
  1263         [
  1249             WindowGroup windowGroupQuerySignal handle:[:ex |
  1264             aBlock value:progressValue value:labelValue
  1250                 ex proceedWith:self topView windowGroup
       
  1251             ] do:[
       
  1252                 aBlock value
       
  1253             ]
       
  1254         ] ensure:[
  1265         ] ensure:[
       
  1266             p terminate.
  1255             p := nil.
  1267             p := nil.
  1256             self stopBusyIndicationProcess.
       
  1257             closeTopWhenDone ifTrue:[
  1268             closeTopWhenDone ifTrue:[
       
  1269                 connectedTop sensor pushEvent:(WindowEvent terminateView:connectedTop).
  1258                 connectedTop hide
  1270                 connectedTop hide
  1259             ].
  1271             ].
  1260             finishAction value.
  1272             self topView hide.
  1261             
  1273             finishAction value
  1262         ]
  1274         ].
  1263     ] newProcess.
  1275 "/    ].
  1264 
       
  1265     Processor activeProcess 
       
  1266         withHigherPriorityDo:
       
  1267             [
       
  1268                 p resume.
       
  1269                 self topView show.
       
  1270             ].
       
  1271     p notNil ifTrue:[p terminate].
       
  1272 
  1276 
  1273     "
  1277     "
  1274       |p|
  1278       |p|
  1275 
  1279 
  1276       p := ProgressIndicator inBox.
  1280       p := ProgressIndicator inBox.
  1293                 ].
  1297                 ].
  1294             ].
  1298             ].
  1295 
  1299 
  1296     "
  1300     "
  1297 
  1301 
  1298     "Modified: / 21.10.1998 / 17:37:00 / cg"
  1302     "Created: / 14-09-2011 / 11:02:21 / cg"
  1299 !
  1303 !
  1300 
  1304 
  1301 showProgressOf:aBlock
  1305 old_showProgressOf:aBlock
  1302     "show progress, while evaluating aBlock.
  1306     "show progress, while evaluating aBlock.
  1303      If the receiver has been created with inBox, show the
  1307      If the receiver has been created with inBox, show the
  1304      box centered on the screen. If not, the view is assumed to
  1308      box centered on the screen. If not, the view is assumed to
  1305      be contained in another view, and no special startup actions
  1309      be contained in another view, and no special startup actions
  1306      are performed.
  1310      are performed.
  1387             ].
  1391             ].
  1388 
  1392 
  1389     "
  1393     "
  1390 
  1394 
  1391     "Modified: / 12-09-2011 / 09:57:03 / cg"
  1395     "Modified: / 12-09-2011 / 09:57:03 / cg"
       
  1396     "Created: / 14-09-2011 / 11:00:12 / cg"
       
  1397 !
       
  1398 
       
  1399 showBusyIndicatorDuring:aBlock
       
  1400     "show progress, while evaluating aBlock.
       
  1401      If the receiver has been created with inBox, show the
       
  1402      box centered on the screen. If not, the view is assumed to
       
  1403      be contained in another view, and no special startup actions
       
  1404      are performed.
       
  1405 
       
  1406      Caveat: cannot (currently) suppress close of the box ..."
       
  1407 
       
  1408     |labelValue p|
       
  1409 
       
  1410     connectedLabel notNil ifTrue:[
       
  1411         labelValue := (connectedLabel label ? '') asValue.
       
  1412         connectedLabel 
       
  1413             model:labelValue;
       
  1414             aspect:#value;
       
  1415             labelMessage:#value.
       
  1416     ] ifFalse:[
       
  1417         labelValue := '' asValue.
       
  1418     ].
       
  1419 
       
  1420 
       
  1421     "/ the worker process
       
  1422 
       
  1423     p := [
       
  1424         [
       
  1425             WindowGroup windowGroupQuerySignal handle:[:ex |
       
  1426                 ex proceedWith:self topView windowGroup
       
  1427             ] do:[
       
  1428                 aBlock value
       
  1429             ]
       
  1430         ] ensure:[
       
  1431             p := nil.
       
  1432             self stopBusyIndicationProcess.
       
  1433             closeTopWhenDone ifTrue:[
       
  1434                 connectedTop hide
       
  1435             ].
       
  1436             finishAction value.
       
  1437             
       
  1438         ]
       
  1439     ] newProcess.
       
  1440 
       
  1441     Processor activeProcess 
       
  1442         withHigherPriorityDo:
       
  1443             [
       
  1444                 p resume.
       
  1445                 self topView show.
       
  1446             ].
       
  1447     p notNil ifTrue:[p terminate].
       
  1448 
       
  1449     "
       
  1450       |p|
       
  1451 
       
  1452       p := ProgressIndicator inBox.
       
  1453       p showBusyIndication:true.
       
  1454       p showProgressOf:
       
  1455             [:progressValue :currentAction |
       
  1456                 1 to:200 do:[:percent |
       
  1457                     (Delay forSeconds:0.05) wait.
       
  1458                     progressValue value:percent 
       
  1459                 ].
       
  1460             ].
       
  1461 
       
  1462       'it can be reused ...'.  
       
  1463       p showBusyIndication:false.
       
  1464       p showProgressOf:
       
  1465             [:progressValue :currentAction |
       
  1466                 1 to:100 by:5 do:[:percent |
       
  1467                     (Delay forSeconds:0.05) wait.
       
  1468                     progressValue value:percent 
       
  1469                 ].
       
  1470             ].
       
  1471 
       
  1472     "
       
  1473 
       
  1474     "Modified: / 21.10.1998 / 17:37:00 / cg"
       
  1475 !
       
  1476 
       
  1477 showProgressOf:aBlock
       
  1478     "show progress, while evaluating aBlock.
       
  1479      If the receiver has been created with inBox, show the
       
  1480      box centered on the screen. If not, the view is assumed to
       
  1481      be contained in another view, and no special startup actions
       
  1482      are performed.
       
  1483 
       
  1484      The block is passed two arguments, the progressValue,
       
  1485      which should be set to the percentage from time-to-time
       
  1486      within the block and an action value, which should be set to
       
  1487      the currently performed action (a string) from time to time.
       
  1488      The second valueHolder can be left unchanged.
       
  1489 
       
  1490      Caveat: cannot (currently) suppress close of the box ..."
       
  1491 
       
  1492     "/ ^ self old_showProgressOf:aBlock
       
  1493     ^ self new_showProgressOf:aBlock
       
  1494 
       
  1495     "
       
  1496       |p|
       
  1497 
       
  1498       p := ProgressIndicator inBox.
       
  1499       p showBusyIndication:true.
       
  1500       p showProgressOf:
       
  1501             [:progressValue :currentAction |
       
  1502                 1 to:200 do:[:percent |
       
  1503                     (Delay forSeconds:0.05) wait.
       
  1504                     progressValue value:percent 
       
  1505                 ].
       
  1506             ].
       
  1507 
       
  1508       'it can be reused ...'.  
       
  1509       p showBusyIndication:false.
       
  1510       p showProgressOf:
       
  1511             [:progressValue :currentAction |
       
  1512                 1 to:100 by:5 do:[:percent |
       
  1513                     (Delay forSeconds:0.05) wait.
       
  1514                     progressValue value:percent 
       
  1515                 ].
       
  1516             ].
       
  1517 
       
  1518     "
       
  1519 
       
  1520     "Modified: / 14-09-2011 / 17:03:08 / cg"
  1392 ! !
  1521 ! !
  1393 
  1522 
  1394 !ProgressIndicator class methodsFor:'documentation'!
  1523 !ProgressIndicator class methodsFor:'documentation'!
  1395 
  1524 
  1396 version
  1525 version
  1397     ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.66 2011-09-12 08:21:08 cg Exp $'
  1526     ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.67 2011-09-14 16:41:21 cg Exp $'
  1398 !
  1527 !
  1399 
  1528 
  1400 version_CVS
  1529 version_CVS
  1401     ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.66 2011-09-12 08:21:08 cg Exp $'
  1530     ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.67 2011-09-14 16:41:21 cg Exp $'
  1402 ! !
  1531 ! !