将使用 Papyrus 创建的 UML 类图转换为 .ecore 文件
这是我使用 eclipse 所做的事情:
- 创建一个新的 Papyrus 项目
- 在 Papyrus 中创建一个类图
- 创建一个新的 EMF 空项目
- 使用 EMF 生成器模型将我的 .uml 文件(使用 Papyrus 创建)转换为 .ecore 文件
现在我想要在 Java 中做到这一点。我发现这里有人从 XSD 执行此操作< /a>.我想做同样的事情,但来自 UML。 User565300 正在使用名为 Xsd2Ecore 的东西,但我找不到 Uml2Ecore。你们知道eclipse用什么来转换UML文件吗?
Here is what I do using eclipse :
- Create a new Papyrus project
- Create a class diagram in Papyrus
- Create a new EMF empty project
- Use the EMF Generator Model to convert my .uml file (created with Papyrus) into an .ecore file
Now i would like to do that in Java. I found a post here where someone is doing it from XSD. I would like to do the same thing but from UML. User565300 is using something called Xsd2Ecore but I couldn't find a Uml2Ecore. Do you guys know what eclipse is using to convert UML file ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最近碰巧遇到了这个问题,并找到了一个简单的解决方案,所以我想分享一下。
除了 Papyrus 之外,我还安装了 Obeo UML Designer 6.1 插件。
1) UML Designer 添加了“建模项目”的概念。从“文件”->“新建”子菜单创建一个。
2) 找到您想要转换为ECore的Papyrus模型。在其根节点下,您通常会看到两个标记为“notation”和“uml”的子节点。标记为“uml”的节点对应于名为“model.uml”的文件。单击它并将文件路径复制到剪贴板。
3) 返回您的建模项目。将剪贴板粘贴到其中,您应该会看到“model .uml”出现。打开它。
4) 打开“根资源节点”并选择其单个子节点,以下将其称为“根模型节点”。
-- 这应该是一个 UML 模型对象,代表您正在移植的模型的根。
- 如果您看到其他内容,请检查您是否未能覆盖预先存在的文件或复制了错误的模型源。
5) 确保您处于建模透视图并看到“UML 编辑器”菜单。在根模型节点仍然突出显示的情况下,导航到“转换为”-> “Ecore 模型...”
6) 完成向导。更正所有错误并在必要时重新进行。
Obeo Designer 是 GitHub 上提供的一个开源项目,因此我想可以分解 Manifest 文件来识别“To Ecore...”的菜单贡献,然后通过 GitHub 找到实际的源代码。
I happened to bump into this problem very recently and found an easy solution so thought I would share.
In addition to Papyrus, I have the Obeo UML Designer 6.1 plugin installed.
1) UML Designer adds a concept of a "Modeling Project". Create one from the File->New submenu.
2) Find the Papyrus model you want to convert to ECore. Under its root node you will generally see two children labeled "notation" and "uml". The node labeled "uml" corresponds to a file called "model.uml". Click it and copy the file path to the clipboard.
3) Return to your Modeling Project. Paste your clipboard into it, and you should see "model .uml" appear. Open it.
4) Open the "root resource node" and select its single child, which will be referred to below as the "root model node".
-- This should be a UML model object representing the root of the model you are porting.
-- If you see something else, check whether you failed to overwrite a pre-existing file or copied the wrong model source .
5) Make sure you are on the Modeling perspective and see the "UML Editor" menu. With the root model node still highlighted, navigate to "Convert To" -> "Ecore Model..."
6) Complete the wizard. Correct any errors and reepat if necessary.
The Obeo Designer is an open source project available on GitHub, so I imagine its possible to pick apart the Manifest file to identify the menu contribution for "To Ecore..." and then locate the actual source code through GitHub.
Papyrus 是一个 UML 编辑器,需要其他插件。您需要使用另一个插件(例如 accelero)来生成代码,但说实话,从 Eclipse 3.5 开始,这个插件似乎并不能真正与最新版本一起使用。
最好的办法是切换到 Topcased,它是建模开发环境,包括代码生成。唯一的问题是 Topcased 已被放弃,以便合并到 Papurus MDT 中,因此今天最好不要投资这个工具并坚持使用 Papyrus MDT。
从纸莎草纸创建 ecore 模型是不可能的,因为它与 GMF 模型一起使用,而不是直接从 Ecore 模型运行。自 Eclipse 3.5 以来 GMF 也被放弃了我不知道该说什么......
祝你好运,
Papyrus is an UML Editor which requires other plugins. You need to use another plugin such as accelero in order to generate code but to be honest it seems that since Eclipse 3.5 this plugin is not really working with the latest releases.
The best would be to swap to Topcased which is modeling development environment including code generation. The only problem is that Topcased has been abandoned in order to be merged inside Papurus MDT so it is better not to invest in this tool today and stick to Papyrus MDT.
Creating ecore model from papyrus is impossible because it works with a GMF model and not directly from an Ecore model. GMF being also abandoned since Eclipse 3.5 I don't know what to say ...
Good luck,