Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse - "Virtual" Resources

I am programming a plug-in that uses a virtual tree-like file-structure. Basically it acts just like a standard filesystem containing files, with the difference that these files do not actually exist in a specific location in the filesystem but rather are mere java objects.

These are currently supported by the navigator (a custom implementation using the Common Navigator Framework) using a SettingProvider, and interaction with these Objects is implemented just like interaction with standard files.

However, it is necessary to stick markers to these Objects now. As I understand the Eclipse framework, markers can be attached to *IResource*s only, so in order to achieve this goal, instead of using *SettingProvider*s, I should create instances of IResource.

However, the standard implementation only allows creation of resources from the filesystem. Since things like virtual folders exist, there must be a possibility to create virtual resources, i.e. resources without an actual location in the filesystem. But how can I do this? My research seems to be leading nowhere...

Alternatively, is there a possibility to achieve the desired functionality (sticking markers to objects in a CNF navigator) in a different way?

Thanks in advance!

like image 220
Sevi Vöst Avatar asked Nov 04 '22 15:11

Sevi Vöst


1 Answers

Right, markers can only be attached to resources in the workspace. To implement a custom filesystem, Eclipse provides the EFS-mechanism, to provide a "file-like" structure, for further information see http://wiki.eclipse.org/EFS - on this page you'll also find links to example implementations which should give you an idea how to implement your own filesystem contributor. BUT: IMHO it is the wrong approach to use Eclipses marker system for your scenario. All stuff is very tight coupled to the workspace model which does not work well with a custom data model. From my experience the best is to

  1. have your own marker-model which fits exactly to your data model,
  2. implement a decorator for your tree (via extension point)
  3. implement something similar like the Problems-view to visualize markers.

Although is sounds a bit odd to implement something similar that is already there it will save you a lot of headaches cause your scenario is not restricted by the boundaries of the workspace model and api.

like image 67
Tom Seidel Avatar answered Nov 08 '22 03:11

Tom Seidel