自己订制gmf中属性编辑器

在gmf中属性页的支持是由PropertyProvider完成的。自动生成的PropertyProvider只有三个方法:
public   boolean  provides(IOperation operation)  {
……
}


public  ICompositePropertySource 
……
}

protected  EObject getSemanticElement(Object object)  {
……
}

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

你可能感兴趣的:(eclipse)