--- a/WorkspaceApplication.st Mon Oct 27 11:26:51 2008 +0100
+++ b/WorkspaceApplication.st Wed Oct 29 13:06:17 2008 +0100
@@ -1554,19 +1554,32 @@
!
addTeaTimer
- |l dt tEnd answer|
+ |l dt tEnd dur answer|
dt := LastTeaWaitTime ? (3*60).
answer := Dialog
- request:'Delta-Time (seconds) or End-Time (hh:mm:ss):'
- initialAnswer:dt printString.
+ request:'Delta-Time (seconds), Duration (n s/m/h) or End-Time (hh:mm:ss):'
+ initialAnswer:(TimeDuration seconds:dt) printString.
answer isEmptyOrNil ifTrue:[^ self].
+ "/ allow 3 formats:
+ "/ hh:mm:ss -> endTime
+ "/ nnn s -> x seconds
+ "/ nnn m -> x minutes
+ "/ nnn h -> x hours
+ "/ nnn -> seconds
+
tEnd := Time readFrom:answer onError:nil.
tEnd isNil ifTrue:[
- dt := Number readFrom:answer onError:[^ self].
- LastTeaWaitTime := dt.
- tEnd := AbsoluteTime now addSeconds:dt.
+ dur := TimeDuration readFrom:answer onError:nil.
+ dur isNil ifTrue:[
+ dt := Number readFrom:answer onError:[^ self].
+ LastTeaWaitTime := dt.
+ tEnd := AbsoluteTime now addSeconds:dt.
+ ] ifFalse:[
+ dt := dur asSeconds.
+ tEnd := AbsoluteTime now + dur.
+ ].
] ifFalse:[
dt := tEnd - Time now.
tEnd := tEnd asAbsoluteTime.
@@ -1574,7 +1587,7 @@
l := Label new.
l sizeFixed:true.
- l label:'Waiting ... [',dt printString,' sec]'.
+ l label:'Waiting... [',(TimeDuration seconds:dt) printString,']'.
l viewBackground:Color red.
self addWindow:l named:'TeaTimer%1'.
@@ -1586,7 +1599,7 @@
[AbsoluteTime now < tEnd ] whileTrue:[
remaining := tEnd - AbsoluteTime now.
- l label:'Waiting ... [',remaining printString,' sec]'.
+ l label:'Waiting... [',(TimeDuration seconds:remaining) printString,']'.
Delay waitForSeconds:1.
].
3 timesRepeat:[ l beep. Delay waitForSeconds:0.4 ].
@@ -2383,5 +2396,5 @@
!WorkspaceApplication class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/WorkspaceApplication.st,v 1.164 2008-10-21 23:08:39 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/WorkspaceApplication.st,v 1.165 2008-10-29 12:06:17 cg Exp $'
! !