Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Problems building my own plugin template
Problems building my own plugin template [message #379] Wed, 09 April 2008 10:05 Go to next message
Miguel Garcia is currently offline Miguel GarciaFriend
Messages: 6
Registered: July 2009
Junior Member
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, I’m 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 article’s example (that works) I found a behaviour
I don’t understand. The example contains a templates_3.2 folder, in which
it contains the section with the template files to be modified by the
user’s selections. If I rename this folder to templates_3.3 for example,
it stop working (creates a plugin from the template, but don’t include the
template class modified by user’s choices). I’m 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 didn’t find any reference
to it.

Thanks in advance,

Miguel
Re: Problems building my own plugin template [message #411 is a reply to message #379] Thu, 10 April 2008 06:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: zx.us.ibm.com

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 #418 is a reply to message #411] Thu, 10 April 2008 12:40 Go to previous message
Miguel Garcia is currently offline Miguel GarciaFriend
Messages: 6
Registered: July 2009
Junior Member
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 didn’t 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 don’t 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, it’s 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 06:36 Go to previous message
Chris Aniszczyk is currently offline Chris AniszczykFriend
Messages: 674
Registered: July 2009
Senior Member
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 12:40 Go to previous message
Miguel Garcia is currently offline Miguel GarciaFriend
Messages: 6
Registered: July 2009
Junior Member
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 didn’t 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 don’t 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, it’s 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
Previous Topic:Unable to send mail in eclipse version 3.3 and later
Next Topic:Scala OSGi plugin template
Goto Forum:
  


Current Time: Tue Apr 23 17:27:36 GMT 2024

Powered by FUDForum. Page generated in 0.03831 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top