Thymeleaf content assist plugin for Eclipse

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Thymeleaf content assist plugin for Eclipse

Emanuel
Administrator
This post was updated on .
Update: this plugin hit version 2.0.0 yesterday and is now downloadable from SourceForge.  See the GitHub page for details and all the latest information: https://github.com/thymeleaf/thymeleaf-extras-eclipse-plugin  Thanks to everyone who provided early feedback to get this plugin going.

========
I started writing an Eclipse plugin to extend the content assist in the Eclipse WTP HTML editor with Thymeleaf processor suggestions.  (This is probably only useful for those creating HTML5 files as XHTML peeps can still use the Thymeleaf DTDs.)  I've finally got something that at least works for the way I use the HTML editor, so I thought I'd release it to anybody willing to try it out.

Any feedback and/or bug reports, either reply to this forum thread or file an issue on the project's GitHub page (https://github.com/thymeleaf/thymeleaf-extras-eclipse-plugin)

---
 - Current version: 0.4.0
 - Released: 8 Feb 2013

Minimum Requirements
 - Java 6
 - Eclipse Indigo SR2 (3.7.2) w/ Web Tools Platform 3.3.2 (you basically have both of these if you downloaded the Eclipse IDE for Java EE Developers bundle)

Installation
Download this ZIP file attached to this forum post: org.thymeleaf.extras.eclipse.repository-0.4.0-SNAPSHOT.zip
Then, in Eclipse, go to Help >> Install New Software... and add the ZIP file as an archive repository. The Thymeleaf Eclipse Plugin item should appear. Select it, and follow the on-screen prompts to install the plugin.

Usage
Content assist features are only available for dialects whose namespaces (with the matching prefix) are defined in your HTML files, and if that dialect has supplied some help files in their JARs. Help files for Thymeleaf's standard processors, as well as the Thymeleaf Extras modules, come bundled with this plugin, so all you have to do to get content assist support is to include the Thymeleaf namespace and prefix in your HTML file like so:

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

You should now start getting content assistance for all of Thymeleaf's standard processors: suggestions as you type and autocompletion of what you've entered so far if it matches only one result (both of these can be invoked manually using CTRL+SPACE), and help text when hovering over the text of a Thymeleaf processor.

---
Check the readme file on the GitHub page for more information.
Reply | Threaded
Open this post in threaded view
|

Re: Thymeleaf content assist plugin for Eclipse

danielfernandez
Administrator

Good job Emanuel! Looking forward to test it :-)

Daniel.
Reply | Threaded
Open this post in threaded view
|

Re: Thymeleaf content assist plugin for Eclipse

Thibault Duchateau
Hi Emanuel,

Great job ! I've just tested it and it works well with the requirements you mentioned !

Some general feedbacks :

* indeed, requirements are a bit restrictive. In my opinion, JDK/JRE 6 compatibility should rank higher than Eclipse 3.7 and lower, but it's just my opinion :-)

* indeed, a little help in addition of each suggestion would be much appreciated !

* I appreciate the nice-looking leaf in the autocompleted list :-)

Some custom dialects related questions :

* how can I integrate suggestions for a custom dialect ?

* does it work for custom Thymeleaf tags ?
 
Thanks !

Reply | Threaded
Open this post in threaded view
|

Re: Thymeleaf content assist plugin for Eclipse

Emanuel
Administrator
Phew, glad to hear it works on other computers than just my own!

Regarding your questions (just copying what I wrote on the GitHub issue for this), the processor suggestions are currently hard-coded in XML files bundled with the plugin, so I'd have to write some new files for each new dialect I want to support.  There must be a better way to do this, but given this is my first ever Eclipse plugin, I'm still exploring the ways to do this.  (Right now I'm wondering if there's a way to scan the project you're currently working on for dialects and load them.)
Reply | Threaded
Open this post in threaded view
|

Re: Thymeleaf content assist plugin for Eclipse

Emanuel
Administrator
In reply to this post by Emanuel
Just uploaded a new version which now works on Java 6 / Eclipse 3.7.2, and has some help/documentation text for what I consider the 'main' Thymeleaf processors (those which don't just set an existing HTML attribute, because there are lot of those!).

Original post updated to reflect these changes and with a link to the new plugin JAR.
Reply | Threaded
Open this post in threaded view
|

Re: Thymeleaf content assist plugin for Eclipse

sparty02
Awesome job on the Eclipse plugin Emanuel.  I just opened a new enhancement on GitHub for a feature request.  It would be great to have some kind of "Thymeleaf Explorer" view in Eclipse. This could be a separate view and/or node in the existing Eclipse project explorer. See Spring's "Spring Elements" implementation as a reference. This would make it nice to easily get to Thymeleaf templates, fragments, etc....
Reply | Threaded
Open this post in threaded view
|

Re: Thymeleaf content assist plugin for Eclipse

Emanuel
Administrator
In reply to this post by Emanuel
Uploaded version 0.4.0 which adds support for the Spring standard dialect (th:field, th:errors, the #fields utility object, and some others) and minor improvements to the content assist suggestions.  You can read the full changelog on the GitHub page readme: https://github.com/thymeleaf/thymeleaf-extras-eclipse-plugin#changelog

This is also the last version before I move to a 'stable' release, which will put this plugin in line with the Thymeleaf extras versioning scheme, bumping the version number to 2.0.0.  When that happens, the plugin will be downloadable through Thymeleaf's SourceForge page instead of this forum thread.  I'm still thinking through options for an Eclipse update site... somewhere.

sparty02: the Thymeleaf Explorer feature is on the roadmap (well, there's a roadmap for this plugin in my head :) ) for after the 2.0.0 release.

Original post updated with a link to this new release.
Reply | Threaded
Open this post in threaded view
|

FYI: 2.0 sources

Vince Schuurman
In reply to this post by Emanuel
Hi Emanuel,

Something is wrong with the 2.0 sources. I cannot import in Eclipse and when unpacking it asks for passwords.

Thanks,

Vince
Reply | Threaded
Open this post in threaded view
|

Re: FYI: 2.0 sources

Emanuel
Administrator
Hi Vince, I can't seem to get any errors when attempting to import the plugin into Eclipse.  I downloaded the file from SourceForge again (just to make sure I didn't accidentally upload a corrupted file), and then tried to import the plugin in several different ways using the tutorial shown on this website: http://www.vogella.com/articles/EclipseCodeAccess/article.html

I tried extracting the contents to a folder then importing the plugins from that folder, and also tried installing the plugin then importing the plugins from my Eclipse installation, but both methods worked for me.  I wasn't asked for a password when unzipping the file either (I use WinZip).

Are you importing the plugin in a different way?  Maybe your download is somehow corrupted, in which case could you try downloading the ZIP file again?
Reply | Threaded
Open this post in threaded view
|

Re: FYI: 2.0 sources

Gavin
So, I'm unable to get this plugin to install myself.  I'm using STS 3.1 which is riding on Eclipse 3.8.x.  I kind of assumed it would work on this but doesn't appear to.  Anyway, people getting failures may need to check their eclipse version
Reply | Threaded
Open this post in threaded view
|

Re: FYI: 2.0 sources

Emanuel
Administrator
That's a good idea: I've only tested on Eclipse 3.7.2 and 4.2.x.  I also thought that it should work with 3.8 versions since it's in between, but I'll download Eclipse 3.8 as well to make sure I'm not missing anything there.  I've also got STS 3.1 in my 4.2 install.

Does any error show up when you try to install it?  I hope I'll get it too when I download 3.8, but I'm just wondering what to look out for.
Reply | Threaded
Open this post in threaded view
|

Re: FYI: 2.0 sources

Gavin
Yes, the error I would get would basically tell me it couldn't find a file.  It didn't tell me what file.  Anyway, If you run it on 3.8 post your findings.
Reply | Threaded
Open this post in threaded view
|

Re: FYI: 2.0 sources

Emanuel
Administrator
Unfortunately, I wasn't able to get any errors installing the plugin with Eclipse 3.8 :|

I tried all sorts of combinations of the following:
 - Eclipse 3.8.1 SDK, 32 and 64-bit editions
 - Java 6 and 7 JDKs, both 32 and 64-bit editions

And took the following steps:
 - Install WTP into a fresh install of Eclipse
 - Install STS next
 - Install the Thymeleaf plugin next

As some last resorts, are you able to confirm the MD5/SHA1 hashes of the file you downloaded against what SourceForge has:
MD5: 00409468ddad585ef275e79a2cba0014
SHA1: 1ea150a011d90500570d0fb2e417ed88f20ccbf3

If there's no difference, then can you try installing the plugin from this test update site that has the same version of the plugin as what I uploaded to SourceForge:
http://p2.ultraq.net.nz/thymeleaf-extras-eclipse-plugin/

(When I usually have trouble installing from a plugin ZIP, I try the update site instead (or vice versa), eg: I just upgraded to Juno SR2 over the weekend, so reinstalled my usual plugins, one of which is the C++ Development Tools.  I tried installing the new CDT from the update site yesterday, and that failed for some strange reason, so I downloaded the ZIP version of the repository and that went fine.)

Is that update site any better?
Reply | Threaded
Open this post in threaded view
|

Re: FYI: 2.0 sources

Gerry King
Hi Emanuel,

I could not install from the archive because it had a dependency on org.thymeleaf.extras.eclipse.dialect 0.0.0.

Installed from the test update site ( http://p2.ultraq.net.nz/thymeleaf-extras-eclipse-plugin/ ) without a problem.

Spring Tool Suite Version: 3.1.0.RELEASE

Nice work!

Gerry

Reply | Threaded
Open this post in threaded view
|

Re: FYI: 2.0 sources

lupons
Hi, I have been able to install your plugin but eclipse hungs after pressing CTRL+SPACE in a th: element.

Installation went on apparently without problems from update site.

Any clue what could be happening?

Thx!
Reply | Threaded
Open this post in threaded view
|

Re: FYI: 2.0 sources

lupons
After reinstalling again it seems to work!

Eclipse Juno SR2.

good work!