[Seaside] Component with multiples decorations

Julien Berthaud j.berthaud at aureo.info
Tue Jun 12 15:46:01 UTC 2007


Sorry I have forgotten this part.
> I have file-out the model just in case but I think you already have it.

Julien


-------------- next part --------------
Object subclass: #STModel
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Tutorial-Theater-Model'!

!STModel methodsFor: 'enumerating' stamp: 'lr 3/29/2006 17:35'!
do: aBlock
	self subclassResponsibility! !


!STModel methodsFor: 'initialization' stamp: 'lr 2/12/2007 15:09'!
initialize! !


!STModel methodsFor: 'accessing-readonly' stamp: 'lr 3/29/2006 19:45'!
plays
	^ Array streamContents: [ :stream |
		self do: [ :each | stream nextPutAll: each plays ] ]! !

!STModel methodsFor: 'accessing-readonly' stamp: 'lr 3/29/2006 19:45'!
shows
	^ Array streamContents: [ :stream |
		self do: [ :each | stream nextPutAll: each shows ] ]! !

!STModel methodsFor: 'accessing-readonly' stamp: 'lr 3/29/2006 19:45'!
tickets
	^ Array streamContents: [ :stream |
		self do: [ :each | stream nextPutAll: each tickets ] ]! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

STModel class
	instanceVariableNames: ''!

!STModel class methodsFor: 'instance-creation' stamp: 'lr 2/12/2007 15:09'!
new
	^ self basicNew initialize! !


STModel subclass: #STPlay
	instanceVariableNames: 'title author kind description shows theater'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Tutorial-Theater-Model'!

!STPlay methodsFor: 'conveniance' stamp: 'lr 3/29/2006 19:48'!
addShow: aShow
	aShow setPlay: self.
	self shows add: aShow.
	^ aShow! !


!STPlay methodsFor: 'accessing' stamp: 'lr 3/29/2006 19:45'!
author
	^ author! !

!STPlay methodsFor: 'accessing' stamp: ' 25/2/05 18:54'!
author: aString
	author := aString! !

!STPlay methodsFor: 'accessing' stamp: 'lr 3/29/2006 19:45'!
description
	^ description! !

!STPlay methodsFor: 'accessing' stamp: ' 25/2/05 18:54'!
description: aString
	description := aString! !

!STPlay methodsFor: 'accessing' stamp: 'lr 3/29/2006 19:46'!
kind
	^ kind! !

!STPlay methodsFor: 'accessing' stamp: ' 25/2/05 18:54'!
kind: aString
	kind := aString! !

!STPlay methodsFor: 'accessing' stamp: 'lr 3/29/2006 19:46'!
title
	^ title! !

!STPlay methodsFor: 'accessing' stamp: ' 25/2/05 18:54'!
title: aString
	title := aString! !


!STPlay methodsFor: 'enumerating' stamp: 'lr 3/29/2006 17:36'!
do: aBlock
	self shows do: aBlock! !


!STPlay methodsFor: 'initialization' stamp: 'lr 3/29/2006 17:36'!
initialize
	super initialize.
	self setShows: Set new! !


!STPlay methodsFor: 'printing' stamp: 'lr 3/29/2006 17:36'!
printOn: aStream
	super printOn: aStream.
	aStream nextPutAll: ' title: '; print: self title! !


!STPlay methodsFor: 'private' stamp: ' 25/2/05 18:54'!
setShows: aCollection
	shows := aCollection! !

!STPlay methodsFor: 'private' stamp: ' 25/2/05 18:54'!
setTheater: aTheater
	theater := aTheater! !


!STPlay methodsFor: 'accessing-readonly' stamp: 'lr 3/29/2006 19:47'!
shows
	^ shows! !

!STPlay methodsFor: 'accessing-readonly' stamp: 'lr 3/29/2006 19:47'!
theater
	^ theater! !


STModel subclass: #STShow
	instanceVariableNames: 'play timestamp tickets'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Tutorial-Theater-Model'!

!STShow methodsFor: 'conveniance' stamp: 'lr 3/29/2006 19:48'!
addTicket: aTicket
	self placesFree isZero
		ifTrue: [ self error: 'No more tickets available for this show.' ].
	aTicket setShow: self.
	self tickets add: aTicket.
	^ aTicket! !

!STShow methodsFor: 'conveniance' stamp: 'lr 3/29/2006 19:48'!
nextTicket
	^ self addTicket: STTicket new! !

!STShow methodsFor: 'conveniance' stamp: 'lr 3/29/2006 20:38'!
nextTickets: aNumber
	^ (1 to: aNumber) collect: [ :each | self addTicket: STTicket new ]! !


!STShow methodsFor: 'accessing-readonly' stamp: 'lr 2/12/2007 15:10'!
date
	^ self timestamp asDate! !

!STShow methodsFor: 'accessing-readonly' stamp: 'lr 2/12/2007 15:10'!
placesFree
	^ self placesTotal - self placesSold! !

!STShow methodsFor: 'accessing-readonly' stamp: 'lr 2/12/2007 15:10'!
placesSold
	^ self tickets size! !

!STShow methodsFor: 'accessing-readonly' stamp: 'lr 2/12/2007 15:10'!
placesTotal
	^ 100! !

!STShow methodsFor: 'accessing-readonly' stamp: 'lr 2/12/2007 15:10'!
play
	^ play! !

!STShow methodsFor: 'accessing-readonly' stamp: 'lr 2/12/2007 15:10'!
tickets
	^ tickets! !

!STShow methodsFor: 'accessing-readonly' stamp: 'lr 2/12/2007 15:10'!
time
	^ self timestamp asTime! !


!STShow methodsFor: 'enumerating' stamp: 'lr 3/29/2006 17:36'!
do: aBlock
	self tickets do: aBlock! !


!STShow methodsFor: 'initialization' stamp: 'lr 3/29/2006 17:36'!
initialize
	super initialize.
	self setTickets: Set new! !


!STShow methodsFor: 'printing' stamp: 'lr 3/29/2006 17:36'!
printOn: aStream
	super printOn: aStream.
	aStream nextPutAll: ' timestamp: '; print: self timestamp! !


!STShow methodsFor: 'private' stamp: ' 25/2/05 18:54'!
setPlay: aPlay
	play := aPlay! !

!STShow methodsFor: 'private' stamp: ' 25/2/05 18:54'!
setTickets: aCollection
	tickets := aCollection! !


!STShow methodsFor: 'accessing' stamp: ' 25/2/05 18:54'!
timestamp
	^timestamp! !

!STShow methodsFor: 'accessing' stamp: ' 25/2/05 18:54'!
timestamp: aTimestamp
	timestamp := aTimestamp! !


STModel subclass: #STTheater
	instanceVariableNames: 'name season plays'
	classVariableNames: 'Default'
	poolDictionaries: ''
	category: 'Tutorial-Theater-Model'!

!STTheater methodsFor: 'conveniance' stamp: 'lr 3/29/2006 19:49'!
addPlay: aPlay
	aPlay setTheater: self.
	self plays add: aPlay.
	^ aPlay! !


!STTheater methodsFor: 'enumerating' stamp: 'lr 3/29/2006 17:36'!
do: aBlock
	self plays do: aBlock! !


!STTheater methodsFor: 'initialization' stamp: 'lr 3/29/2006 17:36'!
initialize
	super initialize.
	self setPlays: Set new! !


!STTheater methodsFor: 'accessing' stamp: 'lr 3/29/2006 19:49'!
name
	^ name! !

!STTheater methodsFor: 'accessing' stamp: ' 25/2/05 18:54'!
name: aString
	name := aString! !

!STTheater methodsFor: 'accessing' stamp: 'lr 3/29/2006 19:49'!
season
	^ season! !

!STTheater methodsFor: 'accessing' stamp: ' 25/2/05 18:54'!
season: aString
	season := aString! !


!STTheater methodsFor: 'accessing-readonly' stamp: 'lr 3/29/2006 19:49'!
plays
	^ plays! !


!STTheater methodsFor: 'printing' stamp: 'lr 3/29/2006 17:36'!
printOn: aStream
	super printOn: aStream.
	aStream nextPutAll: ' name: '; print: self name! !


!STTheater methodsFor: 'private' stamp: ' 25/2/05 18:54'!
setPlays: aCollection
	plays := aCollection! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

STTheater class
	instanceVariableNames: ''!

!STTheater class methodsFor: 'accessing' stamp: 'lr 3/29/2006 19:50'!
default
	^ Default! !


!STTheater class methodsFor: 'initialization' stamp: 'lr 5/15/2006 16:23'!
initialize
	STTicket resetId.
	Default := self new
		name: 'Bedlam Theatre';
		season: 'Summer 2006';
		addPlay: (STPlay new
			title: 'The Improverts';
			kind: 'Theatre';
			author: 'n/a';
			description: 'Fresh from another year of sell-out shows at the Edinburgh Fringe Festival, Edinburgh''s resident late-night comedy show returns for its legendary weekly Friday night spot. Now in its 16th year, our crack improv troupe perform a one hour show of comedy scenes and sketches based only on audience suggestions given to them during each performance. The show is completely different every night, keep coming back for more!!';
			yourself);
		addPlay: (STPlay new
			title: 'Improvisation';
			kind: 'Workshop';
			author: 'Improverts';
			description: 'Open to everyone with or without improv experience, this workshop goes back to the fundamentals of creating scenes on the spot, creating characters and relationships, and having spontaneous fun on stage. A relaxed and informal workshop, and we all go to the pub for lunch afterwards. A great Friday night hangover cure.';
			yourself);
		addPlay: (STPlay new
			title: 'Ghost Train';
			kind: 'Theatre';
			author: 'Arnold Ridley';
			description: 'Arnold Ridley''s "The Ghost Train" was written in seven days in 1925. Suprisingly it still has an old fashioned fascination for today''s audiences. What are the magic ingredients? Well, this was just after the first world war with spies still the number one worry. Take the spies and mix with a remote railway station late at night and all sorts of things can be imagined. There are lots of comings and goings and strange goings on to make the audience enjoy themselves, all things that you would expect of a play of this age and Arnold Ridley knew how to mix it all up to make the outcome just right.';
			yourself);
		yourself.
	self default do: [ :play |
		10 + 20 atRandom timesRepeat: [ | show |
			play addShow: (show := STShow new
				timestamp: (TimeStamp now
					plusSeconds: (6 * 30 * 24 * 60 * 60) atRandom - (2 * 30 * 24 * 60 * 60));
				yourself).
			show timestamp: (DateAndTime
				year: show timestamp year
				month: show timestamp month
				day: show timestamp dayOfMonth
				hour: show timestamp hour
				minute: 0).
			(50 atRandom - 1) timesRepeat: [
				show nextTicket ] ] ]! !


STModel subclass: #STTicket
	instanceVariableNames: 'show id'
	classVariableNames: 'TicketId'
	poolDictionaries: ''
	category: 'Tutorial-Theater-Model'!

!STTicket methodsFor: 'enumerating' stamp: 'lr 3/29/2006 17:36'!
do: aBlock
	self shouldNotImplement! !


!STTicket methodsFor: 'accessing-readonly' stamp: 'lr 3/29/2006 19:50'!
id
	^ id! !

!STTicket methodsFor: 'accessing-readonly' stamp: 'JB 5/8/2007 11:36'!
show
	^ show! !


!STTicket methodsFor: 'initialization' stamp: 'lr 3/29/2006 17:36'!
initialize
	super initialize.
	self setId: self class nextId! !


!STTicket methodsFor: 'printing' stamp: 'lr 3/29/2006 17:36'!
printOn: aStream
	super printOn: aStream.
	aStream nextPutAll: ' id: '; print: self id! !


!STTicket methodsFor: 'private' stamp: ' 25/2/05 18:54'!
setId: aNumber
	id := aNumber! !

!STTicket methodsFor: 'private' stamp: ' 25/2/05 18:54'!
setShow: aShow
	show := aShow! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

STTicket class
	instanceVariableNames: ''!

!STTicket class methodsFor: 'accessing' stamp: 'lr 3/29/2006 19:50'!
nextId
	^ TicketId := TicketId + 1! !

!STTicket class methodsFor: 'accessing' stamp: 'lr 3/29/2006 17:36'!
resetId
	TicketId := 1000! !

STTheater initialize!


More information about the Seaside mailing list