From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:46:14 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>Adaptor1Example</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none customers accountID address name phoneNumber <imports></imports> <category>Examples-Help</category> <attributes> <package>Adapt1-Example</package> </attributes> </class> <comment> Examples.Adaptor1Example
Adaptor1Example class demonstrates the use of a value holder and the use of onChangeSend: to coordinate changes with a domain model, Customer1Example. Browse the initialize-release methods for configuring dependencies, and the change messages methods for updating the domain model. Instance Variables: accountID <ValueHolder on: Integer> customer accountID address <ValueHolder on: String> customer address customers <SelectionInList> list model for customer information name <ValueHolder on: String> customer name phoneNumber <ValueHolder on: String> customer phoneNumber
</comment> <methods> Examples.Adaptor1Example <category>aspects</category>
accountID ^accountID
address ^address
customers ^customers
name ^name
phoneNumber ^phoneNumber
</methods> <methods> Examples.Adaptor1Example <category>change messages</category>
changedAddress | chosenCustomer | chosenCustomer := self customers selection. chosenCustomer isNil ifFalse: [ chosenCustomer address: self address value].
changedCustomer | chosenCustomer | chosenCustomer := self customers selection. chosenCustomer isNil ifTrue: [ self accountID value: 0. self name value: ''. self address value: ''. self phoneNumber value: ''] ifFalse: [ self accountID value: chosenCustomer accountID. self name value: chosenCustomer name. self address value: chosenCustomer address. self phoneNumber value: chosenCustomer phoneNumber]. #( #accountID #name #address #phoneNumber) do: [ :componentName | (self builder componentAt: componentName) isEnabled: chosenCustomer notNil].
changedID | chosenCustomer | chosenCustomer := self customers selection. chosenCustomer isNil ifFalse: [ chosenCustomer accountID: self accountID value]. self redisplayList.
changedName | chosenCustomer | chosenCustomer := self customers selection. chosenCustomer isNil ifFalse: [ chosenCustomer name: self name value]. self redisplayList.
changedPhone | chosenCustomer | chosenCustomer := self customers selection. chosenCustomer isNil ifFalse: [ chosenCustomer phoneNumber: self phoneNumber value].
</methods> <methods> Examples.Adaptor1Example <category>initialize-release</category>
initialize customers := SelectionInList new. customers selectionIndexHolder onChangeSend: #changedCustomer to: self. self initializeID. self initializeName. self initializeAddress. self initializePhone.
initializeAddress address := ValueHolder newString. address onChangeSend: #changedAddress to: self.
initializeID accountID := 0 asValue. accountID onChangeSend: #changedID to: self.
initializeName name := ValueHolder newString. name onChangeSend: #changedName to: self.
initializePhone phoneNumber := ValueHolder newString. phoneNumber onChangeSend: #changedPhone to: self.
</methods> <methods> Examples.Adaptor1Example <category>private</category>
redisplayList (self builder componentAt: #customers) widget invalidate.
</methods> <methods> Examples.Adaptor1Example <category>actions</category>
add | list selectionInList | selectionInList := self customers. list := selectionInList list. "Add new customer." list add: Customer1Example new. "Highlight new customer." selectionInList selectionIndex: list size.
</methods> <methods> Examples.Adaptor1Example class <category>interface specs</category>
windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#FullSpec #window: #(#WindowSpec #label: 'Adaptor1Example' #min: #(#Point 506 188 ) #max: #(#Point 506 188 ) #bounds: #(#Rectangle 668 652 1174 840 ) ) #component: #(#SpecCollection #collection: #( #(#LabelSpec #layout: #(#Point 177 19 ) #label: 'Customer ID' ) #(#LabelSpec #layout: #(#Point 177 56 ) #label: 'Name' ) #(#LabelSpec #layout: #(#Point 177 93 ) #label: 'Address' ) #(#LabelSpec #layout: #(#Point 177 129 ) #label: 'Phone' ) #(#LabelSpec #layout: #(#Point 278 165 ) #label: '(These fields use ValueHolders)' #style: #small ) #(#ActionButtonSpec #layout: #(#AlignmentOrigin 0 0.166667 4 0 0.5 0 ) #model: #add #label: 'Add customer' ) #(#SequenceViewSpec #layout: #(#LayoutFrame 10 0 40 0 0 0.333333 -10 1 ) #name: #customers #flags: 15 #model: #customers ) #(#InputFieldSpec #layout: #(#Rectangle 286 22 333 44 ) #name: #accountID #flags: 40 #model: #accountID #type: #number ) #(#InputFieldSpec #layout: #(#Rectangle 286 57 483 81 ) #name: #name #flags: 40 #model: #name ) #(#InputFieldSpec #layout: #(#Rectangle 286 94 483 118 ) #name: #address #flags: 40 #model: #address ) #(#InputFieldSpec #layout: #(#Rectangle 286 130 483 154 ) #name: #phoneNumber #flags: 40 #model: #phoneNumber ) ) ) )
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>ApplicationModel</name> <environment>UI</environment> <super>UI.Model</super> <private>false</private> none builder uiSession eventHandlers savedWindowInformation <imports></imports> <category>UIBuilder-Framework</category> <attributes> <package>UIBuilder-Framework</package> </attributes> </class>