Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsArrays and Constructors in Class Diagram
https://www.eclipse.org/forums/index.php/mv/msg/1065636/1692040/#msg_1692040
Would like to ask the following, since I have been unable to figure out how to do it:
- How can I define a Constructor in a Class? Every operation I try to create will have a "void" return type if nothing is set.
- How can I create a array in the Class. I know I can set the multiplicity of an attribute, but when generating code, the attribute comes out like this: "List<DataType> var". I would like it to be a real array, like this: "DataType[] var".
Anybody have any idea how to do it, if it's possible?]]>Karel Mous2015-04-12T15:55:13-00:00Re: Arrays and Constructors in Class Diagram
https://www.eclipse.org/forums/index.php/mv/msg/1065636/1692113/#msg_1692113
The Java Profile has stereotypes that convey Java-specific semantics:
* <<javaMethod>> has an 'isConstructor' attribute
* <<primitiveType>> has an 'implementationClass' attribute
For array types, you might just need to model them explicitly as
DataTypes of some kind. Perhaps the <<primitiveType>>
'implementationClass' attribute could let you specify the array
declaration, e.g., 'MyDataType[]' or even something like
'MyDataType[16][16]'.
Hopefully someone responsible for the Java component can chime in with
a better answer about array types ...
HTH,
Christian
On 2015-04-13 12:49:28 +0000, Karel Mous said:
> Am currently using Papyrus 1.0.2 with Eclipse Luna. Am currently
> attempting to create some Class Diagrams, using the Java Profile and
> Java primitive types.
> Would like to ask the following, since I have been unable to figure out
> how to do it:
>
> - How can I define a Constructor in a Class? Every operation I try to
> create will have a "void" return type if nothing is set.
>
> - How can I create a array in the Class. I know I can set the
> multiplicity of an attribute, but when generating code, the attribute
> comes out like this: "List<DataType> var". I would like it to be a real
> array, like this: "DataType[] var".
>
> Anybody have any idea how to do it, if it's possible?]]>Christian Damus2015-04-13T14:21:01-00:00Re: Arrays and Constructors in Class Diagram
https://www.eclipse.org/forums/index.php/mv/msg/1065636/1692311/#msg_1692311
Thanks for your reply.
I've imported the Java Profile into the project via the Model Explorer and indeed notice that it contains a JavaMethod StereoType.
How can I use this stereotype to make my "operation" a Java Method?
Sorry I'm kinda new at the modeling tool, tried looking around the various menus but can't seem to find the correct solution to this problem.
Moreover when attempting to add a Profile or Stereotype to any part of my model, the contents of the Jave Profile do not appear as options.
Hope you can help.
Thanks in advance.
Karel
Edit:
Already found the solution, thanks to Christians answer in a different topic.
For the benefit of others, here is a short description on how to do it:
- Click on the model in the Model Explorer and view the properties of the model in the properties view.
- Click on the "Profile" option.
- In the "Profile Application" field, click on the third button "Apply Registered Profile".
- In the window that appears, select "Java" and click "OK".
After these instructions appropriate stereotypes can be connected to any element in the UML diagram via the "Profile" option in the element properties.
By unfolding the applied stereotype properties like "isConstructor" can be set.]]>Karel Mous2015-04-15T05:00:43-00:00Re: Arrays and Constructors in Class Diagram
https://www.eclipse.org/forums/index.php/mv/msg/1065636/1692389/#msg_1692389
Select your operation in the Model Explorer or a diagram. In the
Properties view, switch to the 'Profile' tab. There you have controls
for applying stereotypes to the operation and setting properties of
those stereotypes.
HTH,
Christian
On 2015-04-15 05:00:45 +0000, Karel Mous said:
> Hi Christian,
>
> Thanks for your reply.
>
> I've imported the Java Profile into the project via the Model Explorer
> and indeed notice that it contains a JavaMethod StereoType.
>
> How can I use this stereotype to make my "operation" a Java Method?
> Sorry I'm kinda new at the modeling tool, tried looking around the
> various menus but can't seem to find the correct solution to this
> problem.
>
> Hope you can help.
>
> Thanks in advance.
>
> Karel]]>Christian Damus2015-04-15T12:37:06-00:00