LicenceBox.st
author Claus Gittinger <cg@exept.de>
Tue, 10 Sep 1996 14:54:57 +0200
changeset 244 646c3da97dd0
parent 243 82637ad60d26
child 245 7b986d50e79d
permissions -rw-r--r--
*** empty log message ***

DialogBox subclass:#LicenceBox
	instanceVariableNames:'accepted destroySemaphore'
	classVariableNames:'LicenceRejectSignal'
	poolDictionaries:''
	category:'Views-DialogBoxes'
!

!LicenceBox  class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1996 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.
"
!

documentation
"
    LicenceBox shows a licence text when opened, an returns true,
    if the licence has been accepted, false otherwise.

    [author:]
	Stefan Vogel

    [see also:]
	AboutBox
"
!

examples
"
						[exBegin]
    LicenceRejectSignal handle:[:ex|
	Transcript showCR:'Licence rejected'.
    ] do:[
	LicenceBox open.
	Transcript showCR:'Licence accepted'.
    ] 
						[exEnd]
"
! !

!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' default:nil.
   file isNil ifTrue:[
	file := 'doc/online/german/LICENCE.STX.html'.
   ].
   file asFilename exists ifFalse:[
       file := Smalltalk getSystemFileName:'doc/online/german/LICENCE.STX.html'.
       file isNil ifTrue:[
	  file := '../../doc/online/german/LICENCE.STX.html'.
       ].
   ].
   file asFilename exists ifFalse:[
       ^ 'oops - you are not allowed to remove the LICENSE file !!'
   ].
   ^ file asFilename readStream contents.

    "Created: 6.9.1996 / 12:17:07 / stefan"
    "Modified: 10.9.1996 / 14:47:41 / cg"
! !

LicenceBox initialize!