在EMF应用中,有一些时候,我们希望一个对象的某一个属性在属性视图中的编辑状态时条件可控的,如果符合某一个条件,这个属性就不能被修改,否则就允许修改。
一种标准办法是在对应对象的xxxItemProviderAdapter中的进行如下处理:
当然也可以设置
其中的倒数第6个参数setable,也是这个作用,如果设置为false,该属性在属性视图上就是不可编辑的;
一种标准办法是在对应对象的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,该属性在属性视图上就是不可编辑的;