Version 0.9
Copyright © 2008 - 2009 Lars Vogel
28.12.2009
| Revision History | ||
|---|---|---|
| Revision 0.1 - 0.3 | 017.12.2007 | Lars Vogel |
| Create first versions | ||
| Revision 0.4 | 09.10.2008 | Lars Vogel |
| Updated to Eclipse 3.4 | ||
| Revision 0.5 | 14.02.2009 | Lars Vogel |
| Changed the project name, minor rework | ||
| Revision 0.6 | 29.05.2009 | Lars Vogel |
| Updated to Eclipse 3.5 | ||
| Revision 0.7 | 16.06.2009 | Lars Vogel |
| Added Multiplicity | ||
| Revision 0.8 | 21.09.2009 | Lars Vogel |
| How to export images | ||
| Revision 0.9 | 28.12.2009 | Lars Vogel |
| Improved description of update site | ||
Table of Contents
Eclipse supports the creation of UML2 diagrams via UML2 Tools project. UML2 Tools is a set of GMF-based editors for viewing and editing UML models.
The Unified Modeling Language (UML) is a visual language for capturing software designs and patterns. The first version of UML was defined 1994 and released by the Object Management Group (OMG) in 1997 as UML v.1.1. The syntax and a semantic of UML is defined by the OMG.
The basic building block for UML is a diagram. UML divides diagrams into structural diagrams and behavioral diagrams
The latest version UML 2 has the target to add the ability for modelers to capture more system behavior. UML 2 has the target to support model driving architectures (MDA). MDA has the target to create automatically a software program from several models.UML is intended to be extended. The formal way to extending a UML model is via a UML profile. A UML profile a a collection of UML stereotypes and constraints on elements that map the generic UML to a specific problem domain or implementation. For example a UML profile can be used to support the modeling of J2EE software components.
Install the following plugin
UML2 Tools SDK
The UML2 Tools can be found under "Modeling" in the update manager.
Install the plugins via the update manager of eclipse (please see Using the update manager of Eclipse for details).
The following example will create a class diagram with the UML2 tools.
Create a new java project "de.vogella.uml2.first" and a new folder "uml2". Right click on the folder "uml2", select New-> Other. Select UML 2.1 Diagrams and then the "class diagram" as the type.
In my example I will create a class diagram.

Define the name of you diagram as "myclasses.umlclass".

Press finish.
From the "Palette" you can now select the type of element you would like to create. For example Select "Class" and click in the whitespace to create the UML representation of a class.

The result should look like the following.

The properties view allow you to change the attributes of the elements. To open the properties view select a class, right mouse click and select "Show Properties View". You can then for example set the "Is Abstract" flag to true to create a abstract class.
If you select your element a menu will be displayed which allows you to add property (fields) and operations (methods).

If you select your UML diagram and click on the outgoing arrow you can create associations.

Save your UML diagram.

You can maintain the relationship multiplicity between two classes by clicking on the association and via the properties lower / upper in the property view.

UML2 Tool let you choose if you want to use the ball-and-socket notation (interface is displayed as a circle) or UML stereotype <<interface>> for the representation of an interface. Simple right click on the interface and select "Show as class" of "Collapse to circle".

A class is represented by a retangular box divided into compartments. A Compartment is an area in the box to write information. The first compartment holds the name , the second holds the attributes and the third is used for the operations .

Any compartment can be hidden to improve readability of the diagram.
UML suggests that a class name:
Starts with a capital letter
is centered in the top compartment
is written in a boldface font
is written in italics if the class is abstract
Attributes specifies details of a class and can be simple types or objects.
Attributes can be defined inlined (as part second compartment of the diagram of the class) or as relationship.
Inlined attributes are placed in the second compartment of the class. The notation for inline attribute is:
visibility name: type {multiplicity} {=default}
Table 1.
| Element | Values | Description |
|---|---|---|
| visibility |
+ - # ~ |
public Attribute private Attribute protected Attribute package Attribute |
| name | myName | Name of the attribute following the camelCase notation |
| type | Class name, interface or primitive types, e.g. int | |
| multiplicity | Optional, if not specified then it is assumed to be 1, * for any value, 1,..,* for ranges. | |
| default | Optional, default value of the attribute |

To model attributes by relationship you use an association relationship between the class which represents the attribute and the class containing the attribute.

Interfaces are indicated via the stereotype <<interface>> .

Relationships can be expressed via the ball-and-socket notation.

UML defines several ways of representing relationships between classes.
Read as "..has a.." association between classes. Drawn as a straight line between the two classes. Does not mean that the classes are owned by one, other classes may use the connected class too.

Strong relationship between classes to the point of containment. Read as "..is part of..". If the owning instance is destroyed then normally (not necessarily) the linked object is destroyed too.

Read as ".. is a..". Use to express inheritance. Represented by a solid line and a hollow triangular arrow. For example the following code could be expressed with the following diagram.
package animals;
public abstract class Animal {
}
package animals;
public class Frog extends Animal {
}

MDA is the approach in which models are automatically translated into complete, deployable, running applications.
MDA defines several levels for these models, Platform independent models, platform specific models and code models.
Represents the business model to be implemented and can be described via UML. The PIM describes the processes of the business model and the structure of the system. The PIM does not specific operating system, programming language and hardware.
The PSM is responsible to specify the technical details to implement the PIM, e.g. the operating system, the programming language. In case several realizations / implementations for a PIM are possible then several PSM are formulated.
Thank you for practicing with this tutorial.
I maintain this tutorial in my private time. If you like the information please help me by using flattr or donating or by
|
Before posting questions, please see the vogella FAQ . If you have questions or find an error in this article please use the www.vogella.de Google Group . I have created a short list how to create good questions which might also help you. .
www.omg.org/uml Home of the standard body for UML
http://wiki.eclipse.org/MDT-UML2Tools Wiki about the UML2 Tool project
http://www.eclipse.org/modeling/ Eclipse Modeling Project