Extension Point Templates: External Development
As a continuation from my previous entry regarding the development of templates for extensions points I will now explain how to create the template in a separate plug-in. The main steps are essentially the same; the two required extension points (org.eclipse.pde.ui.newExtensions and org.eclipse.pde.ui.templates) should be added with the appropriate elements, the template class file should be developed, and a templates_3.X folder should be created (where 3.X represents the package schema version) to hold the java and bin files.
The key change in the implementation is that the template class file should subclass OptionTemplateSection rather than PDETemplateSection (since PDETemplateSection is internal to the org.eclipse.pde.ui package). While the majority of the code can remain the same, the method getFormattedPackageName(String id) will need to be updated to so that the supplied package name corresponds to the usual naming standards. This involves replacing the call to super with functionality that will only use java identifier characters and a lower case letter to begin the package name. Furthermore, the abstract methods getInstallURL() and getPluginREsourceBundle() need to be implemented; some sample code is shown below:
Bundle bundle = Platform.getBundle(UITemplateMessages.Bundle_name);
return Platform.getResourceBundle(bundle);
}
protected URL getInstallURL() {
Bundle bundle = Platform.getBundle(UITemplateMessages.Bundle_name); return bundle.getEntry("/");
}
Note: The use of the variable UITemplateMessages.Bundle_name implies that there is an additional class file named UITemplateMessages that declares externalized strings and points to a file named messages.properties for their definitions.
Beyond making small adjustments to fit the specific extension point and confirming that all file references exist in the plug-in package, there isn’t much more that needs to be done. To test it, simply self host, find your template in the list of Extension Wizards and you’re on your way.
0 Comments:
Post a Comment
<< Home