Customizing UI elements in Eclipse default Java Editor via plugin - eclipse

I'm trying to develop a plugin for Eclipse that will allow me to modify various elements within the default java text editor. I've found lots of tutorials for creating my own text editor for a different language, but nothing for editing the default java editor. Specifically, I want to be able to run a command and highlight certain areas of the code based on a different program. How do I develop this?
Thanks

You will need to implement your own type of markers and maybe associate annotations with them. Then you can associate the java editor with the annotations to show them. Your application will generate the markers.
Specifically you might want to start to read about org.eclipse.core.resources.marker extension point and IResource.createMarker() to create the markers.

Its doable. You need to find the right extension point that allows you to add functionality to the java editor.
See IBM tutorial. The example with the heading "How do you analyze Java code to apply modifications" seems to be what you want to do.

Related

Custom VSCode extension: embed native editor in webview

Goal
I want to have a webview, that embeds the native editor (see image).
The embedded part does not need to have a tabbing-feature. It would be enough to have the editor object, that I fill and update manually per Javascript.
Question
Is that possible? How would I do that?
Background
I want to show various file contents within my own webview. These contents should be editable and have all functionality, that the vscode editor has (e.g. syntax highlighting, multiple cursors, intellisense,...). At best, also 3rd party extensions should work within them.
I don't want to start implementing the whole editor again, so I'm searching for a way to embed the editor.
It is not possible to embed the native editor that comes with VS Code. The extension API simply does not support it.
The closest you can get is to import the code of the editor into your webview. The editor is called Monaco and is available via the npm package monaco-editor. It supports most (or all?) of the features offered by VS Code editor, such as IntelliSense.
However, since this editor would be unaware of the installed VS Code extensions, themes and configuration options, it will behave differently than native editors. You might be able to improve the user experience by manually propagating configuration options and themes, but this would require a significant amount of work and might not be possible for other things, such as support for language servers or third party extensions.

Eclipse Plugin: Editor for a file type with some simple elements

I want to create a plugin for Eclipse that allows me to edit a file in a graphical way. Parsing and saving the file is no problem, but I can't seem to figure out the simplest way of designing an editor in Eclipse. I guess this must be super easy, but I can only find complex examples when googling, and no simple solution for quickly sticking together a GUI as an editor (I don't want to define an entire EMF model etc. for this simple task).
The editor should only have a few simple lists and add and delete button to edit these lists. In should open when I double click the file with the appropriate file ending.
Questions:
In RCP4 required for this or just a normal editor plugin?
In started of with the normal editor plugin generated by the Wizard that provides a XMLEditor. What is the recommend way for adding these simple model editing elements (lists)?
I'm working on a similar editor using Window Builder, Forms, and EMF JFace data bindings.
It is not that complex, but I wouldn't call it simple either. Or, put it differently - it is all simple once you know how it works, but you'll have to invest some time in gaining that knowledge.
Some links which should help you get started:
https://eclipse.org/windowbuilder/
http://blog.vogella.com/2016/06/14/helping-windowbuilder/ - WindowBuilder for Neon
http://www.vogella.com/tutorials/EclipseDataBindingEMF/article.html
http://www.vogella.com/tutorials/EclipseDataBinding/article.html
https://tomsondev.files.wordpress.com/2011/05/emf-databinding.pdf
https://wiki.eclipse.org/JFace_Data_Binding
https://www.eclipse.org/articles/Article-Forms/article.html

How to insert visual elements inside the Java text editor of Eclipse?

I'd like to add extra visual elements inside the Java text editor of Eclipse, more specifically on top of classes and methods declarations. Things like indicators and links.
The best example is what Microsoft has done in Visual Studio with what they call CodeLens:
The closest solution I can think of is using Annotations (displayed in the rulers) but it's far from the user experience I want to have.
Are there any Eclipse plugins that have done this before?
Any pointers to give me somewhere to start?
Annotations are typically shown in the vertical and overview rulers (left and right), but they're not limited to them. Take a closer look at the documentation you linked to, particularly the mentions of AnnotationPainter, and then how it uses drawing strategies. I expect you'd need a rather complicated one, and I haven't even thought through how you'd generate the information in the first place, never mind adding it directly to the Annotation Model if you're not just going to stash it in a Marker on disk.
Of course, some of this looks like information you can already find through Team->Show Annotations (although that does use the ruler to let you find them by line).
Disclaimer, I'm the author of CodeLens Eclipse.
Eclipse doesn't provide Codelens feature, but it exists CodeLens Eclipse.
This project provides a CodeLens extension point to implement your own CodeLens. Today TypeScript, Java JDT CodeLens and lsp4e CodeLens are available. Here a little demo with Java JDT Editor:

Eclipse Plug-in : Displaying warning message in Eclipse using AST , DOM

I am learning Plug-in development and code manipulation using Abstract Syntax Tree and DOM.
I want to code a plug-in which will display a warning (see image) on the left hand side of the Eclipse Java code editor based on some condition in the testing code.
example scenario :
Right now warning message is displayed in eclipse when we do not use any declared variable in Java. I want to display warning message when (Just for example) any variable is assigned value 10 (lets say).
I know how to create Plug-In, Extract variables, expressions and declaration using AST. But I have no idea about how to display warning message.
which API or package is used for it?
Can someone please show me the path for this?
You can achieve the same using eclipse markers (IMarker).
Refer below link for more details on how to create an eclipse marker.
https://www.eclipse.org/articles/Article-Mark%20My%20Words/mark-my-words.html
The MarkerUtilities class provides methods to create markers easily.
You need to add the org.eclipse.ui.editors plug-in to the dependencies.
For showing the same in editor use markerAnnotationSpecification extension point. This is used to define a mapping between markers and editor annotations automatically, with specified formatting.
Refer: http://cubussapiens.hu/2011/05/custom-markers-and-annotations-the-bright-side-of-eclipse/

Creating JSPs with Eclipse

I'm trying to create several JSPs, and I was told that what most people do, is open notepad and hardcode the whole thing in. I come from the origins of C#, so that option is somewhat foreign to me :)
I did try to do several complex components by hand in Java. It took quite a bit of time (mostly with arrangements) but I was able to do it.
My question is, will I be able to create JSPs inside of Eclipse and will all the UI components that I will implement be there as I positioned them?
I'm asking because I found an Eclipse plugin (http://code.google.com/javadevtools/download-wbpro.html) that allows me to drag and drop components (C# style :D) and I needed to know if it is worth downloading, because if I still have to hardcode the JSP's UI in, the download time will be a waste (slow speed here).
Create a jsp page and right click on the editor and go to open with.
Select Web Page Editor and you will have the design view opened.
On the top right corner you will have an arrow. Click on the arrow and you will have elements to drag and drop on the editor.
I think almost nobody uses notepad to create JSP's. The editing is done in text mode in IDE's or comparable tools.
I agree with #BalusC, JSP's don't have good support for drag and drop development (like Visual Studio), although there tools like Dreamweaver which had some support to create the HTML structure in a WYSYWYG environment. I would not recommend these kind of tools for JSP but it's your choice.
The plugin you mention is not for JSP's and any of the alternatives it does support won't be quick to learn.
As #BalusCmentions, JSF's is an alternative for which there are some visual editors. You might want to look into that but you'd need to do some research as JSF is an standard and there are several implementations and related tools around. There are plugins for JSF support in Eclipse.
All in all I think you need to read further on Java web development and the alternatives that exist.