1、先在新建的library插件工程中建立ecore模型。
[img]http://dl.iteye.com/upload/attachment/559925/cbeb0a2a-9eb8-3679-8ad8-13e4d65dad10.jpg[/img]
2、根据ecore生成对应的genmodel,由genmodel生成对应的Model代码以及edit和editor两个相关插件。
3、从Borrower对象的属性books可选择的对象集中排除SchoolBook。
修改edit插件中的BorrowerItemProvider类的addBooksPropertyDescriptor方法,原代码为
修改为
4、这样改完之后就达到了属性选择对象的过滤效果。
[img]http://dl.iteye.com/upload/attachment/559929/395542bb-fa4a-372d-98f8-be2bad168bae.jpg[/img]
[img]http://dl.iteye.com/upload/attachment/559925/cbeb0a2a-9eb8-3679-8ad8-13e4d65dad10.jpg[/img]
2、根据ecore生成对应的genmodel,由genmodel生成对应的Model代码以及edit和editor两个相关插件。
3、从Borrower对象的属性books可选择的对象集中排除SchoolBook。
修改edit插件中的BorrowerItemProvider类的addBooksPropertyDescriptor方法,原代码为
/**
* This adds a property descriptor for the Books feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addBooksPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Borrower_books_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Borrower_books_feature", "_UI_Borrower_type"),
LibraryPackage.Literals.BORROWER__BOOKS,
true,
false,
true,
null,
null,
null));
}
修改为
/**
* This adds a property descriptor for the Books feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
protected void addBooksPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(new ItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Borrower_books_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Borrower_books_feature", "_UI_Borrower_type"),
LibraryPackage.Literals.BORROWER__BOOKS,
true,
false,
true,
null,
null,
null) {
@Override
public Collection<?> getChoiceOfValues(Object object) {
Collection<Object> results = new ArrayList<Object>();
for (Object _object : super.getChoiceOfValues(object)) {
if (!(_object instanceof SchoolBook)) {
results.add(_object);
}
}
return results;
}
});
}
4、这样改完之后就达到了属性选择对象的过滤效果。
[img]http://dl.iteye.com/upload/attachment/559929/395542bb-fa4a-372d-98f8-be2bad168bae.jpg[/img]