tag:blogger.com,1999:blog-5324486046611289266.post2736558341550710293..comments2013-04-12T12:09:10.052-07:00Comments on A Chemical RCP Adventure: New Plug-in Wizard template: Can I add Import-Package programmatically?Egon Willighagenhttp://www.blogger.com/profile/07470952136305035540noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-5324486046611289266.post-37170894483349406152013-04-12T11:00:34.774-07:002013-04-12T11:00:34.774-07:00Really.... a cool Plug-in Wizard template for Bioc...Really.... a cool Plug-in Wizard template for Bioclipse. kudos :)Anonymoushttps://www.blogger.com/profile/16348348168411097006noreply@blogger.comtag:blogger.com,1999:blog-5324486046611289266.post-20148218322663081082009-09-10T14:51:39.883-07:002009-09-10T14:51:39.883-07:00OK, I found a dirty hack which is using deprecated...OK, I found a dirty hack which is using deprecated APIs, but at least works: adding the following to the Template class:<br /><br /> @Override<br /> public void execute(IProject project, IPluginModelBase model,<br /> IProgressMonitor monitor) throws CoreException {<br /> IPluginBase pluginBase = model.createPluginBase();<br /> if (pluginBase instanceof BundlePluginBase) {<br /> IBundle bundle = ((BundlePluginBase) pluginBase).getBundle();<br /> bundle.setHeader("Import-Package", "org.apache.log4j");<br /> model.createPluginBase().getId();<br /> String packageName = getFormattedPackageName(<br /> model.getPluginBase().getId()<br /> );<br /> bundle.setHeader(<br /> "Export-Package",<br /> packageName + ", " +<br /> packageName + ".business"<br /> );<br /> }<br /> super.execute(project, model, monitor);<br /> }Egon Willighagenhttps://www.blogger.com/profile/07470952136305035540noreply@blogger.comtag:blogger.com,1999:blog-5324486046611289266.post-9401253737303812362009-09-10T14:00:05.080-07:002009-09-10T14:00:05.080-07:00No, I just cannot get it to work... I actually hav...No, I just cannot get it to work... I actually have one more problems... the packages that the templates are not exported with Export-Package: in the MANIFEST.MF either... :(<br /><br />Quite depressing... I'll try to step-by-debug-step through the whole performFinish() to learn a bit more on why this is failing for me... :(Egon Willighagenhttps://www.blogger.com/profile/07470952136305035540noreply@blogger.comtag:blogger.com,1999:blog-5324486046611289266.post-18511429224977224132009-09-08T10:27:18.703-07:002009-09-08T10:27:18.703-07:00Looks fine, looking at the HelloOSGiServiceWizard....Looks fine, looking at the HelloOSGiServiceWizard...<br /><br /> public String[] getImportPackages() {<br /> return new String[] {"org.osgi.framework;version=\"1.3.0\"", "org.osgi.util.tracker;version=\"1.3.1\""}; //$NON-NLS-1$ //$NON-NLS-2$<br /> }Chris Aniszczyk (zx)https://www.blogger.com/profile/14067673601779593093noreply@blogger.comtag:blogger.com,1999:blog-5324486046611289266.post-29088916086987186682009-09-08T06:45:14.109-07:002009-09-08T06:45:14.109-07:00@Chris and @Jacek:
First of all, thanx very much ...@Chris and @Jacek:<br /><br />First of all, thanx very much for your feedback... I'm trying to get it working, but need a bit more info I think...<br /><br />We have a class:<br /><br />public class ManagerWizard extends NewPluginTemplateWizard {}<br /><br />to which I just added:<br /><br /> @Override<br /> public String[] getImportPackages() {<br /> String[] superPkg = super.getImportPackages();<br /> String[] pkgs = new String[superPkg.length+1];<br /> System.arraycopy(superPkg, 0, pkgs, 0, superPkg.length);<br /> pkgs[pkgs.length-1] = "org.apache.log4j";<br /> return pkgs;<br /> }<br /><br />Our plugin.xml for this class looks like:<br /><br /><extension<br /> point="org.eclipse.pde.ui.pluginContent"><br /> <wizard<br /> class="net.bioclipse.sdk.pdewizard.ManagerWizard"<br /> icon="icons/bioclipse_16.png"<br /> id="net.bioclipse.sdk.template.wizard"<br /> java="true"<br /> name="Bioclipse Manager Wizard"<br /> pureOSGi="false"<br /> rcp="false"<br /> requiresActivator="false"<br /> ui-content="true"><br /> </wizard><br /></extension><br /><br />Does that look about right? As it does not add the imports line... :(Egon Willighagenhttps://www.blogger.com/profile/07470952136305035540noreply@blogger.comtag:blogger.com,1999:blog-5324486046611289266.post-27490600781357053782009-09-08T04:36:03.021-07:002009-09-08T04:36:03.021-07:00Jacek is correct, use the getImportPackages() meth...Jacek is correct, use the getImportPackages() method... it's a bit wonky but there are example templates in the org.eclipse.pde.ui.templates plug-inChris Aniszczyk (zx)https://www.blogger.com/profile/14067673601779593093noreply@blogger.comtag:blogger.com,1999:blog-5324486046611289266.post-1352103073938001152009-09-08T03:00:46.454-07:002009-09-08T03:00:46.454-07:00I'm adding Import-Package to MANIFEST.MF progr...I'm adding Import-Package to MANIFEST.MF programmatically as part of my oaw - generator - workflow.<br />this week I have no time - please remember me nex t week (ekke_at_ekkes-corner.org) then I can publish my solution - perhaps it helps.<br />ekkeAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5324486046611289266.post-12277131499745026612009-09-08T01:06:53.303-07:002009-09-08T01:06:53.303-07:00regarding adding Import-Package, I believe you can...regarding adding Import-Package, I believe you can do this by extending NewPluginTemplateWizard.getImportPackages()Jacek Pospychalahttps://www.blogger.com/profile/16627298669538613040noreply@blogger.com