Archive for the 'IT' Category

Feb 11 2009

Automatic PDE build with Pluginbuilder

Published by under Eclipse

Pluginbuilder is Eclipse tool that generates build configuration based on PDE build. By default the tool generates map file containing the information how source code of the plug-ins should be obtained. Supported methods are: CVS, GET and COPY. Assuming that you want to build your features or product from source files that are checked-out from repository independently from the build process COPY options seems to look reasonable. There are few problems with that:

  • it requires absolute paths to plug-ins/features locations
  • every single plug-in has to be listed there

Workaround for this is not using map file at all and provide appropriate build directory structure outside. To skip fetching resources based on map file configuration one need to set skipMaps property in file. Next step is to configure getting plug-ins/features resources into build directory. Recommended phase for copying the source code is preSetup phase in PDE build. To hook into this phase standard ant task for copying the files/directories in to build directory have to be invoked in preSetup target in customTargets.xml (it is generated by Pluginbuilder as well as other configuratoin files in build-files directory).

Those two modifications allow to make use of Pluginbuilder generated scripts to build Eclipse based applications without coupling it tightly to version control system.

One response so far

Feb 08 2009

WordPress upgrade

Published by under IT

I have finally upgraded my WordPress installation to version 2.7 … from version 2.3.2 – shame on me.

Upgrade went smoothly, my first impression: automatic upgrade of the plug-ins is really great!

No responses yet

Feb 04 2009

Eclipse Jobs API – Errata

Published by under Eclipse,IT,Java

My colleague Lukasz Milewski has just spotted a missing piece in a code sample for creating icons presented in previous post. In the screenshot you can see nice icons for currently running Jobs as well as for scheduled Jobs. You need to set two properties in your Job implementation to associate an icon with it.

	setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);
	setProperty(IProgressConstants.ICON_PROPERTY, ImageDescriptorFactory

4 responses so far

Jan 14 2009

Using Eclipse Jobs API

Published by under Eclipse,IT,Java

Eclipse platform offers great API for managing long running operations in the background. Besides the API for starting, stopping and monitoring progress of the Job – there is also standard UI for managing all those operations. I’m going to present sample usage of Jobs API in you own plug-in/application.

Creating and scheduling Job may look like this:

 TrainJob job = new TrainJob(TRAIN_JOB_NAME + file.getName(), classifier);
 job.schedule(); // start as soon as possible

Sample of custom Job:

import static org.eclipse.core.runtime.Status.OK_STATUS;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
 * Class for execution of training of a classifier
 * @since 1.0
public class TrainJob extends Job {
 private AbstractClassifier classifier;
  * Public constructor TrainJob
  * @param name Train job name
  * @param classifier Classifier to be trained
 public TrainJob(String name, AbstractClassifier classifier) {
 	this.classifier = classifier;
 protected IStatus run(IProgressMonitor monitor) {
 	// Long running operation - in this case classifier training
       // ...
       return OK_STATUS;

Standard GUI for presenting Job progress:

Jobs API View

3 responses so far

Sep 09 2008

Eclipse RCP tips and tricks

Published by under Eclipse,IT,Java

Recently I had to do couple of tricks Eclipse RCP applications. Basically all of the pieces of code presented below need to be placed in method initialize(IWorkbenchConfigurer configurer). You need to override this method in WorkbenchAdvisor subclass.

  • Displaying icons in Navigator View
    final String ICONS_PATH = "icons/full/";
    final String PATH_OBJECT = ICONS_PATH + "obj16/";
    Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH);
    declareWorkbenchImage(configurer, ideBundle,
    IDE.SharedImages.IMG_OBJ_PROJECT, PATH_OBJECT + "prj_obj.gif", true);
    declareWorkbenchImage(configurer, ideBundle,
    + "cprj_obj.gif", true);
  • Enabling Decoration Context
    DecorationContext dc = (DecorationContext) DecorationContext.DEFAULT_CONTEXT;
    dc.putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE);
  • Enabling Jobs Progress Bar
    IWorkbench wb = PlatformUI.getWorkbench();

Probably you don’t need any of those when running your plug-ins in Eclipse IDE. The tricky part is running it in a stripped to minimum RCP based applications.

One response so far

Sep 05 2008

Firefox, Chrome – WTF?

Published by under IT

Chrome installed, Firefox set as default browser.

Warning during opening GMail from GTalk:

Chrome - WTF?


3 responses so far

Sep 02 2008

Google Chrome

Published by under IT

I have just installed a newest baby of Google on my laptop… Google Chrome – a web browser. It’s fast… and fully integrated with Google services… and stable (per Google). I’m afraid of this monster… 

No responses yet

Aug 12 2008

Eclipse RCP launcher icon

Published by under Eclipse,IT,Java

Eclipse RCP allows easily create an application. Additional advantage of the platform is a native launcher of the application which allows it to behave more like “native” application. It much better to have a process called your_application.exe running instead of another java.exe process.  You will probably also want to have some nice icon attached to *.exe file of your application. This can be done easily in Eclipse 3.4. First you need to create *.ico file (containing all necassary images inside) – one of the generators available on the web can be used for this (for example).

Next step is configuration in *.product file:

   <launcher name="caracal">
      <win useico="true">
         <ico path="/"></ico>

You can also use product file editor for this (a lot of enhancements were added in Eclipse 3.4):

Launcher icon configuration

After building the application based on product file launcher will have your custom icon. No resource hacking, nor recompiling native C code is required!

Launcher custom icon

2 responses so far

Aug 05 2008

Long-running operation in a wizard page

Published by under Eclipse,IT,Java

Some time you may need to do some long running operation in one of the pages in your wizard. Probably the best solution would be to redesign the flow of an application in such way that this operation can be performed outside the wizard as a background task (using Eclipse Jobs API). If you really need to place this inside wizard than in order to not freeze your application completely with such operation you can use IRunnableWithProgress. Sample usage of this interface is presented below.

import java.lang.reflect.InvocationTargetException;
import java.util.logging.Logger;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
 * Wizard Page with long running operation
public class DummyWizardPage extends WizardPage {
    private Logger logger = Logger.getLogger(DummyWizardPage.class.getName());
    protected DummyWizardPage(String pageName) {
     * {@inheritDoc}
    public void createControl(Composite parent) {
	Composite composite = new Composite(parent, SWT.NONE);
	Button button = new Button(composite, SWT.PUSH);
	button.addSelectionListener(new SelectionAdapter() {
	    public void widgetSelected(SelectionEvent event) {
		try {
		    // Invoking long running operation
		    getContainer().run(true, false,
			    new IRunnableWithProgress() {
				public void run(IProgressMonitor monitor)
					throws InvocationTargetException,
					InterruptedException {
				    // Some time consuming operation
		} catch (InvocationTargetException e) {
		} catch (InterruptedException e) {
	// Setting control for Wizard Page

3 responses so far

Jul 26 2008

Help in Eclipse RCP application

Published by under Eclipse,IT,Java

Until you are working at Google or Apple your applications probably requires some sort of help system (UX). Eclipse help system can be easily reused in your custom application based on Eclipse RCP.

Let assume that you already have RCP application (if not you can use one of the wizards provided in Eclipse to get one).  In order to enable help there you need to add three dependencies explicitly in plugin.xml:

  • org.eclipse.equinox.http.jetty

After adding those make sure to update *.product configuration and add all new required dependencies.

The next step is adding an extension which will provide the help content in plug-ins that will contribute it. The extension point that provides this feature is: (there is one template with dummy help content available to choose in Extension Point Selection form).

Now some menu item that will launch help needs to be added. It can be done in plugin.xml:

  • Add an extension (if you don’t have it already) : org.eclipse.ui.menus
  • Add new element: menuContribution with locationURI menu:file
  • Add new command with id:

Last step is registering an action that will be binded to previously created menu item. It can be done in a class that extends ActionBarAdvisor (if you created your RCP application using default wizard it will be called ApplicationActionBarAdvisor. You need to override one method:

protected void makeActions(IWorkbenchWindow window) {
	this.contentsHelpAction = ActionFactory.HELP_CONTENTS.create(window);

Now help system with sample content should be available in Help menu. It will launch separate window and display content there. A help content can be provided by any plug-in extending extension point. It is set of HTML documents which are displayed together in one common place, framework provides built-in search, index, table of contents etc (Eclipse uses Jetty as a web server, try this in a browser).

2 responses so far

« Prev - Next »