From VisualWorks®, 7.5 of April 16, 2007 on August 8, 2007 at 2:52:29 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <class> <name>STSDateRangeSelectorDialog</name> <environment>Seaside</environment> <super>Seaside.WAFormDialog</super> <private>false</private> none startDateSelector endDateSelector startDate endDate <imports></imports> <category>STSTutorial-Library</category> <attributes> <package>Seaside-Tutorial2004</package> </attributes> </class> <class> <name>STSReservation</name> <environment>Seaside</environment> <super>Core.Object</super> <private>false</private> none arrivalDate departureDate numberOfRooms dailyRate <imports></imports> <category>STSTutorial-Workbook</category> <attributes> <package>Seaside-Tutorial2004</package> </attributes> </class> <class> <name>STSReservationMenu</name> <environment>Seaside</environment> <super>Seaside.WAComponent</super> <private>false</private> none navigationBar <imports></imports> <category>STSTutorial-Workbook</category> <attributes> <package>Seaside-Tutorial2004</package> </attributes> </class> <class> <name>STSCalendar</name> <environment>Seaside</environment> <super>Seaside.WAComponent</super> <private>false</private> none month date <imports></imports> <category>STSTutorial-Library</category> <attributes> <package>Seaside-Tutorial2004</package> </attributes> </class> <comment> Seaside.STSCalendar
Calendar component
</comment> <class> <name>STSDateSelectorDialog</name> <environment>Seaside</environment> <super>Seaside.WAFormDialog</super> <private>false</private> none dateSelector <imports></imports> <category>STSTutorial-Library</category> <attributes> <package>Seaside-Tutorial2004</package> </attributes> </class> <class> <name>STSDateSelectorDialog1</name> <environment>Seaside</environment> <super>Seaside.STSDateSelectorDialog</super> <private>false</private> none <imports></imports> <category>STSTutorial-Library</category> <attributes> <package>Seaside-Tutorial2004</package> </attributes> </class> <class> <name>STSReservationTask</name> <environment>Seaside</environment> <super>Seaside.WATask</super> <private>false</private> none reservation continue <imports></imports> <category>STSTutorial-Workbook</category> <attributes> <package>Seaside-Tutorial2004</package> </attributes> </class> <class> <name>STSReservationTask1</name> <environment>Seaside</environment> <super>Seaside.STSReservationTask</super> <private>false</private> none <imports></imports> <category>STSTutorial-Workbook</category> <attributes> <package>Seaside-Tutorial2004</package> </attributes> </class> <class> <name>STSReservationTask2</name> <environment>Seaside</environment> <super>Seaside.STSReservationTask1</super> <private>false</private> none <imports></imports> <category>STSTutorial-Workbook</category> <attributes> <package>Seaside-Tutorial2004</package> </attributes> </class> <name>Images</name> <environment>Seaside.STSCalendar</environment> <private>false</private> <constant>false</constant> <category>class variables</category> <initializer>Dictionary new</initializer> <attributes> <package>Seaside-Tutorial2004</package> </attributes> <methods> Seaside.STSDateRangeSelectorDialog <category>seaside</category>
children ^ Array with: startDateSelector with: endDateSelector.
</methods> <methods> Seaside.STSDateRangeSelectorDialog <category>initialization</category>
initialize startDateSelector := STSCalendar new. endDateSelector := STSCalendar new. startDateSelector onAnswer: [:v | self validate]. endDateSelector onAnswer: [:v | self validate].
</methods> <methods> Seaside.STSDateRangeSelectorDialog <category>actions</category>
ok startDateSelector date isNil ifTrue: [^self inform: 'Date of arrival not specified']. endDateSelector date isNil ifTrue: [^self inform: 'Date of departure not specified']. startDateSelector date < endDateSelector date ifTrue: [self answer: (Array with: startDateSelector date with: endDateSelector date)] ifFalse: [self inform: 'Date of departure must be after date of arrival'].
validate endDateSelector date isNil ifTrue: [^self]. startDateSelector date isNil ifTrue: [^self]. startDateSelector date >= endDateSelector date ifTrue: [self inform: 'Date of departure must be after date of arrival'].
</methods> <methods> Seaside.STSDateRangeSelectorDialog <category>rendering</category>
renderDialogOn: html html form: [(html table) class: #'dual-calendar'; with: [html tableRow: [html tableData: 'Arrival Date'. html tableData: 'Departure Date']. html tableRow: [html tableData: [html render: startDateSelector]. html tableData: [html render: endDateSelector]]]. (html submitButton) callback: [self ok]; text: 'OK']
</methods> <methods> Seaside.STSDateRangeSelectorDialog <category>css style</category>
style ^ 'table.dual-calendar { border: none; font-weight: bold; font-size: 14pt; text-align: center } '
</methods> <methods> Seaside.STSReservation <category>accessing</category>
arrivalDate ^arrivalDate
arrivalDate: anObject arrivalDate := anObject
dailyRate ^dailyRate
dailyRate: anObject dailyRate := anObject
departureDate ^departureDate
departureDate: anObject departureDate := anObject
numberOfRooms ^numberOfRooms
numberOfRooms: anObject numberOfRooms := anObject
</methods> <methods> Seaside.STSReservation <category>validation</category>
checkRuleSet: rules "Stop checking when first assertion fails" rules do: [ :eachRule | eachRule first value ifFalse: [^false]]. ^ true.
getTextForRuleSet: rules rules do: [ :eachRule | eachRule first value ifFalse: [^eachRule last value]]. ^rules last last value.
numberOfRoomsRules | rules | rules := OrderedCollection new. rules add: (Array with: [self numberOfRooms isInteger] with: ['The number of rooms should be an integer number']). rules add: (Array with: [self numberOfRooms >= 0] with: ['The number of rooms should be positive']). rules add: (Array with: [self numberOfRooms > 0] with: ['The number of rooms should be at least one']). rules add: (Array with: [true] with: [self numberOfRoomsText]). ^ rules
periodRules | rules | rules := OrderedCollection new. rules add: (Array with: [self arrivalDate notNil] with: ['The arrival date should be supplied']). rules add: (Array with: [self departureDate notNil] with: ['The departure date should be supplied']). rules add: (Array with: [self duration > 0] with: ['The departure date should be after the arrival date']). rules add: (Array with: [true] with: [self durationText]). ^ rules
</methods> <methods> Seaside.STSReservation <category>queries</category>
cost ^ self duration * self numberOfRooms * self dailyRate.
duration self arrivalDate isNil ifTrue: [^nil]. self departureDate isNil ifTrue: [^nil]. ^ self departureDate subtractDate: self arrivalDate
durationText | str | str := (String new: 20) writeStream. str nextPutAll: 'This reservation is for'; space; nextPutAll: self duration printString; space; nextPutAll: 'night'. self duration > 1 ifTrue: [str nextPut: $s]. ^ str contents
isNumberOfRoomsValidText ^ self getTextForRuleSet: self numberOfRoomsRules
isPeriodValidText ^ self getTextForRuleSet: self periodRules
numberOfRoomsText | str | str := (String new: 20) writeStream. str nextPutAll: 'This reservation is for'; space; nextPutAll: self numberOfRooms printString; space; nextPutAll: 'room'. self numberOfRooms > 1 ifTrue: [str nextPut: $s]. ^ str contents
</methods> <methods> Seaside.STSReservation <category>testing</category>
isNumberOfRoomsValid ^ self checkRuleSet: self numberOfRoomsRules
isPeriodValid ^ self checkRuleSet: self periodRules
</methods> <methods> Seaside.STSReservationMenu <category>rendering</category>
actions ^ #( reservation1 reservation2 reservation3 )
children ^ Array with: navigationBar.
initialize navigationBar := WANavigationBar new owner: self; actionsSelector: #actions.
renderContentOn: html html render: navigationBar
reservation1 self call: STSReservationTask new.
reservation2 self call: STSReservationTask1 new.
reservation3 self call: STSReservationTask2 new.
</methods> <methods> Seaside.STSReservationMenu class <category>seaside</category>
canBeRoot ^ true
description ^'Hotel reservation examples'
</methods> <methods> Seaside.STSReservationMenu class <category>initialize-release</category>
initialize self registerAsApplication: 'examples/reservations'
</methods> <methods> Seaside.STSCalendar <category>accessing</category>
date date isNil ifTrue: [self date: Date today]. ^date
date: anObject date := anObject
month ^ month contents
month: anObject month contents: anObject
</methods> <methods> Seaside.STSCalendar <category>private</category>
firstDate ^ self month firstDate
lastDate ^ self month lastDate
updateRoot: anHtmlRoot super updateRoot: anHtmlRoot.
</methods> <methods> Seaside.STSCalendar <category>initialization</category>
initialize month := WAStateHolder new. self month: Date today month.
</methods> <methods> Seaside.STSCalendar <category>rendering</category>
renderContentOn: html (html table) class: #calendar; with: [self renderMonthHeaderOn: html. self renderWeekHeaderOn: html. self month weeksDo: [:week | self renderWeek: week on: html]]
renderDay: aDay on: html | thisMonth | aDay = self date ifTrue: [(html tableData) class: #selected; with: [html text: aDay dayOfMonth]] ifFalse: [thisMonth := aDay month = self month. (html tableData) class: #included if: thisMonth; class: #excluded if: thisMonth not; with: [(html anchor) callback: [self selectDay: aDay]; with: aDay dayOfMonth]]
renderMonthHeaderOn: html (html tableRow) class: #'month-header'; with: [(html tableData) class: #'month-previous'; with: [(html anchor) title: 'Previous month (' , self month previous name , ' ' , self month previous year printString , ')'; callback: [self month: self month previous]; with: [html image form: self class imagePrevious]]. (html tableData) class: #'month-name'; colSpan: 5; with: self month monthName , ' ' , self month year printString. (html tableData) class: #'month-next'; with: [(html anchor) title: 'Next month (' , self month next name , ' ' , self month next year printString , ')'; callback: [self month: self month next]; with: [html image form: self class imageNext]]]
renderWeek: aWeek on: html (html tableRow) class: #week; with: [aWeek datesDo: [:eachDay | self renderDay: eachDay on: html]]
renderWeekHeaderOn: html html tableRow class: #'week-header'; with: [#(Su Mo Tu We Th Fr Sa) do: [ :eachDay | html tableData: eachDay]]
</methods> <methods> Seaside.STSCalendar <category>css style</category>
script ^''
style ^ 'table.calendar { border: 2px solid black; font-size: 12pt; border-collapse: collapse } table.calendar td.month-previous,td.month-next { border: none; } table.calendar tr.month-header img { border: none; } table.calendar td.month-next:hover,td.month-previous:hover { background: yellow; } table.calendar td.month-name { font-weight: bold; text-align: center } table.calendar tr.week-header td { border: 2px solid black; background-color: lightyellow; font-size: 8pt; text-align: center } table.calendar tr.week { border-bottom: 2px solid black; } table.calendar td.included,td.excluded,td.selected { border: 2px solid black; padding: 3px; text-align: center; } table.calendar a { text-decoration: none; } table.calendar td.excluded { color: #ccc; } table.calendar td.included:hover,td.excluded:hover { background: lightgreen; } table.calendar td.selected { font-weight: bold; background: yellow; } '
</methods> <methods> Seaside.STSCalendar <category>actions</category>
selectDay: aDay self date: aDay. self answer: aDay.
</methods> <methods> Seaside.STSCalendar class <category>seaside</category>
canBeRoot ^ true
</methods> <methods> Seaside.STSCalendar class <category>resources</category>
imageFrom: anIcon ^ anIcon image asGIFWithTransparentPaint: self transparentColor.
transparentColor ^ ColorValue veryLightGray
</methods> <methods> Seaside.STSCalendar class <category>accessing</category>
imageNext ^self images at: #imageNext ifAbsentPut: [self imageFrom: self iconNext].
imagePrevious ^self images at: #imagePrevious ifAbsentPut: [self imageFrom: self iconPrevious].
images Images isNil ifTrue: [Images := Dictionary new]. ^Images
</methods> <methods> Seaside.STSCalendar class <category>initialize-release</category>
initialize self registerAsApplication: 'examples/calendar'
</methods> <methods> Seaside.STSDateSelectorDialog <category>seaside</category>
children ^ Array with: dateSelector
</methods> <methods> Seaside.STSDateSelectorDialog <category>accessing</category>
date: aDate dateSelector date: aDate
</methods> <methods> Seaside.STSDateSelectorDialog <category>initialization</category>
dateComponentClass ^Seaside.WADateSelector
initialize super initialize. dateSelector := self dateComponentClass new
</methods> <methods> Seaside.STSDateSelectorDialog <category>actions</category>
ok self answer: dateSelector date
</methods> <methods> Seaside.STSDateSelectorDialog <category>rendering</category>
renderDialogOn: html html render: dateSelector.
</methods> <methods> Seaside.STSDateSelectorDialog1 <category>initialization</category>
dateComponentClass ^Seaside.STSCalendar
</methods> <methods> Seaside.STSReservationTask <category>private</category>
getArrivalAndDepartureDates [self reservation arrivalDate: self getArrivalDate. self reservation arrivalDate isNil] whileTrue: [self inform: self reservation isPeriodValidText]. [self reservation departureDate: self getDepartureDate. self reservation isPeriodValid] whileFalse: [self inform: self reservation isPeriodValidText].
getArrivalDate ^self getDateWithHeading: 'Choose a date of arrival at the hotel'.
getDailyRate self reservation dailyRate: self rate.
getDateWithHeading: aString ^self call: ((STSDateSelectorDialog new) addMessage: aString; yourself)
getDepartureDate ^self getDateWithHeading: 'Choose a date of departure from the hotel'.
getNumberOfRooms [self reservation numberOfRooms: (self call: ((WAInputDialog new label: 'OK'; default: 1) addMessage: 'Choose number of rooms'; addMessage: self reservation isPeriodValidText; yourself)) asNumber. self reservation isNumberOfRoomsValid] whileFalse: [self inform: self reservation isNumberOfRoomsValidText].
</methods> <methods> Seaside.STSReservationTask <category>actions</category>
go [continue] whileTrue: [self getArrivalAndDepartureDates. self getNumberOfRooms. self reservation dailyRate: self rate. continue := self call: ((WAYesOrNoDialog new) addMessage: 'Another hotel reservation ?'; addMessage: 'Total cost is ' , self reservation cost printString; addMessage: self reservation isNumberOfRoomsValidText; addMessage: self reservation isPeriodValidText; yourself)].
</methods> <methods> Seaside.STSReservationTask <category>initialization</category>
initialize reservation := STSReservation new. continue := true.
</methods> <methods> Seaside.STSReservationTask <category>queries</category>
rate ^ 100.00
</methods> <methods> Seaside.STSReservationTask <category>accessing</category>
reservation ^reservation
reservation: anObject reservation := anObject
</methods> <methods> Seaside.STSReservationTask1 <category>private</category>
getDateWithHeading: aString ^self call: ((STSDateSelectorDialog1 new) addMessage: aString; yourself)
</methods> <methods> Seaside.STSReservationTask2 <category>private</category>
getArrivalAndDepartureDates | dates | dates := self call: STSDateRangeSelectorDialog new. self reservation arrivalDate: dates first. self reservation departureDate: dates last.
</methods> <methods> VisualWave.GIFImage <category>*seaside2</category>
asMIMEDocument ^ Seaside.MIMEDocument contentType: self mediaType content: gifBytes.
</methods> <methods> Seaside.STSCalendar class <category>resources</category>
iconNext "Tools.UIMaskEditor new openOnClass: self andSelector: #iconNext" <resource: #image> ^CachedImage on: (Image extent: 16@16 depth: 1 bitsPerPixel: 1 palette: (Graphics.MappedPalette withColors: ((Core.Array new: 2) at: 1 put: Graphics.ColorValue black; at: 2 put: self transparentColor; yourself)) usingBits: #[255 255 0 0 255 255 0 0 255 255 0 0 231 255 0 0 225 255 0 0 224 127 0 0 224 31 0 0 224 7 0 0 224 7 0 0 224 31 0 0 224 127 0 0 225 255 0 0 231 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0])
iconPrevious "Tools.UIMaskEditor new openOnClass: self andSelector: #iconPrevious" <resource: #image> ^CachedImage on: (Image extent: 16@16 depth: 1 bitsPerPixel: 1 palette: (Graphics.MappedPalette withColors: ((Core.Array new: 2) at: 1 put: Graphics.ColorValue black; at: 2 put: self transparentColor; yourself)) usingBits: #[255 255 0 0 255 255 0 0 255 255 0 0 255 231 0 0 255 135 0 0 254 7 0 0 248 7 0 0 224 7 0 0 224 7 0 0 248 7 0 0 254 7 0 0 255 135 0 0 255 231 0 0 255 255 0 0 255 255 0 0 255 255 0 0])
</methods> <initialize> Seaside.STSReservationMenu </initialize> <initialize> Seaside.STSCalendar </initialize> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>Object</name> <environment>Core</environment> <super></super> <private>false</private> none <imports></imports> <category>Kernel-Objects</category> <attributes> <package>Kernel-Objects</package> </attributes> </class> <class> <name>GIFImage</name> <environment>VisualWave</environment> <super>Graphics.PixelArray</super> <private>false</private> none gifBytes height width bitsPerPixel palette cachedVisual <imports></imports> <category>Wave-Support-Bitmaps</category> <attributes> <package>Wave-Server</package> </attributes> </class> <class> <name>WAComponent</name> <environment>Seaside</environment> <super>Seaside.WAPresenter</super> <private>false</private> none decoration <imports></imports> <category>Seaside-Component</category> <attributes> <package>Seaside-Component</package> </attributes> </class> <class> <name>WAFormDialog</name> <environment>Seaside</environment> <super>Seaside.WAComponent</super> <private>false</private> none validationError form <imports></imports> <category>Seaside-Components-Dialogs</category> <attributes> <package>Seaside-Components-Dialogs</package> </attributes> </class> <class> <name>WATask</name> <environment>Seaside</environment> <super>Seaside.WAComponent</super> <private>false</private> none <imports></imports> <category>Seaside-Component</category> <attributes> <package>Seaside-Component</package> </attributes> </class>