DialogBox subclass:#LicenceBox
instanceVariableNames:'accepted destroySemaphore'
classVariableNames:'LicenceRejectSignal'
poolDictionaries:''
category:'Views-DialogBoxes'
!
!LicenceBox class methodsFor:'documentation'!
documentation
"
LicenceBox shows a licence text when opened, an returns true,
if the licence has been accepted, false otherwise.
"
!
examples
"
[exBegin]
LicenceRejectSignal handle:[:ex|
Transcript showCR:'Licence rejected'.
] do:[
LicenceBox open.
Transcript showCR:'Licence accepted'.
]
[exEnd]
"
!
history
"Created: 6.9.1996 / 13:29:15 / stefan"
"Modified: 9.9.1996 / 14:53:11 / stefan"
! !
!LicenceBox class methodsFor:'initialization'!
initialize
LicenceRejectSignal isNil ifTrue:[
LicenceRejectSignal := ErrorSignal newSignalMayProceed:true.
LicenceRejectSignal nameClass:self message:#licenceRejectSignal.
LicenceRejectSignal notifierString:'licence rejected by user'.
].
"
self initialize
"
! !
!LicenceBox class methodsFor:'instance creation'!
open
"open myself modal and return true if accepted, false otherwise"
^ super open accepted.
"
self open
"
"Modified: 9.9.1996 / 17:52:48 / stefan"
! !
!LicenceBox class methodsFor:'Signal constants'!
licenceRejectSignal
"licence has been rejected by user"
^ LicenceRejectSignal
! !
!LicenceBox methodsFor:'accessing'!
accepted
"return accepted"
^ accepted
"Created: 6.9.1996 / 13:24:44 / stefan"
!
accepted:something
"set accepted"
accepted := something.
"Created: 6.9.1996 / 13:24:44 / stefan"
! !
!LicenceBox methodsFor:'destroying'!
terminate
"this is the close from a windowmanager
(only if UseTransientViews == true).
Redefined, since ModalBox keeps the View alive (only hidden)"
self destroy.
"Created: 9.9.1996 / 15:15:31 / stefan"
! !
!LicenceBox methodsFor:'initialization'!
initialize
|textView|
super initialize.
accepted := false.
(self addTextLabel:(resources string:'Please read the licence terms:')) adjust:#left.
textView := self addTextBoxOn:nil
class:HTMLDocumentView
withNumberOfLines:40
hScrollable:true
vScrollable:true.
self width:(textView preferredExtentForLines:40 cols:70) x.
textView setText:(self licenceText).
self addAbortButtonLabelled:(resources string:'reject licence terms').
self addOkButtonLabelled:(resources string:'accept licence terms').
self abortAction:[self destroy. accepted := false. LicenceRejectSignal raise].
self okAction:[self destroy. accepted := true].
self stickAtBottomWithVariableHeight:textView.
"Modified: 9.9.1996 / 17:52:13 / stefan"
! !
!LicenceBox methodsFor:'private'!
licenceText
"get licence text"
|file|
file := (resources at:'LICENCEFILE') asFilename.
file exists ifFalse:[
file := Smalltalk getSystemFileName:'doc/online/german/LICENCE.STX.html'.
file isNil ifTrue:[
file := '../../doc/online/german/LICENCE.STX.html'.
].
file notNil ifTrue:[
file := file asFilename
].
(file isNil or:[file exists not]) ifTrue:[
^ 'oops - you are not allowed to remove the LICENSE file !!'
].
].
^ file readStream contents.
"Created: 6.9.1996 / 12:17:07 / stefan"
"Modified: 10.9.1996 / 02:16:28 / cg"
! !
!LicenceBox class methodsFor:'documentation'!
alize! !
LicenceBox initialize!