1 - Flat 2 - Letter 3 - Postcard 4 - Parcel

looneyvillestaticSoftware and s/w Development

Aug 15, 2012 (5 years and 2 months ago)

494 views

1


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)
SD
E

NetBeans
を起動

2



3)
次に
SDE EE
-
NB

Diagram Navigator
を表示させる。

3




4)
In
Diagram Navigator

(of SDE), right click on
Class Diagram

and select
New Class Diagram

from the popup menu.

4





5)
A new diagram is created. You
are
asked to enter a package
header on top of the diagram. Enter
myapp

and press
Enter
.

5






6)
You are asked to provide the diagram name. Enter
Domain
Model

and press
Enter
.




7)
SDE Diagram Navigator
からもともとの
NetBeans

Project
Window
の表示に戻るには、下記のように左上の札で
Project
Window
を選択すると良い。

6







8)
クラス図を作成する。

7





9)
ここで、クラス名を「
IMailDelivery
」とする。

8




10)
属性の追加。

9



11)
続けて次の操作を追加するためには、
New Operation
を選択す
る。

方法名「
printShipmentInf
o
():void


10




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

Generali
zation
-
>
Class
µ

and drag

R icon


downwards to create a new

class.

11




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
.

12



14)
We finally get the following diagram.


13


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 popu
p menu.



Or it

is
also possible
to add attributes to classes

to r
ight click on
class
LocalDelivery

and select
New
Attribute

from the popu
p
menu.


14




15




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:



16




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

>
Scop
e

>
classifier

from the popup menu. By doing so, both attributes
will be static (in code level) and are underlined

17





18


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 p
r
ior 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
.

19



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.

Mail


fromPerson : String

fromContact : String

toPerson : String

toContact : String

mailType : 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

fr
om the main
menu. In the documentation pane, enter the following:

Possible types:

1
-

Flat

2
-

Letter

3
-

Postcard

4
-

Parcel

6.


20




20)
The documentation for classes, attributes, operations
and
cccC

parameters will become comments in source code to be
generated.



21






22




21) Code Generation

1.

Up to now, the diagram should look like:


23



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

24




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 s
creen except that we have again
confirmed Step 20.


Best regards,


May 9, 2010

NOTO Hirosi











Check the
Projects

window. You should see a list of generated file.
You can open them to fill in the code bod
y

like this
.

Check the
Projects

window. You should see a list of generated file.
You can open them to fill in the code body.


23) The results of the code generation

25



Successfully done!! GREAT!!

UML class diagram is successfully incorporated the NetBeans the
source code of Java project

Express Courier


and compiled with
no errors!!







26





23)
I asked a question to Visual Paradigm SDE on May 9, 2010
and got an answer on May 10, 2010.

27