Specifying attribute types in Papyrus
Asked Answered
A

5

8

I recently installed Papyrus and attempted to follow the tutorial for creating a model and generating Java code off it.

Unfortunately, I'm pretty much stuck right at the beginning. In the class definition, I added a static operation for main, and I'm able to specify its argument as an array:

in args: <Undefined> [*]

Unfortunately, it does not allow me to specify the type to be String. That is, I would like to specify it as follows:

in args: String [*]

No matter how I enter the type (or any type for that matter), the type reverts back to <Undefined>. I suspect something is wrong or missing with a profile it is supposed to use. Unfortunately, the documentation for this tool is rather sparse, and I cannot find an answer or solution to this.

Anyone has run into this same problem as well???

Alfredalfreda answered 5/9, 2011 at 4:45 Comment(0)
F
21

Have you imported the UML Primitive types package? This should allow you to define the type of the argument to Integer, String or Boolean.

In the model explorer, right click on your model, then choose 'Import package from registered library'
In the window that pops up pick 'UMLPrimitiveTypes' (or the Java ones, if you prefer that).
After this, it should work.

Fictionalize answered 7/9, 2011 at 10:18 Comment(0)
W
4

In the latest version of Papyrus, you have to go to model explorer, right click on your model and then choose Import. After that select "Import Registered Package." That will bring up a dialog with a list of registered packages. From that you can select either "UMLPrimitiveTypes" or "JavaPrimitiveTypes"

Wheelhouse answered 29/4, 2014 at 23:20 Comment(1)
Java Primitive Types are not available as registered profiles or registered packages in Papyrus 1.0. Just UML and XML Primitive Types. Very annoying. We need to be able to distinguish between primitive and wrapped types in our model, for code generation.Unmeriting
S
1

Papyrus consider that modeling is independent of languages and therefore no java type are usually possible. This is fully logical in a MDA approach but not in the real life :-)

There is an accelero plugin which is supposed to generate code from a diagram but it doesn't work with the latest Helios build so..... The best is to do you class diagram and then manually code the related code. I am sure that your code will be better than the one you could get from accelero :-)

Swithbart answered 5/9, 2011 at 8:35 Comment(1)
Damn. That's a bummer. Thanks for the heads-up!Alfredalfreda
A
0

It's very simple, you can do it by just clicking on the attribute properties, then select type option, In the menu bar select Tree, then Primitive Types.

Atp answered 27/2, 2018 at 14:10 Comment(0)
F
0

The String class is not able to see in java primitive types, you need import a package from java core library.

There is a java profile and library/package in Papyrus Software Designer extention. You may install it via the market place.

More details: https://wiki.eclipse.org/Java_Code_Generation

Fateful answered 26/2, 2020 at 4:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.