Chapter 4: Working with Templates
UMLStudio notation template files have a .not ending (e.g., UML.not). A template stores information
about the diagrams and symbols of a notation. Templates are referenced by projects. For example, a
project that uses the UML notation will reference the UML.not template.
Unlike project files, you cannot directly open a template file. (If you open (or double-click) a template
file in the Windows Explorer, UMLStudio will create a new project based on that template for you.)
However, you can indirectly view and edit the contents of a template via any project that is based on
that template.
When you open a project, the explorer pane contains a template folder directly below the Models folder, that
gives you access to the template. This folder has the same name as the notation template on which the
project is based (e.g., UML.not).
As of version 2.0, a user-specified default template is used for creating a new project when UMLStudio
is first launched. The shipped software uses UML.not as the default template. The user can specify the
default template using the Tools:Options dialog.
A template file contains the following:
- The definition of 8 diagram types. Each diagram type specifies the symbols
(links and places) that can be used to create diagrams of that type.
- The definition of 10 or more link tools. Each link tool is defined as a model consisting solely of
primitive drawables.
- The definition of 14 or more place tools. Each place tool is also defined as a model consisting solely
of primitive drawables.
- An icon for each of the tools.
The tool definitions provided by a template correspond to the tools in the custom toolbar of
UMLStudio. When you use a tool in the custom toolbar to create a drawable, UMLStudio creates the
drawable using the definition provided by the template.
If you modify the tool definition in a template, your changes will be immediately reflected in an open
project that is based on that template.
Because templates separate the definition of a notation from the definition of the drawings created in
that notation, they provide you with considerable flexibility. You can, for example, quickly and
consistently change your diagrams by simply adjusting the template.
In addition to the templates shipped with UMLStudio, you can design your own templates and share them
with others. Templates are a great way of enforcing consistency of drawings in an organization.
The link and place tools of a template fall into 3 categories:
- Standard tools are those that are directly visible in the custom toolbar.
Each template provides 10 standard link tools and 14 standard place tools.
These tools can be customized, but they cannot be deleted.
- Extra tools are those that are available via the extra links menu
and the extra places menu in the custom toolbar.
New extra tools can be added by the user, and existing ones in the template can be customized or deleted.
- Stereotypes are variations of standard and extra tools.
If a standard tool has defined stereotypes, then these will appear in a small popup menu when the
cursor is positioned on the tool in the custom toolbar.
If an extra tool has defined stereotypes, then these will appear in the extra menu, directly below the
extra tool itself.
A diagram type is designed as a collection of symbols (links and places) that can be used to create
diagrams of that type. Any combination of the link and place tools provided by the template can be used
to define a diagram type.
When the user creates a diagram of a given type, only those link and place tools that are part of the
diagram type will be available for editing. The other tools will be disabled in the
custom toolbar.
UMLStudio supports 8 diagram types:
- The default type represents unrestricted diagrams used for arbitrary modeling.
- The class type represents diagrams that depict class relationships.
- The use-case type represents diagrams that depict actors, use-cases, and their relationships.
- The sequence type represents diagrams that depict interactions among objects in time sequence.
- The collaboration type represents diagrams that depict message exchanges between objects.
- The state type represents diagrams that depict the sequence of states an object goes through during its life-time.
- The activity type represents special state diagrams in which the states represent actions.
- The implementation type represents diagrams that depict the implementation structures of a system.
The definition of a diagram type can be modified through its
property sheet.
To view the design of a link tool, select its button from the custom
toolbar and press the Tool Design Edit button
(alternatively, you can directly select the tool’s model in the explorer pane).
A magnified view of the link tool’s design is displayed in the drawing pane, as a model that is
partitioned into 3 areas. The boundaries of these 3 partitions appear as dashed red lines.
For example, the design of the UML Uni-Composite link tool looks like this:
Drawables that you place in the left partition specify the link attachment at the source. Similarly,
drawables that you place in the right partition specify the link attachment at the destination. Drawables
that you place in the middle partition specify the middle attachment of the link. The default size of the
link is shown in the locater page of the info pane.
You can drag the knob at the bottom-right corner of this view to change the default size:
If you want the link to have an editable label, place an editable text box primitive in the middle
attachment. If you put more than one editable text box in the middle attachment, only one of them will
be used.
When designing or modifying a link tool model, you should ensure that each drawable appears completely
within one of the 3 partitions. A drawable that overlaps the partition boundaries is regarded as not
belonging to the link and is therefore ignored by UMLStudio.
To view the design of a place tool, select its button from the custom
toolbar and press the Tool Design Edit button
(alternatively, you can directly select the tool’s model in the explorer pane).
A magnified view of the place tool’s design is displayed in the drawing pane.
The boundary of this model appears as dashed red lines.
For example, the design of the UML Actor place tool looks like this:
The default size of the place tool is shown in the locater page of
the info pane. You can drag the knob at the bottom-right corner of this view to change the default size:
If you want the place to have an editable name, place an editable text box primitive in its model. If you
put more than one editable text box in the place model, only one of them will be used.
It is generally unusual for a place tool not to have an editable name. In such a case, places created
using the tool will still have proper names; this is because every place has a named master. However,
you will not be able to directly edit the place name, but you will be able to edit the name via the
place’s property sheet.
When you have created a new tool model or changed the design of an existing tool,
you should also change the design of its icon so that the new design is apparent to the users by simply
looking at the custom toolbar.
To view the icon design of a custom tool, select its button from the custom
toolbar (if it’s not already selected) and press the
Tool Icon Edit button.
A magnified view of the tool’s icon design is displayed in the drawing pane.
For example, the icon design of the UML Actor place tool looks like this:
The default size of the icon is shown in the locater page of
the info pane:
You can use the primitive tools to draw pixels into the icon design. Holding down the control key while
drawing causes the pixels to be erased instead.
As of version 5.0, each tool model has user-defined semantics. This is denoted by the Semantics combo
in the property sheet of the tool model.
A place tool’s semantics may take one of the following values:
- Unspecified, which means that the place semantics is unspecified.
- Class, which means that the place behaves like a class, and may have attributes, methods, and exceptions.
- Package, which means that the place represents a package of other things (i.e., is a place holder).
A link tool’s semantics may take one of the following values:
- Unspecified, which means that the link semantics is unspecified.
- Inheritance, which means that the link’s source place inherits (i.e., is derived) from its target place.
- Realization, which means that the link’s source place realizes (i.e., implements) its target place.
- Instantiation, which means that the link’s source place is an instantiation of its target place.
- Composition, which means that the link’s source place contains its target place.
- Aggregation, which means that the link’s source place references its target place.
- Association, which means that the link’s source and target places are somehow associated.
- Control-Flow, which means that execution control flows from the link’s source place to its target place.
- Data-flow, which means that data flows from the link’s source place to its target place.
- Transition, which means that there is a state transition from the link’s source place to its target place.
- Dependency, which means that the link’s source place depends on its target place.
- Attachment, which means that the link’s source place is attached to its target place.
The specific semantics of a tool has implications, especially for code generation and reverse engineering.
Specifically:
- If a place has class semantics, code generation will result in a class of the same name.
Conversely, reverse engineering of a class will result in a place created with the first tool in the template
that has class semantics.
- If a place has package semantics, code generation will (if appropriate) use it for determining the
package hierarchy (e.g., in Java). Conversely, reverse engineering Java code will result in a diagram
hierarchy that uses the first place in the template that has package semantics to depict the hierarchy.
- If a link that has inheritance semantics connects a class B to a class A,
the code generated for class B will have A as a base class. Conversely, reverse engineering
of a class B derived from A, will result in a diagram that uses the first link in the template that has
inheritance semantics to depict the relationship.
- If a link that has realization semantics connects a class B to an interface A,
the Java code generated for class B will implement interface A. Conversely, reverse engineering
of a Java class B that implements an interface A, will result in a diagram that uses the first link in the template that has
realization semantics to depict the relationship.
- If a link that has composition semantics connects a class B to a class A,
the code generated for class B will have a data member of type A. Conversely, reverse engineering
of a class B that has an object of type A as a member, will result in a diagram that uses the first link in the template that has
composition semantics to depict the relationship.
- If a link that has aggregation semantics connects a class B to a class A,
the code generated for class B will have a data member that is a reference to A. Conversely, reverse engineering
of a class B that has a reference to an object of type A as a member, will result in a diagram that uses the first link in the template that has
aggregation semantics to depict the relationship.
This section describes the generic tasks which you would do when manipulating existing notation templates
or designing new ones.
- Choose File:New to create a new project using an existing
template (choose the template that’s closest to what you want).
- Modify the template as desired (see below).
- Choose File:Save Template to save the modified template
under a new name.
- You can discard the project or, if you want to try out your new template, proceed to create
models in it.
- Choose File:New to create a new project using the template you
want to modify.
- Modify the template as desired (see below).
- Choose File:Save Template to save the modified template
under the same name.
- You can discard the project or, if you want to try out the modified template, proceed to create
models in it.
- In the Diagrams subfolder of the template folder, select the diagram type you want to modify. The
property sheet for the diagram type will appear.
- Edit the diagram type properties as desired. The second tab page (Tools) allows you to select the
symbols that should be supported by the diagram type.
- If you want to create a new link tool model, first select a link (any link) in the custom toolbar,
or select the Template\Links folder in the explorer pane.
- If you want to create a new place tool model, first select a place (any place) in the custom toolbar,
or select the Template\Places folder in the explorer pane.
- Choose Model:New Tool Model.
A new tool model is created and added to the Template\Links or Template\Places folder.
The tool’s icon is added to the extra links menu
or the extra places menu in the custom toolbar.
The tool model is automatically selected and its design is displayed in the drawing pane.
The new tool model is initially named Untitled but can be renamed using the model
property sheet.
The tool design is initially empty, so that you can populate it with drawables as you wish.
- Select the tool for which you want to create a stereotype in the custom toolbar, or
select its model in the explorer pane.
- Choose Model:New Stereotype Model.
A new stereotype model is created and added as a child of the tool’s model in the explorer pane.
The tool’s icon is added to the custom toolbar. If the parent tool is a standard tool then positioning the
cursor on the tool button will display a popup menu that contains the stereotype.
If the parent tool is an extra tool, then the stereotype appears as an icon underneath the parent
tool’s icon in the extra popup menu.
The stereotype model is automatically selected and its design is displayed in the drawing pane.
The new tool model is initially named Untitled but can be renamed using the model
property sheet.
The stereotype design is initially empty, so that you can populate it with drawables as you wish.
- You can only delete extra tool models and stereotype models. You cannot delete any of
the standard tools.
- Select the tool/stereotype model in the explorer pane (with the template hierarchy).
- Choose Edit:Delete or press the delete key.
You will be asked to confirm the delete.
- Select the tool you want to modify from the custom toolbar.
- Press the Tool Design Edit button in the custom toolbar.
The nominated tool’s model is
automatically selected in the explorer pane and the model is displayed in the drawing pane.
- Edit the model as desired. Editing a tool model is essentially the same as editing a normal
model. The only notable restriction is that you can only use primitive tools within a tool model
(you cannot use places, links, or tags).
Tip: While editing a tool model or tool icon, you can quickly go back to the last custom model you were
working with by pressing the Model Edit button in the custom toolbar.
- Select the tool you want to modify from the custom toolbar.
- Press the Tool Icon Edit button in the custom toolbar.
A magnified view of the tool’s icon is displayed in the drawing pane.
- Edit the icon as desired using the primitive tools available.
You can also copy, cut, paste, and delete tool icons. If the icon you’re designing is similar to another
one in this or another template, simply go to that icon, copy it, go back to the icon you’re editing, and
paste it there. To completely erase an icon so that you can redesign it, use the
Edit:Delete command.
When using clipboard operations, make sure the drawing pane is the active pane. To make the drawing pane
active, simply click the mouse pointer inside it.
Changes to a tool’s icon will not be reflected in the custom toolbar until you switch to another model.
- Bring up the tool model’s property sheet.
You can do this in two ways:
- Select the tool in the explorer pane and then choose
Edit:Properties, or
- Double-click the tool model’s icon in the explorer pane.
- Make your changes and press the OK button.
- Make sure that the tool’s model is the current model.
- Drag the corner knob of the tool’s default size in the locater page
of the info pane to the desired size.
- Make sure that the tool’s model is the current model.
- Edit the model’s drawables as you would do with a normal model.
- Make sure that no drawable in the link tool’s model is selected.
- Selected the desired color from the line color menu
and/or the desired line style from the line style menu.
- Choose File:Switch To Template.
This will display a dialog box containing the list of available templates.
- Select the template you want to switch to and press the OK button.
The template is immediately applied to the project. This may affect the appearance of the models. The
project will be based on the new template from now on.
Table of Contents | Chapter 3 | Chapter 5
Copyright © 1996-2010 PragSoft Corporation (www.pragsoft.com)