GMF Labels
From Eclipsepedia
Labels represent pieces of text possibly associated with icons on diagram surface. Text may be edited using inplace facility. There are many possibilities to construct labels but all of them are grouped in four usecases:
1. "feature based label"
Label is always defined in context of a diagram node or a link. If it's based on EClass from domain model then label may be used to represent attribute(s) of this class. Tooling will generate code that constructs label text and converts user input to the new value for attribute(s).
2. "design label"
It may be desirable to have a label that is not stored in domain model. Tooling may generate code that will use notation style (DescriptionStyle for example) to store label text in notation model.
3. "default label"
This is a read-only label with fixed text.
4. "custom label"
GMF runtime defines IParser interface that is responsible to provide label text and editing support. In this usecase toolsmith is supposed to provide his own IParser implementation.
<script type="text/javascript"></script>
Graphical Definition
The only possible label figure is Label. In generated diagram editor the actual figure may be Label from Draw2D or WrapLabel from GMF runtime. Attribute "text" of the figure is a text shown on diagram when parser is not available.
Position of label figure within the model is important; it's used to determine whether label should be inner or external. Link labels are always external but node labels may be located whether inside node figure or "float" near it. If label figure is contained within parent node figure (directly or indirectly) it's inner label.
DiagramLabel element refers to the label figure and is being referenced by LabelMapping from mapping models. If "elementIcon" attribute is set then label uses icon from EMF item providers. The following visual facets are recognized by tooling in DiagramLabel:
- AlignmentFacet - specifies link label position relative to the link figure; in generator model alignment is copied to "alignment" property of GenLinkLabel
- LabelOffsetFacet - initial distance between the label and node / link figure; in generator model represented by LabelOffsetAttributes instance in label viewmap
Mapping
LabelMapping and its subclasses define label within the mapping model.
Basic LabelMapping instance supports 3rd and 4th usecases. It has "diagramLabel" reference to graphical definition and "readOnly" flag.
FeatureLabelMapping extends LabelMapping to support 1st usecase by referencing domain attributes and providing format options:
- "features" reference: at least one attribute from domain model; all attributes should be defined within EClass of parent node / link
- "viewPattern": pattern to construct label text from feature value(s)
- "editorPattern": pattern to construct text for inplace editor from feature value(s)
- "editPattern": pattern to parse text entered by user in new feature value(s)
- "viewMethod": method to produce text from feature value(s) by pattern; used with "viewPattern" and "editorPattern"
- "editMethod": method to parse text entered by user in new feature value(s); used with "editPattern"
Currently supported methods are:
- MESSAGE_FORMAT uses java.text.MessageFormat class
- NATIVE only one attribute should be specified; calls EcoreUtil.convertToString(...) / EcoreUtil.createFromString(...) methods
- REGEXP calls String.split(...) method
- PRINTF calls String.format(...) method
DesignLabelMapping is a LabelMapping flavour to handle 2nd usecase. Now it's empty but there should be a way to define view style used to store label text in notation model [1].
Generator Model
Two hierarchies describe labels in generator model: descendants of GenLabel used to express label presentation in context of parent node / link and descendants of LabelModelFacet that denote label semantic. GenLabel references LabelModelFacet by "modelFacet" reference thus linking them together.
GenLabel
Basic GenLabel has "elementIcon" flag copied from graphical definition and "readOnly" flag from the mapping model. GenNodeLabel and GenExternalNodeLabel are concrete classes that should be used to represent inner and external node labels respectively. GenLinkLabel is for the link labels and has "alignment" attribute derived from respective visual facet. GenChildLabelNode provides the same attributes as GenLabel but prefixed with "label" word; this class is used for nodes within list compartments.
LabelModelFacet
Model facet reflects label usecase:
- "feature label": FeatureLabelModelFacet instance; properties "features", "viewPattern" and "editPattern" are taken from FeatureLabelMapping
- "design label": DesignLabelModelFacet instance
- "default label" and "custom label": no model facet (null)
In fact during mapping model to generator model transformation the following rules are obeyed:
- FeatureLabelMapping -> FeatureLabelModelFacet
- DesignLabelMapping -> DesignLabelModelFacet
- LabelMapping -> null
Pending Requests
This is a list of enhancements related to GMF labels; hopefully future versions of GMF will implement them:
原文地址:http://wiki.eclipse.org/GMF_Labels
分享到:
相关推荐
关于eclipse gmf插件的相关插件工具
15 分钟学会 Eclipse GMF 15 分钟学会 Eclipse GMF
org.eclipse.gmf.rar org.eclipse.gmf.rar org.eclipse.gmf.rarorg.eclipse.gmf.rar
GMF 学习资料 GMF中的小知识点、GMF 教程 Mindmap等
现在GMF的资源比较稀缺, 我提供了一个基于GMF的图形化数据建模的例子,供大家参考,既可以作为自己数据库设计的轻量级工具,也可以作为学习GMF的参考
GMF Tutorial中文版——一套入门教程
GMF 教程 Mindmap,本文是跟着英文教程做了一遍,并简单翻译、截图,做了一些补充,总算是实现了原文的效果。
详细描述GMF的操作过程,GMF 开发文档。
GMF实例解析.pdf
综述了图形建模框架GMF,对于认识GMF,以及演说报告都有参考价值。
eclipse 3.2下的gef,ve,gmf,经过自己的收集,把三个都收集齐了,一并传上,希望对大家有用
GMF实例解析的pdf版,有需要的可以下载回去看
GMF开发FSM的完整的例子,非常详细。教你如何开发自己的建模工具
GMF转基因食品的利与弊英文课件.ppt
GMF入门资料,适合初学者学习,很经典
使用Eclipse GMF进行可视化建模的实战资料,包含概念介绍和示例代码。
我对于GMF Tourial(一)的中文翻译,有需要的可一下载回去看
转基因食品(GMF)中的自然辩证法借鉴.pdf
GMF转基因食品利与弊英文课件.ppt
GMF转基因食品的利与弊英文.pptx