< Previous

Lesson 6: Create multiple template models

In this lesson, you create a second template model for the profile tooling.

Before you begin

Before you begin this lesson, create a new Profile Tooling plug-in project as described in lessons 1 and 2. Ensure that you generate the tooling model; however, you do not have to generate the tooling code.

About this task

By default, after you generate profile tooling code, one template model is associated with the profile. After you deploy the profile tooling plug-in, the template model is displayed in the New UML Model wizard. The name of the profile is listed in the Categories pane, and the default template is shown in the Templates pane. You can create additional template models.

To add a second template model to a profile tooling plug-in project:

Procedure

  1. In the Project Explorer view, under My Profile Tooling Project, expand Models, and then expand the «Wizards» Wizards package.
  2. Right-click «Template» My Profile Model and click Copy; then, right-click the «Wizards» Wizards package and click Paste.
  3. Select the «Template» Copy_1_My Profile Model model that was created when you clicked Paste.
  4. To view the properties of the model, click «Template» Copy_1_My Profile Model so that the heading is displayed in the Properties view, on the General page.
  5. Rename «Template» Copy_1_My Profile Model to Second Model.
  6. In the Properties view, on the Template page, make the following changes:
    1. Enter a template description, such as, This is a different template model. The template description is visible in the New UML Model wizard.
    2. Enter a name for the icon such as, SecondModel.gif.
    3. Modify the ID for this template by adding SecondModel to the end of the ID.
    4. Change the modelName from My Profile Model to Second Model; this name is visible in the Project Explorer view after the model is generated.
    5. Change the templateFile name from My_ProfileModel.emx to SecondModel.emx; this is the name of the actual model file.
  7. To view the properties of the profile, click «TemplateContribution» My Profile so that the heading is displayed in the Properties view; then, navigate to the TemplateContribution page.
  8. In the Properties table, select the template row; then click the ellipsis (...)button to open the template properties window. Notice that the template contribution is linked to the default template model.
  9. To add the second model, click Insert New Class, and browse to the new template model (Second Model) under the «Wizards>> Wizards package; select the template model and click OK.
    Tip: You can also use the template Properties window to reorder the templates. To reorder the items, delete all the elements in the table and add them back in the desired order.
  10. To return to the Properties view, click Close.
  11. Click File > Save.
  12. In the Project Explorer view, right-click the My Profile tooling model; then click Generate Tooling Code.

Results

The Second Model you created now resides in the Models package; consider adding model elements to the Main diagram of this model (for example, a note or other element that you want present in every new model created from this template).
Note: After you make changes to the model, you do not need to regenerate the tooling code.
Note: If you re-generate tooling code after you modify template models, by default, the models are over-written. If you want to avoid this action, in the Project Explorer view, right-click on the tooling model and select File > Properties On the Tooling Code Generation page, change the overwriting protocol for the template model. To ensure that no template models are overwritten, click Ignore. To be prompted for each template model, choose Ask.

After you complete these steps, when you deploy the profile tooling plug-in and create a new model based on this profile, the second template is available in the New UML Model wizard.

< Previous

Feedback