home *** CD-ROM | disk | FTP | other *** search
- Object subclass: #Customer
- instanceVariableNames: 'name number '
- classVariableNames: ''
- poolDictionaries: ''
- category: 'UIApplications-New'!
- Customer comment:
- 'This class defines "customers" for a phone book listing. Each customer has a name and
- a phone number.'!
-
-
- !Customer methodsFor: 'operators'!
-
- <= aCustomer
- ^self name <= aCustomer name! !
-
- !Customer methodsFor: 'printing'!
-
- printOn: aStream
- aStream nextPutAll: name , ' - ' , number displayString! !
-
- !Customer methodsFor: 'accessing'!
-
- name
- ^name!
-
- name: aName
- name := aName!
-
- number
- ^number!
-
- number: aNumber
- number := aNumber! !
-
- !Customer methodsFor: 'private'!
-
- show
- "internal display method"
-
- Transcript cr; show: name; show: ' - '; show: number displayString; cr! !
- "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
-
- Customer class
- instanceVariableNames: ''!
-
-
- !Customer class methodsFor: 'initialize'!
-
- name: aName number: aNumber
- "create a new customer (initialized)"
-
- |newCustomer|
-
- newCustomer := super new name: aName.
- newCustomer number: aNumber.
- ^newCustomer!
-
- new
- "create a new customer"
-
- |newCustomer|
-
- newCustomer := super new name: ''.
- newCustomer number: 0.
- ^newCustomer! !
-
- Model subclass: #PhoneBook
- instanceVariableNames: 'whitepages '
- classVariableNames: ''
- poolDictionaries: ''
- category: 'UIApplications-New'!
- PhoneBook comment:
- 'This class defines a phone book consisting of a list of Customers.'!
-
-
- !PhoneBook methodsFor: 'transactions'!
-
- addCustomer: aCustomer
-
- self whitepages add: aCustomer!
-
- deleteCustomer: aCustomer
-
- self whitepages remove: aCustomer! !
-
- !PhoneBook methodsFor: 'accessing'!
-
- whitepages
- ^whitepages! !
-
- !PhoneBook methodsFor: 'initialize'!
-
- initialize
- whitepages := SortedCollection new! !
-
- !PhoneBook methodsFor: 'private'!
-
- show
- "internal display method"
- Transcript cr.
- whitepages do: [:customer |
- Transcript show: customer name; show: ' - '; show: customer number displayString; cr.].
- Transcript cr! !
- "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
-
- PhoneBook class
- instanceVariableNames: ''!
-
-
- !PhoneBook class methodsFor: 'initialize'!
-
- new
- ^super new initialize! !
-
- ApplicationModel subclass: #PhoneBookInterface
- instanceVariableNames: 'phoneList phonebook phoneHolder '
- classVariableNames: ''
- poolDictionaries: ''
- category: 'UIApplications-New'!
- PhoneBookInterface comment:
- 'This class defines an interface for a phone book listing.'!
-
-
- !PhoneBookInterface methodsFor: 'aspects'!
-
- phoneHolder
- "This method was generated by UIDefiner. Any edits made here
- may be lost whenever methods are automatically defined. The
- initialization provided below may have been preempted by an
- initialize method."
-
- ^phoneHolder isNil
- ifTrue:
- [phoneHolder := Customer new asValue]
- ifFalse:
- [phoneHolder]!
-
- phoneList
- "This method was generated by UIDefiner. Any edits made here
- may be lost whenever methods are automatically defined. The
- initialization provided below may have been preempted by an
- initialize method."
-
- ^phoneList isNil
- ifTrue:
- [phoneList := SelectionInList with: phonebook whitepages]
- ifFalse:
- [phoneList]! !
-
- !PhoneBookInterface methodsFor: 'actions'!
-
- addCustomer
-
- |accepted newCustomer|
-
- phoneHolder := nil.
- accepted := self openDialogInterface: #dialogSpec.
- accepted ifTrue: [
- newCustomer := Customer name: phoneHolder value name
- number: phoneHolder value number.
- phonebook addCustomer: newCustomer.
- self phoneList list: phonebook whitepages]!
-
- deleteCustomer
-
- self phoneList selection isNil
- ifTrue: [^Dialog warn: 'Select a customer to delete.'].
- phonebook deleteCustomer: self phoneList selection.
- self phoneList list: phonebook whitepages!
-
- updateCustomer
-
- |accepted updatedCustomer|
-
- self phoneList selection isNil
- ifTrue: [^Dialog warn: 'Select a customer to update.'].
- self phoneHolder value: self phoneList selection.
- accepted := self openDialogInterface: #dialogSpec.
- accepted ifTrue: [
- phonebook deleteCustomer: self phoneList selection.
- updatedCustomer := Customer name: phoneHolder value name
- number: phoneHolder value number.
- phonebook addCustomer: updatedCustomer.
- self phoneList list: phonebook whitepages]! !
-
- !PhoneBookInterface methodsFor: 'initialize'!
-
- initialize
- phonebook := PhoneBook new! !
- "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
-
- PhoneBookInterface class
- instanceVariableNames: ''!
-
-
- !PhoneBookInterface class methodsFor: 'interface specs'!
-
- dialogSpec
- "UIPainter new openOnClass: self andSelector: #dialogSpec"
-
- <resource: #canvas>
- ^#(#FullSpec
- #window:
- #(#WindowSpec
- #label: 'Add/Update'
- #bounds: #(#Rectangle 631 473 1084 677 ) )
- #component:
- #(#SpecCollection
- #collection: #(
- #(#InputFieldSpec
- #layout: #(#Rectangle 172 23 292 49 )
- #model: #'phoneHolder number'
- #type: #number
- #formatString: '(000) 000-0000' )
- #(#InputFieldSpec
- #layout: #(#Rectangle 123 77 423 106 )
- #model: #'phoneHolder name' )
- #(#LabelSpec
- #layout: #(#Point 55 29 )
- #label: 'Phone Number:' )
- #(#LabelSpec
- #layout: #(#Point 9 84 )
- #label: 'Customer Name:' )
- #(#DividerSpec
- #layout: #(#Rectangle 16 136 434 140 ) )
- #(#ActionButtonSpec
- #layout: #(#Rectangle 82 158 140 192 )
- #model: #accept
- #label: 'OK'
- #defaultable: true )
- #(#ActionButtonSpec
- #layout: #(#Rectangle 302 156 362 194 )
- #model: #cancel
- #label: 'Cancel'
- #defaultable: true ) ) ) )!
-
- windowSpec
- "UIPainter new openOnClass: self andSelector: #windowSpec"
-
- <resource: #canvas>
- ^#(#FullSpec
- #window:
- #(#WindowSpec
- #label: 'ClemsonBell White Pages'
- #bounds: #(#Rectangle 618 490 1065 806 )
- #flags: 4
- #menu: #menuBar )
- #component:
- #(#SpecCollection
- #collection: #(
- #(#SequenceViewSpec
- #layout: #(#Rectangle 36 64 420 238 )
- #model: #phoneList )
- #(#ActionButtonSpec
- #layout: #(#Rectangle 98 254 162 288 )
- #model: #updateCustomer
- #label: 'Update'
- #defaultable: true )
- #(#ActionButtonSpec
- #layout: #(#Rectangle 279 255 342 290 )
- #model: #deleteCustomer
- #label: 'Delete'
- #defaultable: true )
- #(#LabelSpec
- #layout: #(#Point 36 29 )
- #label: 'Phone Listing' ) ) ) )! !
-
- !PhoneBookInterface class methodsFor: 'resources'!
-
- menuBar
- "UIMenuEditor new openOnClass: self andSelector: #menuBar"
-
- <resource: #menu>
- ^#(#Menu #(
- #(#MenuItem
- #label: 'File'
- #submenu: #(#Menu #(
- #(#MenuItem
- #label: 'Exit' ) ) #(1 ) #(#closeRequest ) ) )
- #(#MenuItem
- #label: 'Phone'
- #submenu: #(#Menu #(
- #(#MenuItem
- #label: 'Add' )
- #(#MenuItem
- #label: 'Update' )
- #(#MenuItem
- #label: 'Delete' ) ) #(3 ) #(#addCustomer #updateCustomer #deleteCustomer ) ) ) ) #(2 ) #(nil nil ) ) decodeAsLiteralArray! !
-
-