Extension Point Templates are a great

In the last week I created my first Eclipse extension point template. Once again I am amazed with the ease and power of another rarely mentioned yet powerful Eclipse PDE feature. After going through the exercise I think all extensions should have at least one template. I have an extension point that takes in a class file (which implements an interface), an XML file (WSDL to be exact) and then some other attributes. The problem with the extension point is the WSDL has custom bindings that do not come for free with the WTP WSDL editor. So in short, unless the WTP WSDL editor is extended, creating this WSDL from scratch can be cumbersome. I also think the linking of the class with whatever interface is needed should also come for free.

What is a template you ask?

Here is a screen shot of what I am talking about:


You can have as many templates as you want for any of your extension points. The ActionSets extension in that screen shot creates the extension and the java files associated with them. I actually referenced the Eclipse code in the UI package to figure out how to do this (once again, open source allowed for this). I can not say how valuable it is to be able to just look at source and figure things out. Unfortunately the quick searches I did for this subject yield poor results (of which I am sure someone will respond to this and provide better search results).

You can look at a lot of good template samples under the package org.eclipse.pde.internal.ui.wizards.templates in the org.eclipse.pde.ui plugin. The SampleAction template is what is displayed in that screen shot above.

What makes this concept so interesting is how you can put tokens in the file names and code that are wrapped in $’s and they will automatically be replaced by the fields you specify on the wizard forms. For instance, you add a text field to the wizard page and give the field the name className and wherever “$className$” is in the template directories it will be replaced with the users input.

In the case of the ActionSet extension template there was a file named $className$.java and the contents of that file start with this code:

package $packageName$;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.jface.dialogs.MessageDialog;

* Our sample action implements workbench action delegate.
* The action proxy will be created by the workbench and
* shown in the UI. When the user tries to use the action,
* this delegate will be created and execution will be
* delegated to it.
* @see IWorkbenchWindowActionDelegate

public class $className$ implements IWorkbenchWindowActionDelegate {
private IWorkbenchWindow window;
* The constructor.

public $className$() {

Every place you see the $xxxx$ tokens they will be replaced with the user input and of course this includes file names. The files are also processed in a very specific manner and the JavaDoc explains it very well for the generateFiles() method in the OptionTemplateSection class. Here is the doc for that field:

Generates files as part of the template execution. The default implementation uses template location as a root of the file templates. The files found in the location are processed in the following way:

  • Files and folders found in the directory bin are copied into the target project without modification.
  • Files found in the directory java are copied into the Java source folder by creating the folder structure that corresponds to the package name (variable packageName ). Java files are subject to conditional generation and variable replacement.
  • All other files and folders are copied directly into the target folder with the conditional generation and variable replacement for files. Variable replacement also includes file names.

I would have liked to post some sample code but I do not get paid for this so oh well.

Happy template creation!

Eclipse documentation Extension Templates

<!– Edited by Bob@balfes.net on Wed Aug 30 20:20:21 2006–>

Portal Technical Conference

On Monday I am off to present at the IBM WebSphere Portal Technical Conference in Stuttgart Germany. My talk (Extending Portal for offline and managed clients) is on Wednesday and it is about taking your portlet applications off-line with the Lotus Expeditor along with integration of your portlet applications with Eclipse based applications.

The sample application shows how different components (portlets, SWT views, etc) are aggregated by the portal and wired together using the Portal Admin UI. We demonstrate Portlet to SWT, Portlet to Portlet and SWT to SWT communications.

I will also be presenting the week after in Baltimore in the U.S. version of the conference.

Looks like Apple Batteries are next to go up in flames

Article on CNN: Japan orders Apple battery probe

appleThis is probably an issue to some extent but I sometimes wonder the real conditions these laptops are going up in flames. I know my Thinkpad laptops are very hot (actually the T60p seems to be cooler than the T40’s). How much of this is hype and how much is reality?

New article on Portal 6 Composite Applications

There is an excellent article on Portal 6 and the new composite application infrastructure. The article is in a pdf that can be downloaded here with sample code here.

Composite applications aggregate a set of components into a single, coherent entity. The individual components and the interactions among these components can work together to implement complex business logic as defined by a business user. Components of a composite application can be virtually any code artifacts including Java™ classes, portlets, EJBs, or plain old Java objects (POJOs). Meta data describes the behavior and configuration for each involved component such as a reference to a document library or a workflow definition.

The model is used in the up and coming release of the Lotus Expeditor 6.1.

Vegas was hot and fun

As we all knew it was very hot in Vegas last week. I was pretty much disconnected while there and had the luxury of coming home at 11pm and flying to Austin at 6:30 the next morning! So in short, blogging has taken a second place to fun, travel and work. We only saw one show in Vegas and I think if we go back we will probably schedule to see more prior to going.

We didn’t lose our shirts and since I am still blogging and working we obviously did not beat the house.