Problems building my own plugin template [message #379] |
Wed, 09 April 2008 06:05  |
Eclipse User |
|
|
|
Hi all:
I'm trying to build my own plugin template after read this article
http://www.ibm.com/developerworks/library/os-eclipse-pde
If I understood well when I create a templates_3.x folder, with
sections inside it, Im declaring what I want to be valid for a specific
Eclipse version (and next). That seems not be declared in any other place.
But playing with the articles example (that works) I found a behaviour
I dont understand. The example contains a templates_3.2 folder, in which
it contains the section with the template files to be modified by the
users selections. If I rename this folder to templates_3.3 for example,
it stop working (creates a plugin from the template, but dont include the
template class modified by users choices). Im testing with Eclipse 3.3,
so I assume it should work with templates_3.3 folder. Must be this
information declared in a configuration file? I didnt find any reference
to it.
Thanks in advance,
Miguel
|
|
|
|
Re: Problems building my own plugin template [message #418 is a reply to message #411] |
Thu, 10 April 2008 08:40  |
Eclipse User |
|
|
|
Hi Chris:
I found the place to declare where to look for template files. Thanks
for your help!
To help other people which arrive here looking for the same problem: you
must implement (override) the method
public URL getTemplateLocation();
in your template code, to provide the URL where your template files are.
The problem is that the example of the article I mentioned on my first
post didnt override it, and took the default implementation. This is that
default implementation:
public URL getTemplateLocation() {
URL url = getInstallURL();
try {
String location = getTemplateDirectory() + "/" //$NON-NLS-1$
+ getSectionId() + "/"; //$NON-NLS-1$
return new URL(url, location);
} catch (MalformedURLException e) {
return null;
}
}
protected String getTemplateDirectory() {
String schemaVersion = model.getPluginBase().getSchemaVersion();
if (schemaVersion != null)
return "templates_" + schemaVersion; //$NON-NLS-1$
return "templates"; //$NON-NLS-1$
}
I really dont understand this default behaviour; using the
SchemaVersion (3.2 for Eclipse 3.2 and next versions) it ends to return
the URL for the templates_3.2 folder, which coincides with the example
folder (so it works). I think it could have more sense to use the target
version of your plugin than the schema version; schema version is the
same for multiple cases.
Anyway, its better to implement getTemplateLocation to be sure that
it returns what you need. There are templates and their sources in any
Eclipse distribution. I recommend to read the code of those templates if
you have troubles.
Best regards,
Miguel
|
|
|
Re: Problems building my own plugin template [message #565220 is a reply to message #379] |
Thu, 10 April 2008 02:36  |
Eclipse User |
|
|
|
Check in your template code... there should be a place where you are
actually defining to have your template look in templates_3.2... so when
you move the template to templates_3.3, the code needs to be updated to
reflect this. I'm trying to think of where this is in the code.. but I
don't remember. Do a quick search on templates_3.2 on your plug-in
project and you should find it.
Good luck!
Cheers,
~ Chris
|
|
|
Re: Problems building my own plugin template [message #565269 is a reply to message #411] |
Thu, 10 April 2008 08:40  |
Eclipse User |
|
|
|
Hi Chris:
I found the place to declare where to look for template files. Thanks
for your help!
To help other people which arrive here looking for the same problem: you
must implement (override) the method
public URL getTemplateLocation();
in your template code, to provide the URL where your template files are.
The problem is that the example of the article I mentioned on my first
post didnt override it, and took the default implementation. This is that
default implementation:
public URL getTemplateLocation() {
URL url = getInstallURL();
try {
String location = getTemplateDirectory() + "/" //$NON-NLS-1$
+ getSectionId() + "/"; //$NON-NLS-1$
return new URL(url, location);
} catch (MalformedURLException e) {
return null;
}
}
protected String getTemplateDirectory() {
String schemaVersion = model.getPluginBase().getSchemaVersion();
if (schemaVersion != null)
return "templates_" + schemaVersion; //$NON-NLS-1$
return "templates"; //$NON-NLS-1$
}
I really dont understand this default behaviour; using the
SchemaVersion (3.2 for Eclipse 3.2 and next versions) it ends to return
the URL for the templates_3.2 folder, which coincides with the example
folder (so it works). I think it could have more sense to use the target
version of your plugin than the schema version; schema version is the
same for multiple cases.
Anyway, its better to implement getTemplateLocation to be sure that
it returns what you need. There are templates and their sources in any
Eclipse distribution. I recommend to read the code of those templates if
you have troubles.
Best regards,
Miguel
|
|
|
Powered by
FUDForum. Page generated in 0.04375 seconds