Marker for IStorage - eclipse

I have an editor plugin where I am using IStorage as editor input. I want to push errors of my editor content to eclipse default Problems View, for which I need to write markers.
I am very much aware of the fact that markers can be created on IResource only and not on IStorage.
I don't want my editor to be associated with a file or any other resource.
Can anyone suggest any manipulative way to implement marker on IStorage ?
Or may be any way to not associate a resource with editor but using IResource ?
Thanks In Advance !

As you already understood, there is no way to have a Marker on anything that's not an IResource. What I would suggest as workaround if you want to take advantage of markers (and more) is that you create a dummy IProject in your workspace, and that you create a "linked resource" for the file under this IProject rather than opening directly it as a IStorage.
Using an IFile linking to your file will allow you take advantage of markers, search, change history and many other IDE features that are only available for IResources.

Related

Rename resource file does not change editor part title

In my plugin project, I have a project explorer view where I can rename a config file which in shown in another editor part. The file can be renamed in the explorer with the rename resource dialog but the corresponding the editor tab title does not change. The same problem is described here and also here. Is there a standard way to get the rename functionality working without the creating a custom listener?
Editors based on AbstractTextEditor (or one of its subclasses such as TextEditor) should handle renames through the FileDocumentProvider which listens for resource changes.
Other editors need to use an IResourceChangeListener to deal with this.

How to change open with options in navigator depending upon name of the resource?

I am working on eclipse RCP application which implements CommonNavigator view to display navigator. I have few LinkedResources in navigator that link to files on the file system with custom extension. These custom extension files are opened in custom editor as well as in TextEditor.
One of the file named default.ext will be common to all the projects and I want to keep it read only. Is it possible to open file in custom editor only? For ex. Default.ext should be opened in only custom editor, however Test.ext should be opened in custom editor as well as text editor.
This way I could handle save action in my editor depending upon file name and keep the file read only.
Is there any other way to keep files read only?
Short answer: not possible in the way you describe.
Long answer: if somebody really wants to modify a file then there's no way or need to stop this. What you can do is either (1) hide the file from user or (2) set Read-only flag to discourage users from modifying the file.

In an eclipse plugin: How can I programmatically highlight lines of codes in the java editor?

I am trying to develop an eclipse plugin that does some documentation check on java code and highlights some lines of code in the editor.
To achieve my goal, I DON'T want to create a new editor in eclipse, I simply want to extend the default java editor to draw a line under (or highlight) the methods that do not satisfy some set of predetermined requirements.
Do I need to create a PresentationReconciler? If yes, how do I make the JDT or workbench use my reconciler.
I have never done plugin development and this is my first attempt.
Several starting points for you:
Annotations are an UI feature of JFace's text editor that allows you to visually mark some places in an open editor.
Markers are a Workbench feature, more high-level. They are generic "objects that may be associated with Workbench resources", and they can display in several places: in text editors (as annotations) or in the Problems view, for example.
Depending on what you want to do, you would plug in your plug-in into extension points related to either of those.
The Eclipse Java editor is located in the org.eclipse.jdt.internal.ui.javaeditor.JavaEditor package.
The "internal" in the package name means that the Eclipse development team can change how the Java editor works with new revisions.
Try this help page: Juno Help on syntax highlighting
At the end of the page, it describes how to dynamically add a PresentationReconciler, which is used for syntax highlighting. See if that fits the problem that you want to solve.
I assume you already have a plugin project.
In your plugin.xml, open the tab Extensions, click Add..., search for org.eclipse.ui.editors, then you should see a template named Editor, which will produce a simple xml editor to experiment and play with. Also, you will be able to see the needed structure to define a custom editor.
Hope this helps...
I don't know if you still have a need for this, but you are going to want to use Annotations to keep track of what parts of the editor you need to highlight.
For actually doing the graphical effect of highlighting, you could do syntax highlighting via a PresentationReconciler, but I have no experience with that.
We used a technique we borrowed from http://editbox.sourceforge.net/, replacing the background image of the editor Shell. Its open source, so check it out. (Our code might also help -- its at https://github.com/IDE4edu/EclipseEditorOverlay )

Jface TreeViewer nodes Link with files

I writing an eclipse plugin to analyze files for some defects, I get the list of java files, their classes and methods in a jface tree view, I need to open the file in the editor when I double click on the file node of the tree view.
please help me with this.
thanks,
Shasinda
You should either use a common navigator framework with corresponding filters that already has the link and open function built-in for Eclipse Resources, however, is much trickier to set up - see the blog post series starting with http://cvalcarcel.wordpress.com/2009/07/08/writing-an-eclipse-plug-in-part-1-what-im-going-to-do/
Alternatively, you could add a double click listener that opens an editor (or checks existing editors of the current workbenchpage) by looking the open editors. For the basic idea, see the corresponding Eclipse FAQ entry.
Use IDE.openEditor to open the editor.

Multiple cursor markers in Eclipse text editor

I am developing a plug-in for Eclipse. I have to develop a Java text editor which allows several users to write the code at the same time, the same way as in Google Docs. But I came across the following problem: the text editor has to show the cursor position of the other users who are coding in same Java document. In other words, I want to place a marker in the text editor content (see this image that shows what I'm trying to implement).
I've already looked IMarker, but IMarker is placed on the text editor's vertical ruler, which is not what I want. Can I use this class? If not, what other class should I use?
The other idea of mine was to insert a JTable in the text editor, but I couldn't find the way how to do that. Is this a right approach, or I'm wrong?
Stack Overflow Gods, please help me...
Eclipse has two different concepts for managing extra information related to files: markers and annotations. Annotations are related to a single editor instance, and their appearance can be customized with a corresponding extension point; markers are used to store extra information permanently (and additionally an annotation can be set up for that reason).
I think, you need to use annotations, as markers are too heavyweight for a real-time collaboration. For future reference, see the Annotations in the Eclipse Help; and some time ago I have written a blog post that describes an automatic translation (and customization) of markers to annotations.