From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:46:24 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>Adaptor3Example</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none customers selectedCustomer updateTrigger <imports></imports> <category>Examples-Help</category> <attributes> <package>Adapt3-Example</package> </attributes> </class> <comment> Examples.Adaptor3Example
Adaptor3Example class demonstrates the use of a BufferedValueHolder to synchronize updates between the application model and its domain model, Customer1Example. AspectAdaptors are used to coordinate the application model aspecs and the domain model instance variables. A trigger event is used to signal the update. Instance Variables: customers <SelectionInList> list model of customers selectedCustomer <ValueHolder on: Customer1Example> current customer model updateTrigger <ValueHolder on: Boolean> model to update customer on true
</comment> <methods> Examples.Adaptor3Example <category>actions</category>
accept self updateTrigger value: true. self redisplayList.
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.Adaptor3Example <category>aspects</category>
accountID | adaptor bufferedAdaptor | adaptor := AspectAdaptor subjectChannel: self selectedCustomer. adaptor forAspect: #accountID. bufferedAdaptor := BufferedValueHolder subject: adaptor triggerChannel: self updateTrigger. ^bufferedAdaptor
address | adaptor bufferedAdaptor | adaptor := AspectAdaptor subjectChannel: self selectedCustomer. adaptor forAspect: #address. bufferedAdaptor := BufferedValueHolder subject: adaptor triggerChannel: self updateTrigger. ^bufferedAdaptor
customers ^customers
name | adaptor bufferedAdaptor | adaptor := AspectAdaptor subjectChannel: self selectedCustomer. adaptor forAspect: #name. bufferedAdaptor := BufferedValueHolder subject: adaptor triggerChannel: self updateTrigger. ^bufferedAdaptor
phoneNumber | adaptor bufferedAdaptor | adaptor := AspectAdaptor subjectChannel: self selectedCustomer. adaptor forAspect: #phoneNumber. bufferedAdaptor := BufferedValueHolder subject: adaptor triggerChannel: self updateTrigger. ^bufferedAdaptor
selectedCustomer ^selectedCustomer
updateTrigger ^updateTrigger
</methods> <methods> Examples.Adaptor3Example <category>initialize-release</category>
initialize customers := SelectionInList new. customers selectionIndexHolder onChangeSend: #changedCustomer to: self. selectedCustomer := Customer1Example new asValue. updateTrigger := false asValue.
</methods> <methods> Examples.Adaptor3Example <category>private</category>
redisplayList (self builder componentAt: #customers) widget invalidate.
</methods> <methods> Examples.Adaptor3Example <category>change messages</category>
changedCustomer | chosenCustomer | chosenCustomer := self customers selection. self selectedCustomer value: (chosenCustomer isNil ifTrue: [Customer1Example new] ifFalse: [chosenCustomer]). "Discard changes that were not OK'd." self updateTrigger value: false. "Enable/disable selection-sensitive widgets." #( #accountID #name #address #phoneNumber #ok) do: [ :componentName | (self builder componentAt: componentName) isEnabled: chosenCustomer notNil].
</methods> <methods> Examples.Adaptor3Example class <category>interface specs</category>
windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#FullSpec #window: #(#WindowSpec #label: 'Adaptor3Example' #min: #(#Point 506 201 ) #max: #(#Point 506 201 ) #bounds: #(#Rectangle 601 545 1107 746 ) ) #component: #(#SpecCollection #collection: #( #(#LabelSpec #layout: #(#Point 175 19 ) #label: 'Customer ID' ) #(#LabelSpec #layout: #(#Point 175 56 ) #label: 'Name' ) #(#LabelSpec #layout: #(#Point 175 93 ) #label: 'Address' ) #(#LabelSpec #layout: #(#Point 175 129 ) #label: 'Phone' ) #(#LabelSpec #layout: #(#Point 267 169 ) #label: 'BufferedValueHolders)' #style: #small ) #(#LabelSpec #layout: #(#Point 267 153 ) #label: '(These fields use' #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 ) #(#ActionButtonSpec #layout: #(#Rectangle 434 161 483 191 ) #name: #ok #flags: 40 #model: #accept #label: 'OK' #defaultable: true ) ) ) )
</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>