Getting Started


Defining a reusable visual part

The objective of this section is to familiarize you with creating reusable visual parts and using them with VAGen parts. This exercise focuses on the following tasks:

Creating an embeddable visual part

You will build a group box and use the Quick Form function to add labels and fields to it. Figure 100 shows the group box you will define.

Figure 100. Address Box

Figure addrbox not displayed.

First, you will create a new visual part (just as you did in "Creating a new visual part"). In the next section you will add this reusable visual part to your Customer Information window.

To build a Group Box using Quick Form, perform the following steps:

  1. From the VisualAge Organizer window, select Part>New.

    The VisualAge New Part window is displayed.

  2. In the Part class field, type the name ReusableAddressBoxView for your new part class.
  3. Select OK.

    The Composition Editor is displayed.

  4. Maximize the Composition Editor to get a larger work area.

    Now you can see the entire Window part.

  5. Select the default Window part with mouse button 2.

    The context menu is displayed.

  6. Select Delete.

    The Window is deleted.

Adding the Group Box

A Group Box places a rectangular box around a set of parts. It also allows you to move and use them as a single unit.

Complete the following steps to create the Address Group Box.

  1. Select the Canvas category artwork.

    The parts palette is refreshed to show all parts in the Canvas category.

  2. Select the Group Box part artwork and drop it on the free-form surface.

    A default size Group Box is displayed on your free-form surface.

  3. Select the Group Box (if it is not already selected).

    The Group Box corners have selection handles.

  4. Size the Group Box to fit into the Customer Information window created in Chapter 18, Building a visual part using VisualAge Generator Developer on Smalltalk.

    The Group Box is resized.

  5. Update the label of the Group Box. To do this, place the mouse pointer on the text Group Box and press Alt+mouse button 1.

    The Group Box label becomes blocked for deletion in text edit mode.

  6. Type Address and then click anywhere except on the label.

    Address is now the label of the Group Box.

Populating the Address Group Box

To add parts to the Group Box, you will use Quick Form just like you did in Chapter 18, Building a visual part using VisualAge Generator Developer on Smalltalk.

Complete the following steps to add parts to the Address Group Box.

  1. From the parts palette, select the VAGen parts category Figure vgcat not displayed.. Select a VAGen record part Figure iconrecd not displayed. and drop it on the free-form surface.

    The Add Subpart window is displayed.

  2. From the drop-down list, select CUSTOMER; then select OK.

    The CUSTOMER record part is displayed on the free-form surface.

  3. Select the CUSTOMER record part with mouse button 2.

    The context menu is displayed.

  4. Select Quick Form.

    A list of data items is displayed.

  5. Select CUSSTREET and move the mouse pointer (cross-hair) to the appropriate area in the Address Group Box.

    The Street Label part and a Text part are added to the Group Box. An attribute-to-attribute connection is created, and the data type is set using the CUSSTREET data item definition.

  6. Repeat the above step for CUSCITY, CUSSTATE, and CUSZIP.
  7. Click mouse button 2 on the CUSTOMER record part. From the context menu, select Delete. When the warning message is displayed, select OK.

    The record and all the connections are now deleted. You do not need the attribute-to-attribute connections in this scenario. Later, you will promote these fields to the public interface so that you can define connections to them in any view where you embed this address box.

Laying out the Group Box

Lay out the Label and Text parts in the Group Box as shown in Figure 100. Remember, to size a part, select it with mouse button 1, place the mouse pointer on one of the selection handles, and move the mouse while holding down mouse button 1. For more detailed information about laying out visual parts, see "Arranging visual parts".

Promoting features of the reusable part

If you want to access any information in the ADDRESS Group Box from another view, you must add the appropriate features to the public interface. In this case, the features needed are the attributes for the Text parts. In this section, you will add attributes for all four Text parts (Street, City, State, and Zip) to the public interface.

For more complete information on topics covered in this section, refer to the VisualAge for Smalltalk User's Guide.

To promote part features to the public interface, perform the following steps:

  1. Select the Street Text part with mouse button 2. From the context menu, select Promote Part Feature.

    The Promote features from window is displayed.

  2. On the Promote features from window, from the Attribute column, select object.

    textCUSSTREETObject is displayed in the Promote feature name field.

  3. Change the Promote feature name to streetobject and select Promote.

    Now other parts can reference this Text part by the attribute name. By selecting object, you are adding the actual value of the data that the part represents, including all customized parameters, such as currency symbols or numeric separators. Selecting string would only have added a reference to the input string typed into the field.

  4. Select OK to accept your changes and close the Promote features from window.
  5. Repeat the above steps for the City, State, and Zip Text parts, using the names cityobject, stateobject, and zipobject, respectively.

    The object attribute feature of each of the four Text parts has been added to the public interface. Now these attributes can be accessed by other parts.

  6. Select File>Save Part.

You can also do this same task from the Promote tab in Public Interface Editor. Refer to the VisualAge for Smalltalk User's Guide more information on using the Public Interface Editor.

Now you are ready to embed the address box in your tutorial view and add VAGen logic parts.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]