开发者

Specifying attribute types in Papyrus

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 document开发者_如何转开发ation 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???


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.


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"


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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜