Eclipse - Virtual Resources

I am programming a plugin that uses a virtual tree-like file structure. Basically, it acts the same way as a standard file system containing files, with the difference that these files do not actually exist in a specific place in the file system, but are simply java objects.

Currently, they are supported by the navigator (custom implementation using the Common Navigator Framework) using SetProvider, and interaction with these objects is implemented in the same way as interaction with standard files.

However, now you need to bind markers to these objects. Since I understand the structure of Eclipse, markers can only be bound to * IResource * s, so to achieve this, instead of using * SettingProvider * s, I have to instantiate IResource.

However, the standard implementation only allows you to create resources from the file system. Since there are such things as virtual folders, it must be possible to create virtual resources, that is, resources without an actual location in the file system. But how can I do this? My research seems to be not being conducted anywhere ...

Alternatively, is it possible to achieve the desired functionality (binding markers to objects in the CNF navigator) differently?

Thanks in advance!

+4
source share
1 answer

To the right, tokens can only be tied to resources in the workspace. To implement a custom file system, Eclipse provides an EFS mechanism for creating a "file structure", for more information see http://wiki.eclipse.org/EFS - on this page you will also find links to implementation examples that should give you An idea of ​​how to implement your own file system contributor. BUT: IMHO is the wrong approach to using the Eclipses marker system for your scenario. All material is very tightly connected with the workspace model, which does not work very well with the user data model. In my experience, the best

  • has its own marker model that exactly matches your data model,
  • implement a decorator for your tree (via extension point)
  • implement something like this, for example, the "Problems" view for visualizing markers.

Although it sounds a little strange to implement something similar that already exists, it will save you a lot of headaches, because your script is not limited to the boundaries of the workspace model and api.

+2
source

Source: https://habr.com/ru/post/1435035/


All Articles