User's Guide

Adding the scripts

The RoadRaceView part needs scripts to create and add a runner and to refresh the list of runners. You can do this as follows:

  1. Select Script Editor symbol to switch to the Script Editor view of your visual part.
  2. Create and save the following instance method:
    recordPBClicked
       "When RecordPB is clicked, create and add a runner
        and refresh the list"
       (self subpartNamed: 'Runner Factory') createInstance.
       (self subpartNamed: 'Runners Collection') abtPerformAction: #add:
          with: (self subpartNamed: 'Runner Factory') instance.
       self refreshRunnersList.
    
  3. Create and ave the following instance method:
    refreshRunnersList
       "Refresh the visual list of runners every time a runner
        is added to the Runners Collection"
       | runners sortedRunners |
       runners := (self subpartNamed: 'Runners Collection')
          abtAtAttribute: #self.
       "The sortBlock orders the runners by their finishTime"
       sortedRunners := SortedCollection
          sortBlock: [:runner1 :runner2 |
             runner1 finishTime < runner2 finishTime].
       runners do: [:runner | sortedRunners add: runner].
       (self subpartNamed: 'Result List') items: sortedRunners asOrderedCollection.
    


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]