From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:46:52 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>ComboConversionExample</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none employeeChoices employee <imports></imports> <category>Examples-Help</category> <attributes> <package>ComboConversion-Example</package> </attributes> </class> <comment> Examples.ComboConversionExample
ComboConversionExample class demonstrates the use of a ComboBox widget to display a list of Employee objects. Browse the converting methods for examples of converting between a name that is displayable in the list and the domain object it identifies.
</comment> <methods> Examples.ComboConversionExample <category>aspects</category>
employee ^employee
employeeChoices ^employeeChoices
</methods> <methods> Examples.ComboConversionExample <category>converting</category>
employeeToString: anEmployee "Return a String corresponding to the given Employee. This String is the Employee's name, which will appear in the combo box's pull-down list and field." ^anEmployee name
stringToEmployee: aString "Return an Employee corresponding to the given String. If the String corresponds to the name of an Employee on the choices list, return that Employee. Otherwise, create a new Employee and add it to the list." | theEmp | theEmp := self employeeChoices value detect: [:each | each name = aString] ifNone: [nil]. theEmp isNil ifTrue: [theEmp := Employee new name: aString. self employeeChoices value addLast: theEmp]. ^theEmp
</methods> <methods> Examples.ComboConversionExample <category>initialize-release</category>
initialize "Initialize the combo box with a new, empty Employee. Then provide a List of choices containing several Employee instances. Put this List in a value holder." | aList anEmp | employee := Employee new initialize asValue. aList := List new. anEmp := Employee new initialize. anEmp name: 'Tami Hayes'; empNo: '341-2'; citizen: true. aList add: anEmp. anEmp := Employee new initialize. anEmp name: 'Leo Mazon'; empNo: '786-9'; citizen: false. aList add: anEmp. employeeChoices := aList asValue
</methods> <methods> Examples.ComboConversionExample class <category>interface specs</category>
windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#FullSpec #window: #(#WindowSpec #label: 'ComboConversionExample' #min: #(#Point 40 20 ) #bounds: #(#Rectangle 626 260 853 350 ) ) #component: #(#SpecCollection #collection: #( #(#ComboBoxSpec #layout: #(#LayoutFrame 0 0.171806 0 0.466667 0 0.832599 0 0.744444 ) #model: #employee #style: #default #isReadOnly: false #type: #object #comboList: #employeeChoices #readSelector: #stringToEmployee: #printSelector: #employeeToString: ) #(#LabelSpec #layout: #(#Point 38 13 ) #label: 'Select an employee:' ) ) ) )
</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>