The Trunk: Collections-ar.353.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-ar.353.mcz

commits-2
Andreas Raab uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ar.353.mcz

==================== Summary ====================

Name: Collections-ar.353
Author: ar
Time: 31 March 2010, 10:11:07.876 pm
UUID: 4ea0e395-ea15-b348-8053-a7d27929e745
Ancestors: Collections-nice.352

Fix do:displayingProgress: to suppress changing the label to nil if the display block returns nil (accidentally or deliberately).

=============== Diff against Collections-nice.352 ===============

Item was changed:
  ----- Method: Collection>>do:displayingProgress:every: (in category 'enumerating') -----
  do: aBlock displayingProgress: aStringOrBlock every: msecs
  "Enumerate aBlock displaying progress information.
  If the argument is a string, use a static label for the process.
  If the argument is a block, evaluate it with the element to retrieve the label.
  The msecs argument ensures that updates happen at most every msecs.
  Example:
  Smalltalk allClasses
  do:[:aClass| (Delay forMilliseconds: 1) wait]
  displayingProgress:[:aClass| 'Processing ', aClass name]
  every: 0.
  Smalltalk allClasses
  do:[:aClass| (Delay forMilliseconds: 1) wait]
  displayingProgress:[:aClass| 'Processing ', aClass name]
  every: 100.
  "
  | size labelBlock count oldLabel lastUpdate |
  labelBlock := aStringOrBlock isString
  ifTrue:[[:item| aStringOrBlock]]
  ifFalse:[aStringOrBlock].
  oldLabel := nil.
  count := lastUpdate := 0.
  size := self size.
  '' displayProgressAt: Sensor cursorPoint from: 0 to: size during:[:bar |
  self do:[:each| | newLabel |
  "Special handling for first and last element"
  (count = 0 or:[count+1 = size
  or:[(Time millisecondsSince: lastUpdate) >= msecs]]) ifTrue:[
  bar value: count.
+ oldLabel = (newLabel := (labelBlock value: each) ifNil:[oldLabel]) ifFalse:[
- oldLabel = (newLabel := labelBlock value: each) ifFalse:[
  ProgressNotification signal: '' extra: (oldLabel := newLabel).
  ].
  lastUpdate := Time millisecondClockValue.
  ].
  aBlock value: each.
  count := count + 1.
  ]]!