5

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!

Sevi Vöst
  • 55
  • 3

1 Answers1

2

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.

Tom Seidel
  • 9,525
  • 1
  • 26
  • 38
  • Implementing a custom marker system sounds indeed most reasonable. Thank you very much. – Sevi Vöst Sep 20 '12 at 12:23
  • @Tom Seidel Interesting recommendation to not use the eclipse Markers, since the usual concept is to re-use eclipse features. I have something similar, where I have a `TableViewer` inside `EditorPart` and editor part which takes input from a file. I can create a marker with that resource and then use `IGotoMarker` to listen to selection of this marker (e.g in Marker view) and set selection to the `TableViewer`. How can I now explain to people to not use this way to use eclipse default views? That after advocating the opposite all the time. What kind of problem can one expect in the future? – 2c00L Nov 30 '16 at 16:56
  • @2c00L well, my message was just to use the concepts in its original intention. If you don't deal with `IResource`s in your object-model you shouldn't add additional code to satisfy the concepts and interfaces although it's something different. Your example, the `EditorPart` that is bound to a `IResource` is the typical scenario to reuse the eclipse Markers feature. – Tom Seidel Dec 01 '16 at 13:44