UserConfirmation.st
author Claus Gittinger <cg@exept.de>
Wed, 22 Oct 2008 00:20:59 +0200
changeset 11261 e8dcdce0b2ae
parent 11196 3e4114139cc9
child 11364 217571ef0914
permissions -rw-r--r--
changed #classMenuCompareTwoRepositoryVersions

"
 COPYRIGHT (c) 2007 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libbasic' }"

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

!UserConfirmation class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2007 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
! !

!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.3 2008-10-04 08:42:23 cg Exp $'
! !