Create a new UML Profile Tooling Plug-in Project, based on a new profile. When prompted, enter TestProfile for both the profile name and file name.
In the Project Explorer, navigate to the new profile and create a new Class Diagram.
Create a profile that uses stereotype associations. For the purposes of these instructions, we will use the profile illustrated below.
Figure 1. Profile
To summarize, the profile contains two stereotypes, A and B, which extend the metaclass Class. It also contains a stereotype, stereotypeName, which extends the metaclass AssociationClass. Finally, it contains a stereotype, lessThan, which extends the metaclass Association.
Save the profile.
Now right-click on the profile and select Generate Profile Tooling Model. When prompted, choose not to configure the advanced properties.
Once the tooling model is generated, it can be found under the Models folder in the Project explorer. Its name, when closed, will be TestProfile. When open, the model shows as <<ToolingModel, EditHelpers, Figures, L10N, Providers, Utils>> TestProfile, as seen below.
Figure 2. Tooling model
The following instructions demonstrate how to manually modify the tooling model to support the generation of tooling code for one specific stereotype on an association class. In this case, we will modify the tooling model to support the <<stereotype>> stereotypeName. Repeat these steps for every stereotype on an association class in your profile, replacing every instance of “stereotypeName” with your stereotype name. Remember: these steps are not necessary for stereotypes on Classes, or on Associations.
Create a new DefaultEditPart
Click on the <<Shapes>> folder in the tooling model. You can see the default edit parts for all of the existing components; you will be adding a new <<DefaultEditPart>> for the stereotypeName stereotype.
Components are added to the tooling model through diagrams. Right-click on the <<Shapes>> folder. Create a new Freeform diagram, by selecting Add Diagram > Freeform Diagram.
In the new diagram, use the DefaultEditPart tool from the Shapes palette (shown below) to add a new DefaultEditPart to the diagram. Name it stereotypeNameAssociationClass.
Figure 3. Shapes palette
The diagram should look like the figure below. The <<Shapes>> folder now contains the new DefaultEditPart.
Figure 4. Shapes diagram
Click on the <<Properties>> folder in the tooling model, and then click on the <<PropertySections>> folder. You can see the existing property sections; you will be adding a new <<PropertySection>> for the stereotypeName stereotype.
Right-click on the <<PropertySections>> folder. Create a new Freeform diagram.
In the new diagram, use the PropertySection tool from the Properties palette (shown below) to add a new PropertySection to the diagram. Name it <stereotypeName> AssociationClass.
Figure 5. Properties Palette
The diagram should look like the figure below. The <<PropertySections>> folder now contains the new PropertySection.
Figure 6. PropertySections diagram
Click on the <<Palettes>> folder in the tooling model, and then click on the <<PaletteTools>> folder. You can see the existing palette creation tools; you will be adding a new <<PaletteCreationToolEntry>> for the stereotypeName stereotype.
Right-click on the <<PaletteTools>> folder. Create a new Freeform diagram.
In the new diagram, use the PaletteCreationToolEntry from the Palettes palette (shown below) to add a new PaletteCreationToolEntry to the diagram. Now you need to name it <stereotypeName> AssociationClass.
Figure 7. Palettes palette
The diagram should look like the figure below. The <<PaletteTools>> folder now contains the new PaletteCreationToolEntry.
Figure 8. PaletteTools diagram
Click on the <<ElementTypes>> folder in the tooling model. You can see the existing element types; you will be adding a new <<SterotypeLinkSpecializationElementType>> for the stereotypeName stereotype.
Now right-click on the <<ElementTypes>> folder. Create a new Freeform diagram.
In the new diagram, use the StereotypeLinkSpecializationElementType tool from the Element Types palette (shown below) to add a new StereotypeLinkSpecializationElementType to the diagram. Name it <stereotypeName> AssociationClass.
A tip you can use to make this process go more smoothly is if you cannot immediately see the StereotypeLinkSpecializationElementType tool, explore the Element Types palette. StereotypeLinkSpecializationElementType is in the same palette stack as the StereotypeSpecializationElementType. When you do this, make sure to choose the right tool.
Figure 9. Element Types palette
The diagram should look like the figure below. The <<ElementTypes>> folder now contains the new StereotypeLinkSpecializationElementType.
Figure 10. ElementTypes diagram
In the Freeform diagram just created (in the <<ElementTypes>> folder, perform the following steps:
- From the
<<Shapes>>folder, drag the new <<DefaultEditPart>> stereotypeNameAssociationClass onto the diagram. - From the Shapes palette, use the EditPart elementType tool to connect the <<DefaultEditPart>> to the <<StereotypeLinkSpecializationElementType>>.
- From the
<<PropertySections>>folder, drag the new <<PropertySection>> onto the diagram. - From the Properties palette, use the PropertySection elementType tool to connect the <<PropertySection>> to the <<StereotypeLinkSpecializationElementType>>.
- From the
<<PaletteTools>>folder, drag the new <<PaletteCreationToolEntry>> onto the diagram. - From the Palettes palette, use the ToolEntry elementType tool to connect the <<PaletteCreationToolEntry>> to the <<StereotypeLinkSpecializationElementType>>.
The resulting freeform diagram is shown below.
Figure 11. Resulting freeform diagram
Ensure that the Properties view is open. If not, open it using the Window > Show View > Properties.
In the Freeform diagram (in the <<ElementTypes>> folder, click on the <stereotypeName> AssociationClass <<StereotypeLinkSpecializationElementType>>.
In the Properties view, select the Stereotypes tab, as shown in the graphic below.
Figure 12. Properties view
For each of the properties in the table below, click on the Value cell in the property tab and enter the relevant information.
Table 1. Properties
| Property | Value |
|---|---|
| adviceClassName | stereotypeNameAssociationClassEditHelperAdvice |
| displayName | <stereotypeName> AssociationClass |
| id | TestProfile.stereotypeNameAssociationClass |
| kind | com.ibm.xtools.uml.type.IStereotypedElementType |
| matcherClassName | stereotypeNameAssociationClassMatcher |
| specializesId | com.ibm.xtools.uml.associationClass |
To help ensure that the TestProfile profile is open, navigate to the Profiles folder in the Project Explorer and ensure that you can see the contents of the profile.
Back in the Stereotypes tab of the properties view for the <<StereotypeLinkSpecializationElementType>>, click on the browse button in the Value column of the stereotypeGenClass property.
In the Select Element dialog, click on the Modify Search Scope… button. Select the “Search entire workspace”.
In the Search tab, search for stereotypeName – it is in the TestProfile profile, as shown below.
Figure 13. Select Element dialog
Select the stereotypeName - TempProfile::stereotypeName and click OK.
The resulting properties should look like the figure below.
Figure 14. Resulting properties
Add the new stereotype to the Palette
In the Project Explorer, open the <<Palettes>> folder in the tooling model. Right-click on the <<PaletteStacks>> folder and create a new Freeform diagram.
From the <<PaletteGroups>> folder, drag the <<PaletteDrawer>> TestProfile from the Project Explorer onto the diagram.
Using the PaletteStack tool from the Palettes palette, create a new PaletteStack on the diagram.
Using the PaletteContainer children tool from the Palettes palette, connect the TestProfile palette drawer to the new palette stack.
From the <<PaletteTools>> folder, drag the <<PaletteCreationToolEntry>> <stereotypeName> AssociationClass from the Project Explorer to the diagram.
Using the PaletteContainer children tool from the Palettes palette, connect the new palette stack to the palette creation tool entry.
The Freeform diagram should look like the figure below.
Figure 15. Resulting PaletteStacks freeform diagram
Save all open diagrams and the tooling model.
Generate the profile tooling code. To do so, right-click on the tooling model and select Generate Tooling Code (this command will be in the bottom third of the context menu).
There should be no compile errors in the generated code. If there are errors, this may indicate that a step above has been missed, or an error has crept into your process. For instance, accidentally using the StereotypeSpecializationElementType tool instead of the StereotypeLinkSpecializationElementType tool will result in errors. In addition, if mistakes were made in the original profile, e.g., adding something to the profile and then deleting it from the diagram but not the profile itself, the resulting tooling could contain errors.
After the profile tooling code has been generated, the plug-in can be launched. The resulting tooling should look like the figure below.
Figure xxx. Requires a heading
The example model shows the difference between the stereotyped association and the stereotyped association class.
By following the steps outlined above, you can now customize your profile tooling model in order to permit the generation of tooling code for stereotypes on association classes. With the help of these instructions, you are now able to customize the profile tooling code for your own profiles, streamlining your development process for your own unique needs.
Learn
- For a detailed introduction to Profile
Tooling, see the whitepaper, Custom domain modeling with UML Profiles: Part1.
- Read Part 2, Custom domain modeling with UML Profiles: Part 2. Using the Profile Tooling wizard.
- To learn more about UML profiles, read Authoring UML Profiles: Part 1. Using Rational Software Architect, Rational Systems Developer, and Rational Software Modeler to create and deploy UML Profiles and Authoring UML Profiles: Part 2. Using Rational Software Architect, Rational Systems Developer, and Rational Software Modeler to manage change in UML Profiles by Dusko Misic (IBM developerWorks, April 2008).
- To learn more about deploying a plug-in on an update site, read How to Keep Up to Date, an Eclipse Corner article on the Eclipse.org Web site.
-
Learn about other applications in the IBM Rational Software Delivery Platform, including collaboration tools for parallel development and geographically dispersed teams, plus specialized software for architecture management, asset management, change and release management, integrated requirements management, process and portfolio management, and quality management.
-
Visit the Rational software area on developerWorks for technical resources and best practices for Rational Software Delivery Platform products.
-
Explore Rational computer-based, Web-based, and instructor-led online courses. Hone your skills and learn more about Rational tools with these courses, which range from introductory to advanced. The courses on this catalog are available for purchase through computer-based training or Web-based training. Additionally, some "Getting Started" courses are available free of charge.
-
Subscribe to the Rational Edge newsletter for articles on the concepts behind effective software development.
-
Subscribe to the IBM developerWorks newsletter, a weekly update on the best of developerWorks tutorials, articles, downloads, community activities, webcasts and events.
-
Browse the technology bookstore for books on these and other technical topics.
Get products and technologies
-
Download trial versions of IBM Rational software.
- Download these IBM product evaluation versions and get your hands on application development tools and middleware products from DB2®, Lotus®, Tivoli®, and WebSphere®.
Discuss
- Check out
developerWorks blogs and get involved in the developerWorks community.





