Why does one need the Eclipse Snippets View when editor templates already exist? - eclipse

What are the tradeoffs of the Eclipse Snippets View vs. editor templates? Why were Snippets introduced in the first place?

Snippets appear to be a custom version of templates, with a view in the perspective and GUI dialogs to prompt for variable values in the template.
The only "new" functionality they have is to offer up their functionality through toolbar items in the editors.
Snippets view is sort of an extension proposed by WTP (Web Tool Platform) for template, more oriented to (web) code formatting, whereas templates help the user enter reoccurring patterns into a text editor.
So at the beginning, Eclipse Templates was a standard eclipse feature which could only be applied for java and javadocs.
Snippets are basically the same, but for other kind of files and were introduced by WTP to fill the same need, but for their own type of files (xml, jps, html, ...)
(and this is, right there, "why snippets were introduced in the first place")
Template does not have their own view, but rather an obscure Preference page (Preferences -> Java -> Editor -> Templates)
You could at the time however write a small eclipse extension in order to make a Template View.
This has been resolved since eclipse3.4M6 (Templates have their own view)
You can also build some custom advanced snippets view

Additionally, the Snippets view was first conceived during the development time frame between Eclipse 1.0 and 2.0, before the content assist templates were anywhere close to being as capable as they now are. That's why it was created, and it simply came into WTP as part of IBM's initial contribution to the project.

Related

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:

In the Eclipse HTML editor, is there an easy way to have custom tags available in content assist (autocomplete)?

I'm learning to use a new hosted e-commerce system at work which uses a proprietary markup/scripting language for its page templates. They are similar to JSP pages (although the server tags don't have a prefix, i.e. there is no "xsp:") and use ${expressions} similar to Expression Language. We are transitioning from a .Net system, so all of my fellow devs are very used to having thorough IntelliSense available in our editors.
So, my question is whether it is possible to make these custom tags available in content assist, and whether it is worth the hassle if there is any. (I'm aware the latter is subjective - I'm a reasonable guy and open to opinions.)
FYI, I'm more concerned with auto-completion of tags, but expressions would be great as well depending on how much work is involved. We are using eclipse for Java EE, Juno (core IDE v4.2.1) with WTP... Sorry I'm not really sure how or what to share as far as versions and components go! Let me know if any additional info would help.
Thanks in advance.
A decidedly non-hassle-free answer would be to create an Eclipse plug-in to support your proprietary template language. One place to start might be Veloeclipse, a HTML/XML/JSP/Velocity Editor for Eclipse, which claims to have the following features which you may find interesting:
Smart indentation of velocity directives (on pressing return or when using tabs)
Code folding
Code Formatting
Smart indentation of html tags (on pressing return or when using tabs)
Syntax highlighting for both html and velocity
Autocompletion and Content assist for tags, directives and references (Ctrl + space in html attribute values or when opening or closing tags)
Sources here: http://code.google.com/p/veloeclipse/source/checkout

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.

Add functionality to all Eclipse TextEditors

I need to add some functionality to eclipse text editors. The goal is to get a Graphics Context or add a SWT Canvas to any and all Eclipse AbstractTextEditors and package these modifications within a plug-in (so by installing the plugin I provide, the editor modification will work for the Java Editor, XML Editor, plain text editor, etc.). Are there any extension points that would suffice for this purpose, or is my best bet with a fragment? Any help is appreciated.
I would recommend looking at the source code for AbstractTextEditor to see if an extension point exists for this purpose. If an extension point exists, it will be evident in that class source.
I would wager that such extension point does not exist. You are left with opening an enhancement request and in the meantime patching the plugin containing AbstractTextEditor plugin to alter the source of that file. A fragment isn't going to do the trick. Another alternative to consider is to learn and apply a bytecode weaving framework such as AspectJ (http://eclipse.org/ajdt/).

Eclipse plugins for working with Apache Wicket projects

Are there any widely adopted, currently maintained Eclipse plugins for working with Apache Wicket projects? If so, where are they? Who maintains them? What do they do?
Take a look at Qwickie (eclipse plugin): https://github.com/count-negative/qwickie
The standard used to be wicket bench, but it has been discontinued and you can find a fork named stump.
I don't know stump, but wicket bench mainly had a refactoring listener (if you rename a java class, the HTML is also renamed) and some wizards (create a Panel with associated markup etc).
I haven't used bench in years, as it was rather buggy in newer eclipse versions. But I have made pretty good experiences using a custom set of eclipse HTML templates that you can download from this location: http://www.wicket-praxis.de/blog/wp-content/uploads/2010/01/wicket-template.xml
(German) description on this page: http://www.wicket-praxis.de/blog/download/
You can install these as HTML Code Templates in Eclipse:
Window -> Preferences -> Web -> HTML Files -> Editor -> Templates -> Import...
and that will enable wicket-specific template shortcuts in the HTML editor.
It's too bad you don't use IntelliJ IDEA. It has an excellent plugin called WicketForge.
Not right on the question, but not completely off it, either.
I have released a tool that can be used as an eclipse save action. It generates Java interfaces with constants for ids in wicket templates and resource keys from translation files, so that you don't need to use strings for component ids and translation keys, but can use these generated constants.
It can be integrated in eclipse quite simply as an annotation processor. After a save of a component the interfaces will be generated and built. See its readme:
https://github.com/neurolabs/wicket-id-bindings-generator
I'm maintaining it on github (feel free to fork/contribute) and am using it in all of my wicket projects.