Contributed and maintained by
November 2007 [Revision number: V1-4]
This publication is applicable to NetBeans IDE 6.0 and 6.1 releases
In this tutorial, you learn how to use the UML features of the IDE to create a simple UML activity diagram. The steps in this tutorial show one representative way of creating an activity diagram and introduce you to some of the features offered by NetBeans UML. This tutorial does not teach you about UML concepts or the Java programming language.
Before you proceed, make sure you review the requirements in this section.
This tutorial assumes that your system meets the requirements specified in the Systems Requirements section of the NetBeans 6.0 Release Notes.
Prerequisites
To use this tutorial, the IDE must be installed on your system and you should be familiar with the basic parts of the IDE. You should also have a basic familiarity with the Java programming language and UML. For a basic understanding of the IDE, see the IDE Basics topics in the online help. A good resource for UML techniques and theory is the official UML resource page at http://www.uml.org/.
Software Needed for the Tutorial
To follow this tutorial, you need the software and resources listed in the following table.
An Activity diagram is a visual representation of any system's activities and flows of data or decisions between activities. When you click the Diagram editor tab for an Activity diagram, the IDE displays a specific selection of icons in the IDE Modeling Palette. Activity diagrams provide a very broad view of a business process.
The diagram may be used to:
Describe activities and flows of data or decisions between activities
Provide a broad view of business processes
Describe the activities that occur within a use case
Show many different activities using different discrete symbols
Show parallel threads
The following shows the tasks involved in creating an Activity diagram. This table and the following procedures describe one way to create an Activity diagram.
To create an Activity diagram, you must first create the UML project and a Java package to contain an empty scoped activity diagram. This section contains the following procedures:
From the main menu, choose File > New Project and then do the following:
Under Categories, select UML.
Under Projects, select Platform-Independent Model.
Click Next.
Type ActivityDiagProj for the project name and ActivityDiagTut for the location for your project.
Notice that when you type the Project Name, the IDE automatically suggests this name for the name of the Project Folder.
Click Finish.
The New Wizard opens and displays the Create New Diagram page.
For the purposes of this example, click Cancel.
The IDE does the following:
Creates an empty Platform Independent modeling project
From the Basic section of the Modeling Palette, select the Activity Group icon .
Click inside the Bank Lobby subpartition in the Diagram editor to place the Activity Group element on the diagram inside the left subpartition.
This nests the Activity Group inside the Bank Lobby subpartition.
Right-click to deselect the icon.
Double-click the word Unnamed on the new Activity Group, type Customer and press Enter.
Select the Activity Group that you just added. Move and enlarge it to almost fill this subpartition.
From the Basic section of the Modeling Palette, select the Invocation icon .
Click inside the Customer Activity Group element in the Bank Lobby subpartition to place two invocation elements on the diagram, one directly below the other.
Deselect the icon.
Move and resize the invocation elements so that they fit completely inside the Customer Activity Group as shown in the following figure.
Double-click the upper invocation node that you just added, type Approach Teller Counter and press Enter to label the element.
Select the lower invocation node and name it Enter Transaction.
Place six more invocation elements inside the Teller subpartition and name them as follows:
Receive Transaction Request
Search Customer Info
Send to Customer Service
Process Transaction
Update Account Info
Notify Customer
Your diagram should resemble the following figure.
From the Control section of the Modeling Palette, click the Horizontal Fork icon .
Place the bar representing the Horizontal Fork element above the Update Account Info and Notify Customer invocation elements
Deselect the icon.
Lengthen the bar to span the width of both invocations.
Place another Horizontal Fork element below the Update Account Info and Notify Customer invocation elements and lengthen the bar to span the width of both invocations.
From the Basic section of the Modeling Palette, select the Activity Final Node icon .
Place the Final Node below the lower Horizontal Fork element.
Deselect the Activity Final Node icon.
From the Control section of the Modeling Palette, select the Decision icon .
Place the Decision element on the flow between Search Customer Info and Send To Customer Service elements.
Your diagram should resemble the following figure.
From the Basic section of the Modeling Palette, select the Activity Edge icon .
You use the Activity Edge to connect the Initial Node element to the Invocation element.
Click once on the Initial Node element and click again on the invocation element that is labeled Approach Teller Counter.
An Activity Edge link now connects the two elements. The labels for the Activity Edge links are hidden and need to be displayed.
Deselect the icon by right-clicking anywhere in the Diagram editor.
Select and right-click the Activity Edge element.
Choose Labels > Show Name from the pop-up menu.
The link is labeled with the highlighted text Unnamed.
To name the link, type Initiate Cash Withdrawal and press Enter.
In the IDE, an Activity Group depicts a loop in the flow of an activity. For example, an Activity Group calls out an iteration that already exists in the flow. The IDE's UML feature offers three Group Kinds as follows:
Iteration
Structured
Interruptible
In the Diagram editor, select the Activity Group labeled Customer.
In the Properties window on the GroupKind property row, click the down arrow.
Select Structured from the drop-down list.
The Customer Activity Group is relabeled on the diagram as a structured group.
The finished Activity diagram should resemble the following figure:
In this article, you created an activity diagram for a simple banking application. You learned how to create a representative Activity diagram using the features offered by NetBeans UML.
For more information on UML, consult the online help in the IDE and visit the UML product page, which contains additional tutorials, video clips, and other information.
To send comments and suggestions, obtain support, and stay informed of the latest
changes to the NetBeans IDE J2EE development features, join the
mailing list.