10518
|
1 |
"{ Package: 'stx:libbasic' }"
|
|
2 |
|
|
3 |
UserNotification subclass:#UserConfirmation
|
|
4 |
instanceVariableNames:'canCancel'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Kernel-Exceptions'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!UserConfirmation methodsFor:'accessing'!
|
|
12 |
|
|
13 |
aspect
|
|
14 |
"the aspect the user is asked. Set this to a symbol.
|
|
15 |
It can be used by a exception handler"
|
|
16 |
|
|
17 |
^ parameter
|
|
18 |
!
|
|
19 |
|
|
20 |
aspect:aSymbol
|
|
21 |
"the aspect the user is asked. Set this to a symbol.
|
|
22 |
It can be used by a exception handler"
|
|
23 |
|
|
24 |
parameter := aSymbol
|
|
25 |
!
|
|
26 |
|
|
27 |
canCancel
|
|
28 |
"answer true, if the user is allowed to press the cancel button
|
|
29 |
in a confirmation dialog"
|
|
30 |
|
|
31 |
^ canCancel ? false
|
|
32 |
!
|
|
33 |
|
|
34 |
canCancel:something
|
|
35 |
canCancel := something.
|
|
36 |
! !
|
|
37 |
|
|
38 |
!UserConfirmation methodsFor:'default actions'!
|
|
39 |
|
|
40 |
defaultAction
|
|
41 |
"Default action for confirmations: open a info box with description.
|
|
42 |
If no GUI present, assume that the user pressed 'yes'"
|
|
43 |
|
|
44 |
|text|
|
|
45 |
|
|
46 |
text := self description.
|
|
47 |
|
|
48 |
self hasDialog ifTrue:[
|
|
49 |
self canCancel ifTrue:[
|
|
50 |
^ Dialog confirmWithCancel:text
|
|
51 |
] ifFalse:[
|
|
52 |
^ Dialog confirm:text
|
|
53 |
].
|
|
54 |
].
|
|
55 |
|
|
56 |
"
|
|
57 |
on systems without GUI, simply show
|
|
58 |
the message on the Transcript and assume, that he would have typed 'yes'.
|
|
59 |
"
|
|
60 |
self canCancel ifTrue:[
|
|
61 |
Transcript show:'User confirmation requested (assuming cancel): '; showCR:text.
|
|
62 |
^ nil
|
|
63 |
] ifFalse:[
|
|
64 |
Transcript show:'User confirmation requested (assuming yes): '; showCR:text.
|
|
65 |
^ true
|
|
66 |
].
|
|
67 |
|
|
68 |
|
|
69 |
"
|
|
70 |
UserConfirmation raiseRequestErrorString:'Please click yes or no!!'
|
|
71 |
"
|
|
72 |
! !
|
|
73 |
|
|
74 |
!UserConfirmation class methodsFor:'documentation'!
|
|
75 |
|
|
76 |
version
|
|
77 |
^ '$Header: /cvs/stx/stx/libbasic/UserConfirmation.st,v 1.1 2007-04-16 13:44:06 stefan Exp $'
|
|
78 |
! !
|