EMF中如何让动态设置属性视图中属性的编辑状态

在EMF应用中,有一些时候,我们希望一个对象的某一个属性在属性视图中的编辑状态时条件可控的,如果符合某一个条件,这个属性就不能被修改,否则就允许修改。
一种标准办法是在对应对象的xxxItemProviderAdapter中的进行如下处理:
protected void addxxxPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(new ItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(), getResourceLocator(),
getString("_UI_Join_this_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Join_this_feature", "_UI_Join_type"),
RelationPackage.Literals.JOIN__THIS, true, false, true, null,
null, null)
{

@Override
public boolean canSetProperty(Object object) {
if(xxx){
return false;
}
return true;
}
}


当然也可以设置
createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_End_multiplicity_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_End_multiplicity_feature", "_UI_End_type"),
RelationPackage.Literals.END__MULTIPLICITY,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null)

其中的倒数第6个参数setable,也是这个作用,如果设置为false,该属性在属性视图上就是不可编辑的;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值