Search in sources :

Example 1 with PropertySource

use of org.eclipse.emf.edit.ui.provider.PropertySource in project ecf by eclipse.

the class EObjectPropertySourceFactory method getAdapter.

/* (non-Javadoc)
	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
	 */
public Object getAdapter(Object adaptableObject, Class adapterType) {
    if (adapterType.equals(IPropertySource.class) && adaptableObject instanceof EObject) {
        EObject eObj = (EObject) adaptableObject;
        List adapters = eObj.eAdapters();
        for (Iterator itr = adapters.iterator(); itr.hasNext(); ) {
            Object adapter = itr.next();
            if (adapter instanceof IItemPropertySource) {
                // TODO handle the case with multiple IItemPropertySource adapters for this EObject
                return new PropertySource(adaptableObject, (IItemPropertySource) adapter);
            }
        }
    }
    return null;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) Iterator(java.util.Iterator) IPropertySource(org.eclipse.ui.views.properties.IPropertySource) List(java.util.List) EObject(org.eclipse.emf.ecore.EObject) IItemPropertySource(org.eclipse.emf.edit.provider.IItemPropertySource) IPropertySource(org.eclipse.ui.views.properties.IPropertySource) PropertySource(org.eclipse.emf.edit.ui.provider.PropertySource) IItemPropertySource(org.eclipse.emf.edit.provider.IItemPropertySource)

Aggregations

Iterator (java.util.Iterator)1 List (java.util.List)1 EObject (org.eclipse.emf.ecore.EObject)1 IItemPropertySource (org.eclipse.emf.edit.provider.IItemPropertySource)1 PropertySource (org.eclipse.emf.edit.ui.provider.PropertySource)1 IPropertySource (org.eclipse.ui.views.properties.IPropertySource)1