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
- In the Project Explorer view, under My Profile
Tooling Project, expand Models,
and then expand the «Wizards» Wizards package.
- Right-click «Template» My Profile Model and
click Copy; then, right-click the «Wizards»
Wizards package and click Paste.
- Select the «Template» Copy_1_My Profile Model model
that was created when you clicked Paste.
- 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.
- Rename «Template» Copy_1_My Profile Model to Second
Model.
- In the Properties view, on the Template page, make the
following changes:
- Enter a template description, such as, This
is a different template model. The template description
is visible in the New UML Model wizard.
- Enter a name for the icon such as, SecondModel.gif.
- Modify the ID for this template by adding SecondModel to
the end of the ID.
- Change the modelName from My Profile Model to Second
Model; this name is visible in the Project Explorer view
after the model is generated.
- Change the templateFile name from My_ProfileModel.emx
to SecondModel.emx; this is the name of the
actual model file.
- 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.
- 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.
- 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.
- To return to the Properties view, click Close.
- Click .
- 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.