UserConfirmation.st
author Stefan Vogel <sv@exept.de>
Wed, 02 May 2007 12:52:12 +0200
changeset 10536 d1da7d71bcf5
parent 10518 f2717d1ae95d
child 10845 948ce25c5209
permissions -rw-r--r--
Put additionalDefinitions before localIncludes

"{ Package: 'stx:libbasic' }"

UserNotification subclass:#UserConfirmation
	instanceVariableNames:'canCancel'
	classVariableNames:''
	poolDictionaries:''
	category:'Kernel-Exceptions'
!


!UserConfirmation methodsFor:'accessing'!

aspect
    "the aspect the user is asked. Set this to a symbol. 
     It can be used by a exception handler"

    ^ parameter
!

aspect:aSymbol
    "the aspect the user is asked. Set this to a symbol. 
     It can be used by a exception handler"

    parameter := aSymbol
!

canCancel
    "answer true, if the user is allowed to press the cancel button
     in a confirmation dialog"

    ^ canCancel ? false
!

canCancel:something
    canCancel := something.
! !

!UserConfirmation methodsFor:'default actions'!

defaultAction
    "Default action for confirmations: open a info box with description.
     If no GUI present, assume that the user pressed 'yes'"

    |text|

    text := self description.

    self hasDialog ifTrue:[
        self canCancel ifTrue:[
            ^ Dialog confirmWithCancel:text
        ] ifFalse:[
            ^ Dialog confirm:text
        ].
    ].

    "
     on systems without GUI, simply show
     the message on the Transcript and assume, that he would have typed 'yes'.
    "
    self canCancel ifTrue:[    
        Transcript show:'User confirmation requested (assuming cancel): '; showCR:text.
        ^ nil
    ] ifFalse:[
        Transcript show:'User confirmation requested (assuming yes): '; showCR:text.
        ^ true
    ].


    "
      UserConfirmation raiseRequestErrorString:'Please click yes or no!!'
    "
! !

!UserConfirmation class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libbasic/UserConfirmation.st,v 1.1 2007-04-16 13:44:06 stefan Exp $'
! !