 | Level: Intermediate Wayne Diu (wdiu@ca.ibm.com), Software developer, IBM Canada
06 May 2008 This article explains how you can customize the tooling that will be generated
for your UML profile. It assumes you are familiar with the basics of generating
and deploying tooling for profiles. If you are not familiar with this, please
read Part 1, "Generating and deploying tooling," before you continue
(see More in this series).
Before you start
The workspace from the launched instance will be called the runtime
workspace, while the workspace that contains your original profile and the generated
plug-in will be referred to as the original or development workspace.
- Delete the generated plug-in from your development workspace.
- Now right-click on the profile again, and select Generate Profile Tooling
from the drop-down menu.
Tip:
If you have generated models left over from a previous generation, the shortcut
check boxes on the first wizard page to generate palette, menu, and graphics
will be disabled. Settings from the previous invocation will be preserved by
the wizard. If you don't want to preserve the settings, delete the generated
model files before relaunching the wizard.
- If possible, check the option for customized shapes on the first
page, and click Next. (If the option is grayed out because you are
regenerating, you can always use the Select All buttons on the various wizard
pages.)
You are now in the Profile Tooling page (Figure 1).
- On this page, you select elements for which you want palette entries and
drop-down menus to be generated.
Figure 1. The Profile Tooling page
Tip:
The wizard is resizable if you are not satisfied with the default size.
The items on this page are all checked because the "All palette items"
and "All menu items" check boxes on the first page were checked. You
can customize each entry by checking or clearing the check boxes in the Name,
EClass, and Type table at the top of the page. This table is populated based
on the elements in your profile. It contains these entries:
- One or more entries for each metaclass extension of each stereotype. Observe
that if the metaclass extension was to an abstract EClass, it will not show
in the list. This is because you cannot create tooling for abstract types.
Concrete subtypes of the metaclass extension's EClass will automatically
be added. The EClass column will contain the UML EClass of the metaclass extension.
- An entry for each stereotype association and each metaclass association.
In these cases, the EClass column will contain either stereotype association
or metaclass association.
Note:
Profile class and enumerations are not supported in this release; therefore,
they do not show up in the wizard. Furthermore, items that cannot be reasonably
modeled by using the palette (such as a UML model) are filtered out.
The table at the bottom displays the properties of the element that you selected
in the table at the top. Observe how the available properties will change, based
on the select element. Now we'll examine some of these properties in detail.
Tip:
Merely setting the "Create menu item" and "Create palette entry"
properties to "Yes" will not generate the tooling if the element is
unchecked in the table at the top of the page. Similarly, merely checking the
element will not have any effect if both "Create menu item" and "Create
palette entry" properties are set to "No."
By default, all menu entries are added to a submenu titled "Add [Your
Application Name] Element," and they all belong to the same group within
that submenu. That group is called "defaultGroup." You may want to
separate items into further groups. Simply set the group name to be something
other than defaultGroup. The groups will be separated by separators in the drop-down
menu. In the example in Figure 2, the Crew, Agent, System, and Miscellaneous
menu items have been separated into different groups.
Figure 2. Items can be grouped together by specifying different group names
Creating palette groups
For the palette, you can contribute to the default palette or to some other
palette. As explained in Part 1, the name of the application is the default
palette group name. You can contribute to a new palette group by typing in another
palette group name. Connectors always appear below the tools to generate nodes. A separator is automatically generated between the node tooling and the connector tooling.
Choosing icons
If you leave the icon blank, the icon chosen from the profile will be used.
If there is no icon defined in the profile, the icon corresponding to the metaclass
extension will be used. For example, if there is a stereotype with a metaclass
extension of Actor, and there is no icon for the stereotype defined in the profile,
then the icon for the UML actor will be used.
Although in most cases it will make sense to accept the icon associated with
the profile element, there may be an odd case or two where you'll want to change
the icon. Yet, you will notice that, sometimes, the button to browse for icons
is grayed out. The button is grayed out when you're generating into a plug-in
that has not yet been created. This is because you can choose only icons from
the plug-in that you'll be generating into.
Therefore, create that plug-in first and add your icons into it before running
the wizard. Why? Because when you refer to icons in the plugin.xml file, you
can refer only to icons in the same bundle. (There are ways to get around this
by specifying settings in the genmodel, but that is for more advanced users.)
Note:
If you generate a metaclass association or a stereotype association, you need
to generate the tooling or shape for the stereotyped ends.
Profile Graphics wizard
The next page is the Profile Graphics wizard (Figure 3). This page is self-explanatory.
To generate custom edit parts, check the elements. To use the standard UML notation
of Rational modeling, simply clear the elements. No code will be generated for
the edit parts rendered using standard UML notation.
Figure 3. The Profile Graphics wizard
Note:
Code will be generated automatically for edit parts of metaclass associations
and stereotype associations if you choose to create the tooling for it.
Genmodel and code generation
Tip:
The genmodel is a standard EMF concept, and it is short for "Generator
Model." To get the most use out of it, you don't have to be a master of
EMF. All you need to know is that it's a model file that contains settings for
the code that will be generated and that the wizard will create the genmodel
from the mapping model. We will go into detail regarding modifying these files
later. The genmodel files for profile tooling have the epxgen extension.
When the wizard finishes, gmftool, gmfgraph, and epxmap files will always
be generated. These contain the parameters that you defined in the previous
steps of the wizard pertaining to the tooling, graphics, and mapping, respectively.
The gmftool and gmfgraph files conform to the standard Eclipse Graphic Modeling
Framework (GMF) model for code generation.
- In this step of the wizard, you have the options of generating a
genmodel
and also generating the code. You are probably wondering, why would I only
generate the gmftool, gmfgraph, and epxmap files? What good would it be
if I don't generate the code?
- Given that the
gmftool and gmfgraph files conform to the standard GMF
models, you can open the files by using the standard editors and tweak the
parameters before generating the code.
- In this case, you may invoke the drop-down (context) menu of the map file,
then choose Generate Profile Gen Model, and the
genmodel will be generated.
- You may adjust the parameters of the generated
genmodel in the same manner as the other generated model files. After you
have made the desired changes, you may invoke the context menu on the genmodel
and choose Generate Profile Tooling Code.
Tip:
If you clear the check box to generate the genmodel, the check box to generate
the code will also be cleared automatically. This is because the code is generated
from the parameters defined in the genmodel.
- Leave the two check boxes checked, and click Finish. Customized
tooling will be generated in the specified project.
Summary of generated tooling and graphics
The following table summarizes what the wizard generates.
Table1. Summary of the tooling and graphics generated by the wizard
| Profile Element | Create Palette Entries | Create Menu Items | Create Graphics |
|---|
| Metaclass extensions for stereotyped
elements that are links | Yes (default) or No | Not available | No (default) or Yes |
|---|
| Metaclass extensions for stereotyped
elements that are nodes | Yes (default) or No | Yes (default) or No | No (default) or Yes |
|---|
| Stereotype associations | Yes (default) or No | Not available | Yes if the palette entry or menu item was created for it, not
available otherwise |
|---|
| Metaclass associations | Yes (default) or No | Not available | Yes if the palette entry or menu item was created for it, not
available otherwise |
|---|
Next step
You have now learned how to generate customized profile tooling without writing
any code. If you are satisfied with the tooling that has been generated -- or
if you are simply not feeling very motivated -- you are ready to distribute
the generated plug-in. Otherwise, you may tweak the parameters in the model files and regenerate. If you choose to edit the generated Java code, note that your changes will be merged upon regeneration if you change the @generated tag (in the Javadoc) to @generated NOT.
Acknowledgements
The author thanks Dusko Misic and Maneesh Goyal for reviewing this article.
Resources Learn
- Read Part 1,
Custom domain modeling with UML Profiles: Part 1. Generating and deploying tooling,
by the same author.
- 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.
- 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
Discuss
About the author  | |  | Wayne Diu is a software developer at IBM Rational who worked on designing and implementing the Profile Integration feature. He has developed several other features for the Rational Modeling Platform such as the Browse Diagram infrastructure and was one of the developers responsible for the platformization of the metamodel integration framework. He has also worked on a diverse collection of other features such as printing, find and replace, and refactoring support.
|
Rate this page
|  |