From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:46:21 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>Adaptor4Example</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none collectionModel customers selectedCustomer <imports></imports> <category>Examples-Help</category> <attributes> <package>Adapt4-Example</package> </attributes> </class> <comment> Examples.Adaptor4Example
Adaptor4Example class demonstrates adapting a list domain model, Customer2Example, to its application model. Browse the initialize method for adapting the domain model collection to a SelectionInList. Instance Variables: collectionModel <Customer2Example> holder for Customer1Example instances customers <SelectionInList> list model for Customer1Example instances selectedCustomer <ValueHolder on: Customer1Example> current Customer1Example selection
</comment> <methods> Examples.Adaptor4Example <category>aspects</category>
accountID | adaptor | adaptor := AspectAdaptor subjectChannel: self selectedCustomer. adaptor forAspect: #accountID. adaptor onChangeSend: #redisplayList to: self. ^adaptor
address | adaptor | adaptor := AspectAdaptor subjectChannel: self selectedCustomer. ^adaptor forAspect: #address
customers | list | list := AspectAdaptor subject: collectionModel. list forAspect: #customers. ^customers isNil ifTrue: [customers := SelectionInList new listHolder: list ] ifFalse: [customers]
name | adaptor | adaptor := AspectAdaptor subjectChannel: self selectedCustomer. adaptor forAspect: #name. adaptor onChangeSend: #redisplayList to: self. ^adaptor
phoneNumber | adaptor | adaptor := AspectAdaptor subjectChannel: self selectedCustomer. ^adaptor forAspect: #phoneNumber
selectedCustomer ^selectedCustomer
</methods> <methods> Examples.Adaptor4Example <category>private</category>
redisplayList (self builder componentAt: #customers) widget invalidate.
</methods> <methods> Examples.Adaptor4Example <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.Adaptor4Example <category>initialize-release</category>
initialize collectionModel := Customer2Example new. customers := SelectionInList new. customers listHolder: ( (AspectAdaptor subject: collectionModel) forAspect: #customers). self customers selectionIndexHolder onChangeSend: #changedCustomer to: self. selectedCustomer := Customer1Example new asValue.
</methods> <methods> Examples.Adaptor4Example <category>change messages</category>
changedCustomer | chosenCustomer | chosenCustomer := self customers selection. self selectedCustomer value: (chosenCustomer isNil ifTrue: [Customer1Example new] ifFalse: [chosenCustomer]). "Enable/disable selection-sensitive widgets." #( #accountID #name #address #phoneNumber) do: [ :componentName | (self builder componentAt: componentName) isEnabled: chosenCustomer notNil].
</methods> <methods> Examples.Adaptor4Example class <category>interface specs</category>
windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#FullSpec #window: #(#WindowSpec #label: 'Adaptor4Example' #min: #(#Point 20 20 ) #max: #(#Point 506 188 ) #bounds: #(#Rectangle 590 612 1096 800 ) ) #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 171 167 ) #label: '(This list is adapted from a raw collection)' #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>