Month: August 2008

Eclipse RCP launcher icon

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

Long-running operation in a wizard page

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