anjlab / eclipse-tapestry5-plugin

Eclipse Plugin for Tapestry5
Apache License 2.0
21 stars 9 forks source link

Update tapestry XSD to 5.4 #19

Closed olivierperez closed 8 years ago

olivierperez commented 9 years ago

tapestry_5_3.xsd => tapestry_5_4.xsd

dmitrygusev commented 9 years ago

I can't accept this PR as-is, because it will break backwards compatibility for T5.3 projects. And this matters because T5.4 wasn't even released yet.

My idea of supporting multiple tapestry versions was by creating separate template files by appending tapestry version suffix to them.

For example for T5.4 this snippet.tml could be named like snippet-5.4.tml. Or maybe even better update the snippet.tml as you proposed (latest version without suffix) and create new snippet-5.3.tml.

Then in the NewFileWizardAction you could build filename valid for your current project, and fallback to filename without suffix if the file doesn't exist.

Two problems with this approach:

  1. The plugin works even if you don't have any tapestry projects around, so all you have is an instance of TapestryContext that only exposes related files of a page/component class in context. But you can get current TapestryProject of the workspace via Activator#getTapestryProject(window), just expect it could be null.
  2. Currently there's no mechanism to get tapestry version string for TapestryProject, so this needs to be implemented first.

Here's how you can get a tapestry version string.

Having an instance of TapestryProject you may get a list of its modules. One of the modules should return true for TapestryModule#isTapestryCoreModule(). This is the tapestry core module that should be from tapestry-core-x.y.x.jar. This JAR should contain META-INF/gradle/org.apache.tapestry/tapestry-core/project.properties file that holds tapestry version number:

tapestry-core-project-version

I haven't tried this, but I hope that it would be possible to reuse JarTapestryModule#findClasspathFileCaseInsensitive() to get that project.properties file.

So my idea is you can get this version string and expose it via new TapestryProject#getTapestryVersion(). I think returning null should be fine here if you couldn't obtain version number.

olivierperez commented 9 years ago

Sorry, I made this change for my team and we use Tapestry 5.4 only. It's the first time I code on an eclipse plugin, thanks for the help, I'll try to do something better. Stay tuned.

dmitrygusev commented 9 years ago

Please check this with new version -- 2.5.0

olivierperez commented 9 years ago

Thank's we'll try the new version tomorow ;-)

dmitrygusev commented 8 years ago

It got even better in the latest release, see: https://github.com/anjlab/eclipse-tapestry5-plugin#edit-templates