Copying methods into TimeLogger
Six of the methods are identical to those implemented for Stopwatch and TextEditor. To save time, you can copy the methods into TimeLogger. This section provides the steps for copying classes to move methods between applications. If you have not yet defined Stopwatch or TextEditor, this section also provides the code for the methods.
You can copy methods between classes contained in one application. Provided the target class is visible, you can also copy methods between classes in different applications; it creates an extension of the target class.
Copying methods from Stopwatch
To copy methods from Stopwatch, you must copy Stopwatch, move the new class to DevelopTimeLogger, and then copy the methods from the new class to TimeLogger. The steps to do this are as follows:
To copy Stopwatch and move the new class to DevelopTimeLogger
1. Open an Application Manager and ensure that the applications DevelopStopwatch and DevelopTimeLogger are open editions (not versions). Also ensure that the classes Stopwatch and TimeLogger are open editions.
2. Select DevelopStopwatch and the class Stopwatch; then select Copy from the Classes menu.
3. In the displayed prompter, type a name for the class, such as Stopwatch2; then select OK.
4. After a second prompter window opens asking if you want to browse methods referencing the class, select No.
5. Select the new class (Stopwatch2); then select Move from the Classes menu. A window opens, listing applications to which you can move the class.
6. Select DevelopTimeLogger; then select OK.
Moving methods from the new class to TimeLogger
1. Return to a development browser open on DevelopTimeLogger and, if necessary, update the list of classes so it shows the new class (Stopwatch2).
2. Display the private instance methods of the new class.
3. While pressing Ctrl, select the methods calculateTime:, startButtonMotion:clientData:callData:, timeElapsedDisplay, and timeElapsedDisplay:.
4. From the Methods menu, select Move > To A New Class. A window opens, prompting you for the name of the target class.
5. Type TimeLogger, then select OK.
Copying methods
6. Select an application, then select OK.
The methods are moved to TimeLogger. timeElapsedDisplay and timeElapsedDisplay: go into the Getters & Setters category; startButtonMotions:clientData:callData: goes into Event Handlers; and calculateTime: goes into Operations. Finally, delete the new class (Stopwatch2).
Copying methods from TextEditor
By following steps similar to those listed above, you can copy from TextEditor the methods fileName and fileName:. Both methods go into the Getters & Setters category.
Code for the private instance methods
Instead of copying methods, you can implement them by adding the following code to the class TimeLogger:
Method fileName
fileName
"Private - Answers the value of fileName."
^ fileName.
Method fileName:
fileName: value
"Private - Sets the value of fileName."
fileName := value.
Method startButtonMotion:clientData:callData:
startButtonMotion: aButton clientData: aRowColumn callData: callData
"Private - The user pressed the Start button. Displays the time elapsed."
startTime := Time now.
self timeElapsedDisplay
setString: ' 00:00:00'. "9 spaces before the time."
Method timeElapsedDisplay
timeElapsedDisplay
"Private - Answers the timeElapsedDisplay for the receiver."
^ timeElapsedDisplay.
Method timeElapsedDisplay:
timeElapsedDisplay: aTextWidget
"Private - Sets the timeElapsedDisplay for the receiver."
timeElapsedDisplay := aTextWidget.
Method calculateTime:
calculateTime: time
"Private - Answers the time elapsed in a format that
displays Hours:Minutes:Seconds."
| answer |
answer := WriteStream on: (String new: 8).
time hours < 10 ifTrue: [answer nextPut: $0].
time hours printOn: answer.
answer nextPut: $:.
time minutes < 10 ifTrue: [answer nextPut: $0].
time minutes printOn: answer.
answer nextPut: $:.
time seconds < 10 ifTrue: answer nextPut: $0].
time seconds printOn: answer.
^answer contents.
Opening an instance of TimeLogger
After you implement all of the methods for TimeLogger, try opening an instance of the class using DevelopChooser or by evaluating:
TimeLogger new open.
C:\Users\documentation\Documents\vastePublisher\stable\VAS Documentation Word\images\sg\sutl0.png
Finally, ensure that you create versions of the classes and release them to DevelopTimeLogger. To do this, from an Application Manager, select Version/Release All from the Classes menu.
Also, create a version of each application. (See Example: Creating an application version.) If you want team members to work on the applications, create a new edition of the application versions. (See Example: Creating an application edition.)
Last modified date: 02/26/2019