'From VisualWorks(R) Release 2.0 of 4 August 1994 on 29 April 1995 at 10:04:48 pm'! ApplicationModel subclass: #Adaptor1Example instanceVariableNames: 'customers accountID address name phoneNumber ' classVariableNames: '' poolDictionaries: '' category: 'Examples-Cookbook'! Adaptor1Example comment: 'This example class demonstrates the use of a value holder. The VisualWorks Cookbook provides usage instructions -- look for this class''s name in the Cookbook''s index.'! !Adaptor1Example methodsFor: 'initialize-release'! 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.! ! !Adaptor1Example methodsFor: 'aspects'! accountID ^accountID! address ^address! customers ^customers! name ^name! phoneNumber ^phoneNumber! ! !Adaptor1Example methodsFor: 'actions'! add | list selectionInList | selectionInList := self customers. list := selectionInList list. "Add new customer." list add: Customer1Example new. selectionInList list: list. "Highlight new customer." selectionInList selectionIndex: list size.! ! !Adaptor1Example methodsFor: 'change messages'! changedAddress | chosenCustomer | chosenCustomer := self customers selection. chosenCustomer isNil ifFalse: [ chosenCustomer address: self address value].! changedCustomer | chosenCustomer selector | chosenCustomer := self customers selection. chosenCustomer isNil ifTrue: [ self accountID value: 0. self name value: ''. self address value: ''. self phoneNumber value: ''. selector := #disable] ifFalse: [ self accountID value: chosenCustomer accountID. self name value: chosenCustomer name. self address value: chosenCustomer address. self phoneNumber value: chosenCustomer phoneNumber. selector := #enable]. #( #accountID #name #address #phoneNumber) do: [ :componentName | (self builder componentAt: componentName) perform: selector].! 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].! ! !Adaptor1Example methodsFor: 'private'! redisplayList (self builder componentAt: #customers) widget invalidate.! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! Adaptor1Example class instanceVariableNames: ''! !Adaptor1Example class methodsFor: 'interface specs'! windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" ^#(#FullSpec #window: #(#WindowSpec #label: 'Adaptor1Example' #min: #(#Point 506 188 ) #max: #(#Point 506 188 ) #bounds: #(#Rectangle 244 427 750 615 ) ) #component: #(#SpecCollection #collection: #( #(#LabelSpec #layout: #(#Point 193 27 ) #label: 'Customer ID' ) #(#LabelSpec #layout: #(#Point 193 63 ) #label: 'Name' ) #(#LabelSpec #layout: #(#Point 193 99 ) #label: 'Address' ) #(#LabelSpec #layout: #(#Point 193 135 ) #label: 'Phone' ) #(#LabelSpec #layout: #(#Point 283 167 ) #label: '(These fields use ValueHolders)' #style: #small ) #(#ActionButtonSpec #layout: #(#AlignmentOrigin 0 0.166667 7 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 ) ) ) )! !