Using MyEclipse: UML


Laurie Williams, Ben Smith and Sarah Smith
CSC 326 - Software Engineering
Department of Computer Science
North Carolina State University

Back to Software Engineering Tutorials



0.0 Outline
1.0 Background/Installation
2.0 Registering MyEclipse
3.0 MyEclipse Perspectives
4.0 UML with MyEclipse
5.0 Exercises
6.0 Resources

1.0 Background/Installation

UML

UML (Unified Modeling Language) was developed by Grady Booch, James Rumbaugh, and Ivar Jacobson, at Rational Software Corporation in 1997, for a standard way to model the structure of large applications. The UML is a standard maintained by the Object Management Group (OMG). The current version of UML is 2.0. UML provides a standardized way of modeling software, so the everyone can understand a given model. UML has several different modeling types: class diagram, sequence diagrams, state charts, and Use Cases to name a few. This tutorial will introduce programmers to creating state diagrams in Eclipse UML.

MyEclipse is an application configuration for Eclipse which extends the functionality of the IDE immensley. Its features include complete support for developing web applications and UML modeling.

IMPORTANT:

It is recommended that users of this tutorial have a moderate understanding of the basics of the Eclipse development environment. If you do not know Eclipse basics, we recommend you read The Eclipse Tutorial also located on this website.

Installing MyEclipse

In order to install and use MyEclipse, you must have Eclipse preinstalled. You can download a trial copy of MyEclipse from their website or if you are an North Carolina State student, simply check the MyEclipse option in the web installer for your course.

State Diagrams

State Diagrams are used to describe the different states and state transitions of an object in the system. State Diagrams are not able to directly translate to code, so we cannot use them in Rational XDE to generate code based on the diagram, however, State Diagrams can be useful on their own to help model the behavior of a program in order for a programmer to better understand the intricacies of the code they are writing.

The key elements of a State Diagram are, of course, the states. There are three kinds of states: initial (or start), final, and regular states where things can happen. Inside of a state there can be entry and exit conditions as well as things that are done when the object is inside the state.

To move from state to state we have transitions. Transitions can be unconditional which means that when the activities of a state are complete a transition is automatically moved to another state. There can also be events that trigger a transition. In the CoffeeMaker example, the coffee maker waits until the user inputs a command. This command would trigger a transition to a particular state.

States can also contain an internal state diagram. It can be a parallel diagram in which there are multiple states executing at once, or the diagram can just contain a single string of events with its own start and finish states. When the final state is reached the parent state is exited.

For more detailed information about State Diagrams, check out Chapter 10 in Martin Fowler's UML Distilled.

Top | Contents

2.0 Registering MyEclipse

MyEclipse is shareware which will expire in 30 days. If you have been provided a registration number as part of a course or for a company, read on in this section for the steps to register your copy. If you do not have a registration number, skip this step.

To register MyEclipse, you will need both a Subscriber ID and a Subscription Code. After opening your copy of MyEclipse, within any perspective, go to the "MyEclipse menu" and select "Update Subscription..." as demonstrated in figure 2.1.


Figure 2.1: Subscribing to MyEclipse

A dialog box will appear asking for your Subscription's ID and Code. Enter these and click "Okay." Your copy of MyEclipse is now registered.

Top | Contents

3.0 MyEclipse Perspectives

The perspective MyEclipse has to offer in which we are most interested is the UML perspective. The steps below will show you how to load this perspective in your workspace. The other perspectives can be quite useful, however, especially when developing a web application. To switch to the UML perspective, go to the icon next to the Java perspective in Eclipse and select the "MyEclipse UML" from the dropdown menu as shown in figure 3.1.


Figure 3.1: Loading the UML Perspective

Here is a quick list and description of the other perspectives MyEclipse has to offer:

  • Database Explorer: After it is configured properly, this perspective allows you to view the status, structure and data contained within your databases. This is to avoid having to write code which shows you the contents of your entire database.
  • Image Editor: Just like any other image editor, except you can edit the images contained within your projects, do image mapping and manipulate image behavior based on Java events.
  • J2EE Development: Allowing views of the current status of your system on any web development platform, this perspective automates deployment of your project to the server, and allows you to manage and configure the server.
  • Web 2.0: This perspective allows live editing of JSP and AJAX, two web interface technologies that are on the cutting-edge of the web world.
Top | Contents

4.0 UML with MyEclipse

MyEclipse makes synchronization of your code with a UML repository a snap. Before continuing through the various steps, you should make a decision as to whether you would like to create a possible design for your project before writing any code and then have MyEclipse generate the skeleton classes (Forward Engineering) or use code that you have already written to generate design diagrams either for documentation or communication (Reverse Engineering).

Sections 4.2-4.3 demonstrate how to generate diagrams using the UML perspective and then use them as a source to generate your Java basecode. Section 4.4 shows you how to reverse engineer your Java code into a diagram. Section 4.5 demonstrates how to take the diagrams within your project and export them as images for ease of use.

4.1 Creating a UML Repository

In MyEclipse, all UML must be contained within a repository. For different versions of a program or different levels of collaboration and development, one could have different repositories. Resositories are one file in MyEclipse, but they are still not source code or libraries, so we recommend placing them in a folder called /doc. To create a UML repository, go to File -> New... and select UML Model Repository from the dropdown menu that appears as in figure 4.1.


Figure 4.1: Creating a UML Repository

A dialog box will appear asking you which folder you would like to create the repository within, select your documentation folder or any folder that is not a source folder and click "Okay". Your repository will load within the perspective.

4.2 Creating diagrams

After you have completed section 4.1 or already have a UML repository, you can create UML diagrams using the MyEclipse editor. When your repository is showing within the MyEclipse UML perspective, you should see a toolbar that looks like figure 4.2a.


Figure 4.2a: Creating a new diagram

Hover your mouse over each button to see which type of class it creates. The classs types from left to right in figure 4.2a are class, use case, sequence, activity, state, collaboration and deployment.

Now is a good time to discuss the properties view. When you load any diagram within the MyEclipse UML perspective, the properties view will appear at the bottom of your screen (see figure 4.2b).


Figure 4.2b: The Properties

This editor will allow you to manipulate the various facets of any object within your UML repository. From the repository itself all the way to an element within an action that is a trigger of a transition of a state that is within a state diagram... you get the idea. Proper use of the properties view requires a knowledge of UML and Java.

Upon creating a diagram, you should also see a set of buttons for each type. The following figure shows the buttons for state diagrams. Hover your mouse over each to see what type of element it allows you to create.


Figure 4.2c: State Diagram buttons

To create each element, click the button and click within the diagram where you would like the place the element. It will appear as an "anon" element until you edit its properties (see figure 4.2b).

4.3 Exporting Images

Many people do not have MyEclipse and cannot open the files with which it stores UML Model Repositories (UMR). The most universal way to share UML is through an image file. This allows other developers (or perhaps your professor or TA) a brief view of the structure of your system in an easy to open format. To export your diagram as an image, you need to be in the MyEclipse UML perspective, have the diagram predrawn and have it showing. Then, right click on the image and select "Export as Image..." as shown in figure 4.5. We recommend keeping a backup copy of your UML diagrams in your /doc folder for easy publishing.


Figure 4.5: Exporting as an Image

Top | Contents

5.0 Exercises

These exercises will help you to learn how to use MyEclipse's UML perspective to model the system with the CoffeeMaker project (documentation, project files). Download the project files and import them into your workspace to begin. When you have completed each exercise, show your work to your TA for lab credit.

The Exercise

Create a state diagram in that models all of the states of the CoffeeMaker example. The requirements for the project can be found on the documentation pages.

Top | Contents

6.0 Resources

  • MyEclipse Documentation
  • Download Eclipse
  • UML Resource Page
  • Top | Contents

    Back to Software Engineering Tutorials
    Installing Eclipse Plug-ins ©2006 North Carolina State University, Laurie Williams, Sarah Smith , Ben Smith
    Email Sarah Smith with any questions or comments about this tutorial.
    Last Updated: Wednesday, July 26, 2006 1:46:50 PM