< Previous | Next >

Lesson 3: Divide the palette for a profile

In this lesson, you divide a profile tooling palette.
Based on the model and profile constructs that you created in Lesson 1, the default palette should contain two stereotypes: <A> Actor and <B> Actor. The association between <A> Actor and <B> Actor appears as Ab. In this lesson, instead of using this default ordering, you divide the palette into two: one palette for the actor stereotypes, and one palette for the association between them.
Restriction: It is important to remember that the various palette elements relate to each other in a specific manner. For instance, a palette (<<Palette>>) may contain palette drawers (<<PaletteDrawer>>). A palette drawer may contain palette entries (<<PaletteCreationToolEntry>>) and palette stacks (<<PaletteStack>>). A palette stack may contain palette entries.

When customizing the profile tooling palette, it is possible to create relationships between the various palette elements that do not conform to the constraints listed above. No validation is provided, either during customization, or during the profile tooling code generation. Therefore, it is important to maintain the correct relationships between palette drawers, palette stacks, and palette entries in order to create valid code and avoid exceptions during code generation.

To divide the palette into two palettes:

  1. Return to the My Profile Tooling Project that you created in Lesson 1.
  2. In the Project Explorer view, open the My Profile tooling model, expand the <<Palettes>> My Profile package, expand the <<PaletteGroups>> Palette Groups package and click <<PalletteDrawer>> My Profile.
  3. If you had executed your profile tooling project in Lesson 2, you would have seen one palette drawer, called My Profile, containing three palette tools. You will rename this palette drawer, as well as create a new palette drawer.
  4. Profile tooling elements can be displayed in the diagram editor, which helps you see the relationships between elements. To create a diagram that shows the palette drawer and its contained elements, in the Project Explorer view, right-click <<PaletteDrawer>> My Profile; then click Add Diagram > Add PaletteDrawer Diagram. As the following figure illustrates, the diagram editor shows the My Profile palette drawer as a child of the My Profile palette, and contains references to the two stereotypes and one association in the profile.
    Diagram showing the profile tooling hierarchy.
    Note: You can perform some customization using the diagrams; although, it is often quicker and easier to perform the customization through the properties of a profile tooling element. Remember that associations in profile tooling do not behave as associations in, for instance, a class diagram. Therefore, you cannot simply move one end of one of the association in the previous figure to display an element as a child of a different palette drawer. Similarly, you can only delete an association from the diagram; you cannot delete the actual underlying association between the palette drawer and its child. The purpose of this tutorial is to show you how to use the properties view to perform these actions.
  5. To confirm the properties of the My Profile palette drawer, click it so that the heading is displayed in the Properties view.
    Note: If you do not have the Properties view open, click Window > Show View > Other > Properties.
  6. To rename the palette drawer, in the Properties view, on the General page, change the name in the Name field to Profile Stereotypes. After you rename the palette drawer, the diagram editor shows the new name: Profile Stereotypes.
  7. In this tutorial, you only want stereotypes in the palette drawer; therefore, you must remove the association. In the diagram editor, select the Profile Stereotypes palette drawer and then in the Properties view, select the PaletteDrawer properties tab. Notice that the children property has three entries that correspond to the two stereotypes and association that are listed as children of the drawer.
  8. In the Properties table, select the children row; then click the […] ellipsis button to open the children Properties window.
  9. To delete the <<PaletteCreationToolEntry>> A b value from the table, select it and click the red X to delete the element from the model; then click Close.
    Tip: You can also use the children Properties window to reorder the items in a palette. To reorder the items, delete all the elements in the table and then add them in the desired order.
    Note that the diagram did not update to show that the Profile Stereotypes palette drawer now contains two children. However, you can create a new diagram of the palette drawer to show the new structure, and you can add a new palette that contains all the profile tooling model elements.
  10. To add a new palette, in the Palette, under Palettes, click PaletteDrawer and drag it into the diagram editor. A new class called PaleteDrawerClass is added. The following figure shows the PaletteDrawer tool.
    Picture of a class stereotyped PaletteDrawer.
  11. The relationship between Profile Stereotypes and the PaletteDrawerClass class shows that the latter is defined “under” the former; this structure is more evident in the Project Explorer view. To keep the tooling model organized, in the Project Explorer view, drag the new PaletteDrawerClass class up to make it a child of the <<PaletteGroup>> stereotype.
  12. Rename the new palette drawer to: Profile Associations.
  13. Make the A b association a child of the new Profile Associations palette drawer:
    1. In the diagram editor, click Profile Associations palette drawer.
    2. In the Properties view, click the PaletteDrawer tab.
    3. Because the children Properties window shows no children, you must add one. Click the ellipsis button.
    4. In the children Properties window, click Add.
    5. In the Select Element window, browse to find <<PaletteCreatinToolEntry>> A b, then click OK. This step associates the new palette drawer with the actual palette.
  14. In the diagram editor, use the PaletteContainer children association to create an association between the My Profile Palette and the Profile Associations palette drawer.
  15. You have finished the customization of the palette in the tooling model.
  16. Click File > Save to save your work.
    Remember: To generate or regenerate the profile tooling code, in the Project Explorer view; then right-click the tooling model and click Generate Tooling Code.
When you deploy the profile tooling plug-in and create a new model based on this profile, your palette should look like the following figure:

Two palettes: a profile stereotypes palette and profile associations palette.

< Previous | Next >

Feedback