Jump to: navigation, search

Difference between revisions of "MDT/UML2/Getting Started with UML2"

< MDT‎ | UML2
(New page: Copyright © 2004, 2011 International Business Machines Corp. and CEA === Summary === This article describes how to get started with the UML2 plug-ins for Eclipse. In particular, it give...)
 
Line 1: Line 1:
Copyright © 2004, 2011 International Business Machines Corp. and CEA
+
Copyright © 2004, 2011 International Business Machines Corp. and CEA  
  
=== Summary ===
+
=== Summary ===
  
This article describes how to get started with the UML2 plug-ins for Eclipse. In particular, it gives an overview of how to create models (and their contents) both programmatically and by using the sample UML editor.
+
This article describes how to get started with the UML2 plug-ins for Eclipse. In particular, it gives an overview of how to create models (and their contents) both programmatically and by using the sample UML editor.  
  
===== By Kenn Hussey and James Bruck =====
+
'''Kenn Hussey and James Bruck'''
 +
Last Updated: October 12, 2011
  
Last Updated: October 12, 2011
+
= Prerequisites  =
  
= Prerequisites =
+
To start using UML2 (and to follow along with the example in this article), you must have [http://www.eclipse.org/eclipse/ Eclipse], [http://www.eclipse.org/modeling/emf/?project=emf EMF], and [http://www.eclipse.org/modeling/mdt/?project=uml2 UML2] installed. You can either download the [http://www.eclipse.org/downloads/packages/eclipse-modeling-tools/indigosr1 Modeling Tools Package] or follow these steps:
  
To start using UML2 (and to follow along with the example in this article), you must have [http://www.eclipse.org/eclipse/ Eclipse], [http://www.eclipse.org/modeling/emf/?project=emf EMF], and [http://www.eclipse.org/modeling/mdt/?project=uml2 UML2] installed. You can either download the [http://www.eclipse.org/downloads/packages/eclipse-modeling-tools/indigosr1 Modeling Tools Package] or follow these steps:
+
#Download and run Eclipse.  
 
+
#Select the '''Help &gt; Install New Software…''' menu item.  
#Download and run Eclipse.
+
#Select a software site to work with, e.g., '''Indigo - http://download.eclipse.org/releases/indigo'''.  
#Select the '''Help &gt; Install New Software…''' menu item.
+
#Expand the '''Modeling''' tree item.  
#Select a software site to work with, e.g., '''Indigo - http://download.eclipse.org/releases/indigo'''.
+
#Select '''UML2 Extender SDK''' and press the '''Next &gt;''' button.  
#Expand the '''Modeling''' tree item.
+
#Review the install details and press the '''Next &gt;''' button.  
#Select '''UML2 Extender SDK''' and press the '''Next &gt;''' button.
+
#Accept the terms of the license agreement and press the '''Finish''' button.  
#Review the install details and press the '''Next &gt;''' button.
+
#Accept the terms of the license agreement and press the '''Finish''' button.
+
 
#Restart Eclipse when prompted to do so.
 
#Restart Eclipse when prompted to do so.
  
[GSWU2_Prerequisites.png]
+
[GSWU2_Prerequisites.png]  
  
At this stage, UML2 and all dependencies should be installed.
+
At this stage, UML2 and all dependencies should be installed.  
  
= Introduction =
+
= Introduction =
  
This article will walk you through the basics of creating models using UML2. Using a simple model (the ExtendedPO2 model, shamelessly “borrowed” from the EMF “bible” [1]) as an example, we’ll look at what’s involved in creating some of the more common elements that make up a model. For each type of element, we’ll first explain the creation process using the sample UML editor and then explore how to accomplish the same thing using Java code. The ExtendedPO2 model is shown below.
+
This article will walk you through the basics of creating models using UML2. Using a simple model (the ExtendedPO2 model, shamelessly “borrowed” from the EMF “bible” [1]) as an example, we’ll look at what’s involved in creating some of the more common elements that make up a model. For each type of element, we’ll first explain the creation process using the sample UML editor and then explore how to accomplish the same thing using Java code. The ExtendedPO2 model is shown below.  
  
[GSWU2_Introduction.gif]
+
[GSWU2_Introduction.gif]  
  
= Getting Started =
+
= Getting Started =
  
Before getting started, you’ll need to create a simple project in your workspace. This project will serve as the container for the model that we’ll create using the UML editor. To create a simple project for this article, follow these steps:
+
Before getting started, you’ll need to create a simple project in your workspace. This project will serve as the container for the model that we’ll create using the UML editor. To create a simple project for this article, follow these steps:  
  
#Select the '''Window &gt; Open Perspective &gt; Other…''' menu item.
+
#Select the '''Window &gt; Open Perspective &gt; Other…''' menu item.  
#Select the '''Resource''' perspective and press the '''OK''' button.
+
#Select the '''Resource''' perspective and press the '''OK''' button.  
#Select the '''File &gt; New &gt; Project...''' menu item.
+
#Select the '''File &gt; New &gt; Project...''' menu item.  
#Select the '''Project''' wizard from the '''General''' category and press the '''Next &gt;''' button.
+
#Select the '''Project''' wizard from the '''General''' category and press the '''Next &gt;''' button.  
 
#Enter a project name (i.e. “Getting Started with UML2”) and press the '''Finish''' button.
 
#Enter a project name (i.e. “Getting Started with UML2”) and press the '''Finish''' button.
  
At this point your workspace should look something like this:
+
At this point your workspace should look something like this:  
  
[GSWU2_GettingStarted.png]
+
[GSWU2_GettingStarted.png]  
  
OK, that should be enough to get us going with the UML editor. Now, to follow along with the programmatic approach to creating models, we’ll assume that you’ve created a class (named, say, “GettingStartedWithUML2”) in which you can write some code to construct our sample model. The code snippets we’ll show assume you’ve defined the following utility methods to give the user information on the program’s status:
+
OK, that should be enough to get us going with the UML editor. Now, to follow along with the programmatic approach to creating models, we’ll assume that you’ve created a class (named, say, “GettingStartedWithUML2”) in which you can write some code to construct our sample model. The code snippets we’ll show assume you’ve defined the following utility methods to give the user information on the program’s status:  
 
<pre>    public static boolean DEBUG = true;
 
<pre>    public static boolean DEBUG = true;
  
Line 59: Line 58:
 
         System.err.println(error);
 
         System.err.println(error);
 
     }
 
     }
</pre>
+
</pre>  
A static debug flag [GSWU2_tag1.gif] can be used to enable or disable verbose information printed to the system’s output stream [GSWU2_tag2.gif]. Errors will always be printed to the system’s error stream [GSWU2_tag3.gif].
+
A static debug flag [GSWU2_tag1.gif] can be used to enable or disable verbose information printed to the system’s output stream [GSWU2_tag2.gif]. Errors will always be printed to the system’s error stream [GSWU2_tag3.gif].  
  
 
All righty then! In each of the following subsections, we’ll look at how to create a different kind of UML element, starting with models.
 
All righty then! In each of the following subsections, we’ll look at how to create a different kind of UML element, starting with models.

Revision as of 22:44, 11 October 2011

Copyright © 2004, 2011 International Business Machines Corp. and CEA

Summary

This article describes how to get started with the UML2 plug-ins for Eclipse. In particular, it gives an overview of how to create models (and their contents) both programmatically and by using the sample UML editor.

Kenn Hussey and James Bruck Last Updated: October 12, 2011

Prerequisites

To start using UML2 (and to follow along with the example in this article), you must have Eclipse, EMF, and UML2 installed. You can either download the Modeling Tools Package or follow these steps:

  1. Download and run Eclipse.
  2. Select the Help > Install New Software… menu item.
  3. Select a software site to work with, e.g., Indigo - http://download.eclipse.org/releases/indigo.
  4. Expand the Modeling tree item.
  5. Select UML2 Extender SDK and press the Next > button.
  6. Review the install details and press the Next > button.
  7. Accept the terms of the license agreement and press the Finish button.
  8. Restart Eclipse when prompted to do so.

[GSWU2_Prerequisites.png]

At this stage, UML2 and all dependencies should be installed.

Introduction

This article will walk you through the basics of creating models using UML2. Using a simple model (the ExtendedPO2 model, shamelessly “borrowed” from the EMF “bible” [1]) as an example, we’ll look at what’s involved in creating some of the more common elements that make up a model. For each type of element, we’ll first explain the creation process using the sample UML editor and then explore how to accomplish the same thing using Java code. The ExtendedPO2 model is shown below.

[GSWU2_Introduction.gif]

Getting Started

Before getting started, you’ll need to create a simple project in your workspace. This project will serve as the container for the model that we’ll create using the UML editor. To create a simple project for this article, follow these steps:

  1. Select the Window > Open Perspective > Other… menu item.
  2. Select the Resource perspective and press the OK button.
  3. Select the File > New > Project... menu item.
  4. Select the Project wizard from the General category and press the Next > button.
  5. Enter a project name (i.e. “Getting Started with UML2”) and press the Finish button.

At this point your workspace should look something like this:

[GSWU2_GettingStarted.png]

OK, that should be enough to get us going with the UML editor. Now, to follow along with the programmatic approach to creating models, we’ll assume that you’ve created a class (named, say, “GettingStartedWithUML2”) in which you can write some code to construct our sample model. The code snippets we’ll show assume you’ve defined the following utility methods to give the user information on the program’s status:

     public static boolean DEBUG = true;

     protected static void out(String output) {

            if (DEBUG) {
                 System.out.println(output);
            }
     }

     protected static void err(String error) {
         System.err.println(error);
     }

A static debug flag [GSWU2_tag1.gif] can be used to enable or disable verbose information printed to the system’s output stream [GSWU2_tag2.gif]. Errors will always be printed to the system’s error stream [GSWU2_tag3.gif].

All righty then! In each of the following subsections, we’ll look at how to create a different kind of UML element, starting with models.