Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
E<<SDE+ NetBeans 授 業 用 デ モ
(6/22/2010)>>NetBeans授業用デモ Tutorial NetBeans(5/6/2010):
【概要】Generate Java source from UML class diagram in SDE for NetBeans
1)新規企画生成「Java応用プログラム」
企画名「Express Courier」
2) SDE NetBeansを起動
1
3) 次に SDE EE-NB でDiagram Navigator を表示させる。
2
4) In Diagram Navigator (of SDE), right click on Class Diagram and select New Class Diagram from the popup menu.
3
5) A new diagram is created. You are asked to enter a package header on top of the diagram. Enter myapp and press Enter.
4
6) You are asked to provide the diagram name. Enter Domain Model and press Enter.
7) SDE Diagram Navigator からもともとのNetBeansの
5
Project Windowの表示に戻るには、下記のように左上の札で
Project Windowを選択すると良い。
8) クラス図を作成する。
6
9) ここで、クラス名を「IMailDelivery」とする。
7
10) 属性の追加。
8
11) 続けて次の操作を追加するためには、New Operation を選択
する。
方法名「printShipmentInfo():void」
9
12) We need to create a class for local delivery which inherits IMailDelivery. Move the mouse pointer over interface IMailDelivery, press on the resource icon designated “R” just above the context explanation box which reads “Generalization -> Class” and drag “R icon” downwards to create a new class.
10
13) Name the class as LocalDelivery and press Enter to confirm.
As the LocalDelivery class is implementing the interface IMailDelivery, we need to implement the operations defined in IMailDelivery. Right click on class LocalDelivery and select Related Element > Realize all Interfaces from the popup menu.
11
14) We finally get the following diagram.
12
15) We can see that operations setState and printShipmentInfo are both inherited.
16) It is time to add attributes to classes. Right click on class LocalDelivery and select Add Attribute from the popup menu.
Or it is also possible to add attributes to classes to right click on class LocalDelivery and select New Attribute from the popup menu.
13
14
17) We need to have two constants for representing states. Press Enter to continue creating attribute. Name the attribute STATE_INIT : char = 'a'. This means to create an attribute named STATE_INIT, which is in char type and have 'a' as default value. Press Enter to create another constant STATE_DELIVERED : char = 'b'. Up to now, the class should look like:
15
18) In order to declare both STATE_ attribute as constants, select STATE_INIT, press the Ctrl key and select STATE_DELIVERED to make a multiple selection. Right click on them and select Model Element Propertes > Scope > classifier from the popup menu. By doing so, both attributes will be static (in code level) and are underlined
16
17
19) Again, right click on the two attributes and select Code Detail > final from the popup menu. Click on the diagram to confirm editing. The class should now become:
(※注 )I can’t understand what’s the role of this command. The last figure(just above) of the class “LocalDelivery” no more different than the figure prior to the “Code Detail > final”command.
1. We need to create a new class Mail with association from class LocalDelivery. Move the mouse pointer to the class LocalDelivery. Press on the resource icon Aggregation -> Class.
2. Drag to the right of the class LocalDelivery and release the mouse button. Name the new class Mail.
18
3. Follow the previous steps to create attributes in class Mail.
Class
Attributes
Operations
4. We need to describe the attribute mailType by listing the possible values. Select mailType.
MailfromPerson : StringfromContact : StringtoPerson : StringtoContact : StringmailType : int
-
5. Activate the documentation pane. If you cannot find it on the screen, or if you had closed that, open it by selecting View > SDE EE-NB View > Documentation from the main menu. In the documentation pane, enter the following: Possible types:1 - Flat2 - Letter3 - Postcard4 - Parcel
6.
19
20) The documentation for classes, attributes, operations andcccC parameters will become comments in source code to be generated.
20
21
21) Code Generation1. Up to now, the diagram should look like:
22
2. Select File > Save SDE EE-NB Project from the main menu to save.
3.Now comes the code generation. Select the menu Update Code on Diagram Navigator
23
22) Hello! I am now following the tutorial, enjoying functional and beautiful panes on SDE EE-NB. I have a question in Step 21.I wonder what the meaning of this step is. It seems that nothing happens or changes on the screen except that we have again confirmed Step 20.
Best regards,
May 9, 2010NOTO Hirosi
Check the Projects window. You should see a list of generated file. You can open them to fill in the code body like this.Check the Projects window. You should see a list of generated file. You can open them to fill in the code body.
24
23) The results of the code generation
Successfully done!! GREAT!!UML class diagram is successfully incorporated the NetBeans the source code of Java project “Express Courier” and compiled with no errors!!
25
23) I asked a question to Visual Paradigm SDE on May 9, 2010 and got an answer on May 10, 2010.
26
27