You should be able to do this using the platform adapter manager to tell Eclipse how to get a folder from your object:
Create an IAdapterFactory
for your class:
class MyTreeEntryAdapterFactory implements IAdapterFactory
{
@Override
public Object getAdapter(Object adaptableObject, Class adapterType)
{
if (!(adaptableObject instanceof MyTreeEntry))
return null;
if (adapterType == IResource.class || adapterType == IFolder.class)
return ((MyTreeEntry)adaptableObject).getFolder();
return null;
}
public Class<?> [] getAdapterList()
{
return new Class<?> [] {IResource.class, IFolder.class};
}
}
register your adapter factory with the adapter manager:
Platform.getAdapterManager().registerAdapters(adapterFactory, MyTreeEntry.class);
You probably need the adapters for IResource
as well as IFolder
.
Note: The IAdaptable
interface provides very similar support but the Eclipse menu system requires the IAdapterFactory
.