如何在 EMF Ecore 建模框架中创建自定义属性

How to create custom attributes in EMF Ecore Modeling Framework

在我们的项目中,我们的目标是对具有一系列组件的系统进行建模,每个组件都有一个输入和输出列表。我们想要区分输入和输出,所以我们不希望它成为一个大的 EFloat 列表,而是我们想要创建一个自定义数据类型,将 属性 定义为输入或输出并包含单位价值的衡量标准。

我们在 Ecore 模型中创建了自定义数据 类,但无法将它们分配给组件,因为属性列表包含默认的 Ecore 属性。

正在搜索 "custom ecore attributes" returns 不能完全解决我们问题的一般 Ecore 建模信息的结果。

如果您创建的 "custom data classes" 是 EClass,那么您可以通过 "EReference" 将它们分配给组件。如果它们是自定义数据类型,那么您可以通过 "EAttribute" 分配它们。有帮助吗?

我在之前错过的 post 中找到了答案。

How do I create an EAttribute whose data type is not an EMF class?

You can add a data type to eCore models by manually adding an eClassifiers entry to the *.ecore file. (I was unable to find a mechanism to do this through the Eclipse UI.)

For example:

<eClassifiers xsi:type="ecore:EDataType"
 name="MyClass" instanceClassName="my.package.MyClass"/>

This will make the class available as an option for the EType in the Properties editor for EAttributes. It does not appear to make it available for EReferences.