Multiple cursor markers in Eclipse text editor - eclipse

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.

Related

Richer TreeView Experience in VS Code Extension

I am trying to determine if its possible to provide a "richer" experience when using TreeViews in a VS Code extension. The default explorer view has the ability to do things provide custom text coloring for items (such as red when a file has an error or yellow if its been changed). However, the only highlight I can seem to find in TreeItems is only able to highlight text in an item without control over color but only select when the highlight starts/stops.
I would really like to take advantage of the same tree experience provided by the VS Codes extensions view but it does not seem to be restricted by the same API as other extensions (makes sense).
Any recommendations? I am considering just doing a webview that holds my own "TreeView" but wanted to see if there are other options before going down that rabbit hole.

How to make marker annotations in Eclipse extend to the whole width of the editor?

I'm writing a plugin for the Eclipse IDE that adds a custom marker annotation to highlight portions of the code. Currently, I use textStylePreferenceValue="BOX" in the org.eclipse.ui.editors.markerAnnotationSpecification and get a changed background color that ends at the line-break for each line. That introduces a lot of visual noise, and I would like to have the color to extend to the whole width of the editor. How can I achieve this?
If this is not possible at the moment, what would be the next steps to add this functionality to the platform?
This is what I have:
This is what I want:
After researching further, it seems that this is not possible at the moment, at least not easily. The relevant Eclipse sub-project seems to be "platform.text" (https://github.com/eclipse/eclipse.platform.text/). The possible textStylePreferenceValues are defined in the class "org.eclipse.ui.texteditor.AnnotationPreference", and how to paint them is defined in the class "org.eclipse.jface.text.source.AnnotationPainter".
A low level solution could be to use a LineBackgroundListener together with the StyledText object of the editor.

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 )

Creating an Eclipse plug-in to display content assist regardless of cursor location

I'm working on some reflection stuff using Java across XML files. The process would be made much faster and less prone to error if I could get content assist to behave like a tree in a small window off to the side, but more than by my current cursor location.
My question is can this really be done without reinventing the wheel too much? Essentially I want to display a list of classes, choose a class, then drill down a TreeView similar to the outline view Eclipse has for a current open file and at some point I click a button below and it generates the desired XML formatted text I would have typed manually, this is generated based on whatever in the tree I have highlighted.
I've designed and begun work on the front and back end, but the piece that keeps eluding me is harnessing Eclipse's content assist to gather a list of practically anything I could possibly call in a given project.
Can this be done? I've been combing Eclipse's documentation for a few days and fighting with the source download dying halfway repeatedly.
I am not 100% if that's it but I had an eclipse plugin with spider in it's name in mind, which does what you described.
Maybe it is this one: http://eclipse-plugins.2y.net/eclipse/plugin_details.jsp?id=202
Furthermore when writing Eclipse plugins, it is useful to press ctrl+shift+f1 (eclipse plugin spy) once having worked in the pde this should be possible.
It shows you info about all possible extensionpoints refering to your current view.

Eclipse RCP - Internals of projection (folding) service

I need to make custom text folding as described here: Can I merge Syntax coloring and Folding? OR Projection colored from master document info
I'm digging through code, but its very perplexed... and I cant get access to some classes.
I still haven't found what class decides what to show when ProjectionAnnotation collapsed
I need some info on how folding/projection is implemented, but haven't found any articles.
Please if somebody familiar with Eclipse projection, or knows any articles, help!
The basic goals:
1) make ProjectionAnnotations to show text enclosed in xml tags, instead of first line
2) make ProjectionAnnotations unexpandable(permanently collapsed)
3) remove collapse/expand button (I think I know how to do it, but this decorative and have less priority)
Have a look at the excellent Eclipse corner article, you could also try looking at how Spring IDE implemented it (check out their source code from here).