VisualAge's quick form feature gives you a fast way to build a user interface for a nonvisual part. You often use quick forms to display the results of database queries or display parameters for external function parts.
Quick forms work by creating a visual part that best matches the data type of each attribute in the nonvisual part. For example, if you used quick forms to build a user interface for the timer part, a text-entry field would be created for the length attribute (because it's a numeric value) and a toggle part would be created for the repeat attribute (because it's a Boolean value).
By default, VisualAge uses Text parts to display most data types. Now that you've defined your own data types, you might want to change the visual part that matches your data type. Let's change the default for the Canadian province data type, by implementing a few methods in the MyCanadianProvince class.
Note: | In the next section, you will override methods that are not VisualAge APIs. It is possible that this code will not work in future versions of VisualAge. |
The first step is to tell VisualAge that the Canadian Province data type should have a quick form. You do that by implementing the following class method in MyCanadianProvince class:
abtAddDefaultViewForAttributeNamed: attributeName builderSet: aLoadedBuilderSet connectionOperations: aSetOfConnectionOperations at: aPoint ^self abtAddDefaultViewForAttributeNamed: attributeName label: attributeName builderSet: aLoadedBuilderSet connectionOperations: aSetOfConnectionOperations at: aPoint
Move the preceding method to your edit-time application, MyEditSamplePartsApp. If you do not implement it, VisualAge will not create a quick form at all for province objects.
Next, you tell VisualAge what kind of visual part to use for the quick form. This example uses a drop-down list that contains all the province names as the quick form. The following method creates the drop-down list, sets its items attribute, and connects the province object to the drop-down list's selectedItem:
abtAddDefaultViewForAttributeNamed: attributeName label: aString builderSet: aLoadedBuilderSet connectionOperations: aSetOfConnectionOperations at: aPoint | partBuilder defaultSize | partBuilder := AbtDropDownListComboBox newSubpartBuilder attributeSettingNamed: #items put: (MyCanadianProvince provinces). defaultSize := AbtDropDownListComboBox defaultEditSize. aLoadedBuilderSet builderNamed: nil put: partBuilder boundingBox: (aPoint extent: defaultSize). aSetOfConnectionOperations add: ((AbtAddConnectionOperation new: AbtAttributeToAttributeConnectionBuilder) sourceConnectionItemName: attributeName; targetBuilder: partBuilder; targetConnectionItemName: #selectedItem). ^defaultSize
Move the preceding method to your edit-time application, MyEditSamplePartsApp. Notice that it needs a list of province names. To create the list, add the following class method to MyCanadianProvince:
provinces "Answer a list of all the provinces" ^self mapping values asSortedCollection
Use the testing window you created earlier to test the new quick form.
A Drop-down List part should be added to your testing window. Test the part, and check that the drop-down list contains all the province names.