views:

41

answers:

1

I know that Eclipse working sets are very flexible and customizable. They are made of elements which implement IAdaptable Which can be anything. However, in many (most) cases, working sets are used to define a set of resources.

In case these elements can be seen as resources (e.g. IJavaProject), is there a universal (or formal) way to programatically translate these elements to resources?

Eventually, I need to determine whether a given resource is in a working set, so an answer in that direction is acceptable as well.

+1  A: 

Unfortunately I don't think there's any way around the IAdaptable route. You can do something like this, given an IWorkingSet ws:

List<IResource> resources = new ArrayList(); // or LinkedList
for (IAdaptable adaptable: ws.getElements()) {
  IResource r = (IResource) adaptable.getAdapter(IResource.class);
  if (r != null) resources.add(r);
}
dplass
Yes, that's what I thought, but I wanted to be sure I didn't miss anything. I'll keep this open for a while longer to see if there are any other options.
zvikico