Skip to main content

Custom domain modeling with UML Profiles: Part 2. Using the Profile Tooling wizard

Wayne Diu, Software developer, IBM Canada
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.

Summary:  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).

View more content in this series

Date:  06 May 2008
Level:  Intermediate PDF:  A4 and Letter (911KB | 22 pages)Get Adobe® Reader®
Activity:  531 views

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.

  1. Delete the generated plug-in from your development workspace.
  2. 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.

  1. 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).

  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
Screen capture

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
Screen capture

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
Screen capture

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.

  1. 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?
  2. 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.
  3. 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.
  4. 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.

  1. 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 ElementCreate Palette EntriesCreate Menu ItemsCreate Graphics
Metaclass extensions for stereotyped elements that are linksYes (default) or NoNot availableNo (default) or Yes
Metaclass extensions for stereotyped elements that are nodesYes (default) or NoYes (default) or NoNo (default) or Yes
Stereotype associationsYes (default) or NoNot availableYes if the palette entry or menu item was created for it, not available otherwise
Metaclass associationsYes (default) or NoNot availableYes 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

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.

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=305876
ArticleTitle=Custom domain modeling with UML Profiles: Part 2. Using the Profile Tooling wizard
publish-date=05062008
author1-email=wdiu@ca.ibm.com
author1-email-cc=gclarke@us.ibm.com

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers