如何在 Eclipse 上通过 Papyrus 生成代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7130937/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to generate code by Papyrus on Eclipse?
提问by beanhorstmann
回答by Andrea Sindico
In order to generate any text artifacts from UML models in the Eclipse Modelling Environment (i.e. Papyrus, TopCased, etc.) you should use Acceleowhich is an eclipse implementationof the MOF models to text transformation language, the OMG standard languagefor models to text transformations. It is a very well made technology but it could take some time to become familiar with it especially if you do not know MOFand the Model Driven Architecture.
为了从UML模型生成的Eclipse建模环境中的任何文字的文物(即纸莎草纸,TopCased等),你应该使用Acceleo这是一个日食执行财政部车型文本转换语言,对的OMG标准语言的模式,以文本转换。这是一项制作精良的技术,但要熟悉它可能需要一些时间,尤其是在您不了解MOF和模型驱动架构的情况下。
QVT is another OMG language but its aim is models to models transformations (not models to text). It is therefore not the right answer to your question.
QVT 是另一种 OMG 语言,但它的目标是模型到模型转换(而不是模型到文本)。因此,这不是您问题的正确答案。
回答by babyinEclipse
To generate the java code from UML you can follow the below steps.
要从 UML 生成 Java 代码,您可以按照以下步骤操作。
- New Project->EMF Project Press Next
- give the project name
- In Model Importer page select UML model and press Next
- Select UML model which is created by using Papyrus.Press next
- In Package selection page select all the root packages
- click finish, it will generate genmodel.
- Use the genmodel to generate Java code.
- 新建项目->EMF项目 按下一步
- 给出项目名称
- 在模型导入器页面中选择 UML 模型并按下一步
- 选择使用 Papyrus 创建的 UML 模型。按下一步
- 在包选择页面选择所有的根包
- 单击完成,它将生成 genmodel。
- 使用 genmodel 生成 Java 代码。
I hope this information helps.
我希望这个信息帮助。
回答by Perdamaian
You need to install Papyrus Java Classes Generator.
您需要安装 Papyrus Java Classes Generator。
- Help --> install new software
- work with : http://download.eclipse.org/modeling/mdt/papyrus/updates/releases/mars
- Check group items by category
- Check show only the latest version of available software
- Check Papyrus Java
- Next --> accept terms and conditions
- finish
- 帮助 --> 安装新软件
- 使用:http: //download.eclipse.org/modeling/mdt/papyrus/updates/releases/mars
- 按类别检查组项目
- 检查仅显示可用软件的最新版本
- 检查 Papyrus Java
- 下一步 --> 接受条款和条件
- 结束
Now, in your model.di : right click on your class --> Java --> Generate java code. And you're done !
现在,在您的 model.di 中:右键单击您的类 --> Java --> 生成 java 代码。大功告成!
回答by Lobo
To generate code from a UML diagram created with Papyrus must create a run configuration for Papyrus.
要从使用 Papyrus 创建的 UML 图生成代码,必须为 Papyrus 创建运行配置。
More information and a demo video at the following links.
更多信息和演示视频位于以下链接。
回答by Srikanth Venkatesh
回答by Gabriel ??erbák
Papyrus is an Eclipse lugin for modeling, you need to use additional Eclipse plugin to do model transformations. In the other answer you can find link to tutorials. First of them indicates you should use QVTo.
Papyrus 是一个用于建模的 Eclipse lugin,您需要使用额外的 Eclipse 插件来进行模型转换。在另一个答案中,您可以找到教程的链接。第一个表示您应该使用 QVTo。
Resources:
资源:
回答by UML GURU
It doesn't work with Java because even if you get a code from a class diagram then this code is so dirty that it is totally unusable.
它不适用于 Java,因为即使您从类图中获取代码,该代码也非常脏,以至于完全无法使用。
It seems that this tool has been written by modelers who have never done any java codding :-)
这个工具似乎是由从未做过任何 Java 编码的建模者编写的 :-)