开发者

How do I get the resources of a working set?

开发者 https://www.devze.com 2023-01-01 13:25 出处:网络
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

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.


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);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消