Example - UML Hello World 1 by H.Ozawa
We'll create a package "examples1". We'll also be using the same example as in the Moving on to Seasar and focus on using UML plugin.
To create a new package under "Examples", right click on the src package and select New - Package from the context menu.
Enter examples1 as the Name and select the Finish button.
A new package named "examples1" should appear under "src".
It's time to create an UML class diagram. We'll create it in the package we just created.
Right click on examples1 - New - Other... in the context menu.
Expand the UML Diagrams by clicking on the + the right of it. Since we want to create a new class diagram, select UML Class Diagram and select the Next > button.
Enter examples1.ucd as the File name and select the Finish button.
Note that UML Class diagram files have file extension "ucd".
An empty class diagram should appear and file "examples1.ucd" should appear under "examples1".
Time to start writing the UML class diagram.
As my preference, we'll first create Interfaces than Classes and add methods and attributes afterwards. Actually, we could save some steps by defining interface methods and attributes and then creating classes - methods are attributes defined in the supported interface is automatically added to the class.
Nevertheless in this example, we'll create interfaces and classes before defining methods and attributes because I prefer to work that way. :)
Select the interface icon . Press left mouse button in the diagram area and drag the mouse to create a rectangle. Release the mouse button when the rectangle is the size you want it to be.
Java Interface dialog box should appear. Check that Source folder is "Examples/src" and Package is "examples1". Enter Greeting as the Name and select the Finish button.
The rectangle should be filled with <interface> and Greeting as in the diagram below.
Repeat the above step to create interface GreetingClient. The diagram should be like the one below.
We'll now create implementations of interfaces we just created.
Click on the class icon . Press left mouse button in the diagram area and drag the mouse to create a rectangle. Release the mouse button when the rectangle is the size you want it to be.
We will create this class in folder "impl". Change the Package from "examples1" to examples1.impl" to tell Eclipse to create a new folder "impl" under "examples1".
Enter GreetingImpl" as the Name and make sure public static void main(String[] args) is not checked.
To specify which interface this class implements, select the Add... button next the the Interfaces: list area.
In the "Choose interfaces:" begin entering Greeting, list of all matching interfaces will be displayed. Select Greeting - examples1 - Examples/src from the list and select the OK button.
Confirm examples1.Greeting is displayed in the Interfaces: list box and select the Finish button.
a "impl.GreetingImpl" box will be displayed with an arrow pointing to "Greeting" as in the following diagram.
Selecth the icon and drag a rectangular area again to define an implementation of "GreetingClient".
Enter examples1.impl as a "Package" and GreetingClientImpl as the Name and verify that public static void main(String[] args) is unchecked.
Select the Add... button to specify an interface.
Select GreetingClient - examples1 - Examples/src from the list. If it is not displayed, enter GreetingClient in the "Choose interfaces".
Make sure "examples1.GreetingClient" is displayed in the "Interfaces" list box and select the Finish button.