自定义GMF编辑器属性视图的Cell Editor

以一个自定义的对话框的Cell Editor的例子进行说明:
1)自定义***CellEditor 继承 DialogCellEditor,并覆盖openDialogBox()方法,返回要打开的对话框
2)自定义***PortPropertyDescriptor继承PropertyDescriptor,覆盖方法createEDataTypeCellEditor,返回步骤1定义的***CellEditor,如:
protected CellEditor createEDataTypeCellEditor(EDataType e, Composite c) {
EAttribute feature = (EAttribute) itemPropertyDescriptor
.getFeature(object);
if(ConnectionPackage.Literals. ***.equals(f eature)){
return new ***CellEditor(e, c, object, feature);
}
return super.createEDataTypeCellEditor(e,cc);
}
3)自定义***PropertySource继承 PropertySource,并覆盖createPropertyDescriptor()方法,返回步骤2定义的***PortPropertyDescriptor:
protected IPropertyDescriptor createPropertyDescriptor(IItemPropertyDescriptor des) {
if (itemPropertyDescriptor != null) {
Object feature = des.getFeature(object);
if (ConnectionPackage.Literals.***.equals(feature) {
return new ***PropertyDescriptor(object, des);
}
}
return new PropertyDescriptor(object, des);
}
4)找到***.diagram工程中***sheet包下的***PropertySection.java, 修改getPropertySource方法,返回步骤3定义的***PropertySourc:其中***ItemProvider为生成的***.edit工程中对应的提供器
public IPropertySource getPropertySource(Object object) {
if (object instanceof IPropertySource) {
return (IPropertySource) object;
}
AdapterFactory af = getAdapterFactory(object);
if (af != null){
IItemPropertySource ips = (IItemPropertySource) af.adapt(object,IItemPropertySource.class);
if (ips != null) {
if(ips instanceof ***ItemProvider){
return new ***PropertySource(object, ips);
}else {
return new PropertySource(object, ips);
}
}
}
if (object instanceof IAdaptable) {
return (IPropertySource) ((IAdaptable) object).getAdapter(IPropertySource.class);
}
return null;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值