From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:49:16 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>Contact</name> <environment>Examples</environment> <super>Core.Object</super> <private>false</private> none name address email phone fax <imports></imports> <category>Examples-Help</category> <attributes> <package>ContactBrowser-Example</package> </attributes> </class> <comment> Examples.Contact
A simple object containing contact information. Used as part of the domain for ContactBrowser. Instance Variables: address <String> contact address email <String> contact e-mail fax <String> contact fax name <String> contact name phone <String> contact phone number
</comment> <class> <name>Contact2Browser</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none group contactsList book <imports></imports> <category>Help-Examples</category> <attributes> <package>ContactBrowser-Example</package> </attributes> </class> <comment> Examples.Contact2Browser
Contact2Browser, a variation of example Contact1Browser, minimizes coding of AspectAdaptors and change notification by making use of the application builder to build them from specifications. Instance Variables: book <ContactBook> book of ContactLists grouped by name contactsList <SelectionInList> list model of contacts from a selected ContactList group <ValueModel> current group selection
</comment> <class> <name>Contact1Browser</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none group contactsList contactChannel book <imports></imports> <category>Examples-Help</category> <attributes> <package>ContactBrowser-Example</package> </attributes> </class> <comment> Examples.Contact1Browser
A GUI to display information from a selected book of contacts using AspectAdaptors and PluggableAdaptors. Instance Variables: book <ContactBook> book of ContactLists grouped by name contactChannel <ValueHolder on: Contact> current Contact selected contactsList <SelectionInList> list model of contacts from a selected ContactList group <ValueHolder on: String> current group selection listChannel <ValueModel> current ContactList selection
</comment> <class> <name>ContactBook</name> <environment>Examples</environment> <super>Core.Object</super> <private>false</private> none listsCollection <imports></imports> <category>Examples-Help</category> <attributes> <package>ContactBrowser-Example</package> </attributes> </class> <comment> Examples.ContactBook
A book of ContactLists grouped by name. Used as part of the domain for ContactBrowser. Instance Variables: listsCollection <Dictionary> dictionary of ContactLists keyed by group name.
</comment> <class> <name>ContactList</name> <environment>Examples</environment> <super>Core.Object</super> <private>false</private> none contacts <imports></imports> <category>Examples-Help</category> <attributes> <package>ContactBrowser-Example</package> </attributes> </class> <comment> Examples.ContactList
A collection of Contact instances. Used as part of the domain for ContactBrowser Instance Variables: contacts <OrderedCollection of: Contact> collection of contacts
</comment> <methods> Examples.Contact <category>accessing</category>
address ^address
address: aValue address := aValue
email ^email
email: aValue email := aValue
fax ^fax
fax: aValue fax := aValue
name ^name
name: aValue name := aValue
phone ^phone
phone: aValue phone := aValue
</methods> <methods> Examples.Contact <category>initialize-release</category>
initialize name := address := email := phone := fax := String new
</methods> <methods> Examples.Contact <category>printing</category>
printOn: aStream ^aStream nextPutAll: self name.
</methods> <methods> Examples.Contact class <category>instance creation</category>
new ^super new initialize
</methods> <methods> Examples.Contact2Browser <category>initialize-release</category>
initialize book := ContactBook new. contactsList := SelectionInList new. group := String new asValue.
</methods> <methods> Examples.Contact2Browser <category>aspects</category>
contactChannel ^contactsList selectionHolder
contactsList ^contactsList
group ^group
groupsList "Collected from the keys in the ContactBook" ^(PluggableAdaptor on: book) getBlock: [:model | model groups asOrderedCollection] putBlock: [:model :adaptor | nil] updateBlock: [:model :adaptor :para | false]
</methods> <methods> Examples.Contact2Browser <category>changing</category>
changedGroup "When the selected group changes, change the list." contactsList list: (book listFor: group value) contacts asList
</methods> <methods> Examples.Contact1Browser <category>aspects</category>
address | adaptor | adaptor := AspectAdaptor subjectChannel: contactChannel. adaptor forAspect: #address. ^adaptor
contactsList ^contactsList
email | adaptor | adaptor := AspectAdaptor subjectChannel: contactChannel. adaptor forAspect: #email. ^adaptor
fax | adaptor | adaptor := AspectAdaptor subjectChannel: contactChannel. adaptor forAspect: #fax. ^adaptor
group "The currently displayed group from groupsList, or empty if no group is selected" ^group
groupsList "Collected from the keys in the ContactBook" ^(PluggableAdaptor on: book) getBlock: [:model | model groups asOrderedCollection] putBlock: [:model :adaptor | nil] updateBlock: [:model :adaptor :para | false]
name | adaptor | adaptor := AspectAdaptor subjectChannel: contactChannel. adaptor forAspect: #name. ^adaptor
phone | adaptor | adaptor := AspectAdaptor subjectChannel: contactChannel. adaptor forAspect: #phone. ^adaptor
</methods> <methods> Examples.Contact1Browser <category>changing</category>
changedContact "When a new contact is selected, update the information" contactChannel value: contactsList selection
changedGroup "When the selected group changes, change the list." contactsList list: (book listFor: group value) contacts asList. contactChannel value: Contact new.
</methods> <methods> Examples.Contact1Browser <category>initialize-release</category>
initialize book := ContactBook new. contactsList := SelectionInList new. contactChannel := Contact new asValue. group := String new asValue.
</methods> <methods> Examples.ContactBook <category>accessing</category>
collection ^listsCollection
groups ^self collection keys
listFor: aGroupString ^self collection at: aGroupString
</methods> <methods> Examples.ContactBook <category>initialize-release</category>
fillBook | list | list := ContactList new. list add: (Contact new name: 'Lois'; phone: '123-765-4321'; email: 'lois@worldnet.com'). list add: (Contact new name: 'Tim'; phone: '123-765-5432'; email: 'timboyer@worldnet.com'). list add: (Contact new name: 'Megan'; phone: '890-432-2345';email: 'meganboyer@worldnet.com'). listsCollection at: 'family' put: list. list := ContactList new. list add: (Contact new name: 'Mark'; phone: '199-642-9753'; email: 'markk@universe.net'). list add: (Contact new name: 'Brad'; phone: '567-434-4628'; email: 'bradm@msn.com'). list add: (Contact new name: 'Michelle'; email: 'rosette@earthlink.net'). listsCollection at: 'band' put: list.
initialize listsCollection := Dictionary new. self fillBook.
</methods> <methods> Examples.ContactBook class <category>instance creation</category>
new ^super new initialize
</methods> <methods> Examples.ContactList <category>accessing</category>
contact: aContactNameString ^contacts select: [ :x | x name = aContactNameString ]
contacts ^contacts
</methods> <methods> Examples.ContactList <category>initialize-release</category>
initialize contacts := OrderedCollection new
</methods> <methods> Examples.ContactList <category>adding - removing</category>
add: aContact ( aContact isKindOf: Contact ) ifTrue: [ contacts add: aContact ] ifFalse: [ Dialog warn: 'Only Contact instances are acceptable' ]
remove: aContact ( contacts includes: aContact ) ifTrue: [ ( Dialog confirm: 'Remove selected contact?' ) ifTrue: [ contacts remove: aContact ] ]
</methods> <methods> Examples.ContactList class <category>instance creation</category>
new ^super new initialize
</methods> <methods> Examples.Contact2Browser class <category>interface specs</category>
windowSpec "Tools.UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#{UI.FullSpec} #window: #(#{UI.WindowSpec} #label: #(#{Kernel.UserMessage} #key: #ContactsBrowser #defaultString: 'Contacts Browser' #catalogID: #examples) #bounds: #(#{Graphics.Rectangle} 800 600 1199 870 ) ) #component: #(#{UI.SpecCollection} #collection: #( #(#{UI.LabelSpec} #layout: #(#{Core.Point} 190 17 ) #name: #Label3 #label: 'Name' ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 190 62 ) #name: #Label4 #label: 'Address' ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 190 107 ) #name: #Label5 #label: 'email' ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 190 152 ) #name: #Label6 #label: 'Phone' ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 190 197 ) #name: #Label7 #label: 'Fax' ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 14 62 ) #name: #Label2 #label: 'Contacts' ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 14 17 ) #name: #Label1 #label: 'Contact Lists' ) #(#{UI.SequenceViewSpec} #layout: #(#{Graphics.Rectangle} 24 86 163 242 ) #name: #contacts #model: #contactsList #useModifierKeys: true #selectionType: #highlight ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.Rectangle} 202 39 374 62 ) #name: #name #model: #'contactChannel name' ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.Rectangle} 202 84 374 107 ) #name: #address #model: #'contactChannel address' ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.Rectangle} 202 129 374 152 ) #name: #email #model: #'contactChannel email' ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.Rectangle} 202 174 374 197 ) #name: #phone #model: #'contactChannel phone' ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.Rectangle} 202 219 374 242 ) #name: #fax #model: #'contactChannel fax' ) #(#{UI.ComboBoxSpec} #layout: #(#{Graphics.Rectangle} 24 39 163 62 ) #name: #lists #model: #group #callbacksSpec: #(#{UI.UIEventCallbackSubSpec} #valueChangeSelector: #changedGroup ) #comboList: #groupsList ) ) ) )
</methods> <methods> Examples.Contact1Browser class <category>interface specs</category>
windowSpec "Tools.UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#{UI.FullSpec} #window: #(#{UI.WindowSpec} #label: #(#{Kernel.UserMessage} #key: #ContactsBrowser #defaultString: 'Contacts Browser' #catalogID: #examples ) #bounds: #(#{Graphics.Rectangle} 512 384 911 654 ) ) #component: #(#{UI.SpecCollection} #collection: #( #(#{UI.LabelSpec} #layout: #(#{Core.Point} 190 17 ) #name: #Label3 #label: 'Name' ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 190 62 ) #name: #Label4 #label: 'Address' ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 190 107 ) #name: #Label5 #label: 'email' ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 190 152 ) #name: #Label6 #label: 'Phone' ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 190 197 ) #name: #Label7 #label: 'Fax' ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 14 62 ) #name: #Label2 #label: 'Contacts' ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 14 17 ) #name: #Label1 #label: 'Contact Lists' ) #(#{UI.SequenceViewSpec} #layout: #(#{Graphics.Rectangle} 24 86 163 242 ) #name: #contacts #model: #contactsList #callbacksSpec: #(#{UI.UIEventCallbackSubSpec} #valueChangeSelector: #changedContact ) #useModifierKeys: true #selectionType: #highlight ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.Rectangle} 202 84 374 107 ) #name: #address #model: #address ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.Rectangle} 202 129 374 152 ) #name: #email #model: #email ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.Rectangle} 202 39 374 62 ) #name: #name #model: #name ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.Rectangle} 202 174 374 197 ) #name: #phone #model: #phone ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.Rectangle} 202 219 374 242 ) #name: #fax #model: #fax ) #(#{UI.ComboBoxSpec} #layout: #(#{Graphics.Rectangle} 24 39 163 62 ) #name: #lists #model: #group #callbacksSpec: #(#{UI.UIEventCallbackSubSpec} #valueChangeSelector: #changedGroup ) #comboList: #groupsList ) ) ) )
</methods> "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>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>