Posts Tagged ‘PDE’

Eclipse PDE templates – Your action is my command

Wednesday, September 23rd, 2009

The Eclipse PDE templates are fantastic to help people to learn the platform and to get oven the first initial resistence to start with Eclipse RCP or Eclipse Plugin development.

Templates indicates to their consumers that they represent best development practices. This puts a certain burden on the quality to the templates. Unfortunately the PDE RCP templates in Eclipse 3.5 were all based on actions which I believe are superseded by Eclipse Commands.

I have seen in the past lots of questions regarding actions in the Eclipse RCP and PDE newsgroups. I believe that at least some of these questions are based on the fact that the PDE templates still promote actions.

I’m therefore happy to see the changes of Bug 265231 applied for the “RCP with a view” template for the upcoming Eclipse 3.6. Special thanks for this to Chris Aniszczyk.

It also looks good for the mail example. It seems that work is happening in Bug 253105

Actions are (a little bit more) dead. Long live the command! ;-)

 

Eclipse Papercut #4 – Modifying Eclipse PDE default launch configuration

Monday, July 27th, 2009

In this episode of the Eclipse Papercut series I will change the default PDE launch configuration. During this process I show how to get and modify Eclipse PDE code.

Lets define the papercut:

One thing I always have to do during plugin and Eclipse RCP development is to make the following settings in the launch configuration:

  1. add -consoleLog in the arguments tab
  2. Select the flag “Validate plug-in automatically prio to launching” on the plug-ins tab

This papercut has two dimensions.

The first one is that for everybody who knows about these settings it is not a problem to set them up. It is just time-consuming and error prone. Sometimes I’m searching why something does not work and then I’m banging my head because I forgot to set -consoleLog.

The second dimension is that this default launch configuration makes it harder for new plugin and Eclipse RCP developers to get started. I frequently see questions in the Eclipse newsgroup and other places which can be answered by: “please set -consoleLog” or “press the Validate button”.

So I seek to change the current behavior.

Adding “-consoleLog” is easy. Go to preference, select the target platform, select “Edit” and add -consoleLog as a argument.

target10

target20

Of course this does not help the new developers but I come back to this later in this post.

To set the “Validate plug-in automatically prio to launching” flag we have to look into Eclipse PDE code.

A launch configuration is contributed by the extension point “org.eclipse.debug.core.launchConfigurationTypes”. To search through your existing plugins import your plugins into a new workspace. A plugin search reveals that “org.eclipse.pde.ui” contributes such an extension.

Eclipse PDE can be found in the Eclipse cvs via the repository path “/cvsroot/eclipse”. Search here for the folder “pde” which contains the pde plugins. Checkout the plugin “org.eclipse.pde.ui”.

Here we find quickly the right extension point.

pde10

After some pocking around the code and some debugging I found the class “AbstractPluginBlock” and the method “setDefaults”. The change is trivial:

public void setDefaults(ILaunchConfigurationWorkingCopy config) {
	config.setAttribute(IPDELauncherConstants.INCLUDE_OPTIONAL, true);
	config.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true);
	config.setAttribute(IPDELauncherConstants.AUTOMATIC_VALIDATE, true); // This has changed from false to true
	config.setAttribute(IPDELauncherConstants.SHOW_SELECTED_ONLY, false);
}

If you now run Eclipse with this adjusted plugin the flag “Validate…” will be flagged for a new runtime configuration.

Now lets return to the addtion of “-consoleLog” to the target platform. I argued earlier that the absence of “-consoleLog” makes it harder for beginner to get started with plugin and RCP development. Changing the target platform is not trivial for starters, so the better solution was if was part of the standard code.

We find the relevant code easily with a text seach for an existing launch parameter, e.g. “-arch”. The responsible class is “LaunchArgumentsHelper” and the method getInitialProgramArguments(). We add “-consoleLog” to the following line:


StringBuffer buffer = new StringBuffer("-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"); //$NON-NLS-1$

Thats it. By deploying the plugin into our Eclipse IDE we have the changed behavior.

I have submitted bugs and attached the patches. Bug Report for “Validate plug-in automatically prio to launching” and Bug Report for -consoleLog.

I hope that these patches will get accepted. If they would be accepted I believe it would be a little easier for new developers to get started.

If someone finds a reason why these settings should not always be the default I would suggest a new PDE preference page which contains the settings for these launch parameters.