自己订制gmf中属性编辑器

本文介绍了如何在GMF中通过重写PropertyProvider的方法来自定义属性页。主要涉及如何创建自定义的EMFCompositePropertySource及EMFCompositeSourcePropertyDescriptor,并实现特定的CellEditor。
在gmf中属性页的支持是由PropertyProvider完成的。自动生成的PropertyProvider只有三个方法:
ExpandedBlockStart.gifContractedBlock.gifpublic boolean provides(IOperation operation) dot.gif{
InBlock.gif……
ExpandedBlockEnd.gif}

None.gif
None.gif
public ICompositePropertySource 
None.gif……
None.gif}
None.gif
ExpandedBlockStart.gifContractedBlock.gif
protected EObject getSemanticElement(Object object) dot.gif{
InBlock.gif……
ExpandedBlockEnd.gif}

None.gif
第一个方法主要是判断这个provider是否可以处理某个operation.
第二个方法返回一个PropertySource,和传统的eclipse PropertySource相似
第三个方法返回View对应的semantic model
要想定置自己的属性编辑器可以重载GenericEMFPropertiesProvider里面的
None.gifprotected ICompositePropertySource createPropertySource(Object object,
ExpandedBlockStart.gifContractedBlock.gif            IItemPropertySource itemPropertySource) 
dot.gif{
InBlock.gif……
ExpandedBlockEnd.gif}
方法,这个方法返回一个你自己重载的EMFCompositePropertySource对象,在你的EMFCompositePropertySource对象中你需要重载方法:
None.gifprotected IPropertyDescriptor newPropertyDescriptor(
ExpandedBlockStart.gifContractedBlock.gif                    IItemPropertyDescriptor itemPropertyDescriptor) 
dot.gif{
InBlock.gif……
ExpandedBlockEnd.gif}
这个方法中返回一个自己订制的EMFCompositeSourcePropertyDescriptor对象,在你的对象中,你需要重载其中的:
ExpandedBlockStart.gifContractedBlock.gifprotected CellEditor doCreateEditor(Composite composite) dot.gif{
InBlock.gif……
ExpandedBlockEnd.gif}
方法。在EMFCompositeSourcePropertyDescriptor类中有方法getFeature()可以获得这个PropertyDescriptor对应的属性值,可以通过判断这个属性值的类型来返回你自己的celleditor。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值