emf 模型的 Gef 编辑部分
我正在从 EMF 模型创建 GEF 编辑器;假设模型名称为 StartEvent,它具有 ID 和名称等属性。
在编辑部分,我有两个标签:一个用于显示小圆圈,另一个用于显示名称。我已经在图窗类中实现了handleBounds接口,并且返回了图标标签的边界,这样当我单击图窗时,图标只会被选中,否则如果您不实现handleBounds接口,整个图窗都会被选中。
图标标签和名称标签都必须是可选的,并且我必须能够将名称标签移开。
StartEvent 模型的名称属性映射到名称标签。
我确实明白 gef 中的所有内容都是编辑部分。你的答案可能是名称标签也应该是一个单独的编辑部分,但名称不是模型;这是模特的财产。
I am creating a GEF editor from an EMF model; say the model name is StartEvent, and it has properties like ID, and name.
In the edit part, I have two labels: one for displaying the small circle, and another one for displaying the name. I have implemented the handleBounds interface in the figure class, and I return the bounds of the icon label so that when I click the figure the icon only gets selected else if you don implement handleBounds interface the whole figure will be selected.
Both the icon label and name label must be selectable, and I must be able to move the name label away from it.
The name property of the StartEvent model is mapped to the name label.
I do understand that every thing in gef is an edit part. Your answer may be that the name label should also be an separate edit part, but the name is not an Model; it is a model's property.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您希望标签像任何其他 GEF 元素一样工作(可移动、可选择等),则必须为标签创建一个
EditPart
。标签不是模型实体并不重要,您必须使用一些特殊的解决方法为此标签创建一个EditPart
,例如拥有一个包含图中标签的特殊类(并且不是一个简单的字符串),它可以由编辑器的EditPartFactory
识别。据我所知,没有其他方法可以做到这一点。If you want the label to behave like any other GEF element (movable, selectable, etc) you have to create an
EditPart
for the label. It doesn't matter that the label is not a model entity, you will have to create anEditPart
for this label using some special workaround, like having a special class that contains the label in the figure (and not a simple String) which can be identified by theEditPartFactory
of your editor. From what I know, there is no other way to do this.