package org.fredy.eclipsepluginexample.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;

public class SampleHandler extends AbstractHandler {
    @Override
    public Object execute(final ExecutionEvent event) throws ExecutionException {
        final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
        Job job = new Job("About to say hello") {
            @Override
            protected IStatus run(IProgressMonitor monitor) {
                monitor.beginTask("Preparing", 5000);
                try {
                    for (int i = 0; i < 5; i++) {
                        Thread.sleep(1000);
                        monitor.worked(1000);
                    }
                } catch (InterruptedException e) {}
                finally {
                    monitor.done();
                }
                
                Display.getDefault().asyncExec(new Runnable() {
                    public void run() {
                        MessageDialog.openInformation(
                            window.getShell(),
                            "Eclipse Plugin Example",
                            "Hello, Eclipse world");
                    }
                });
                return Status.OK_STATUS;
            }
        };
        job.schedule();
        return null;
    }
}

@@ -93,16 +93,58 @@
 andler;%0A
+import org.eclipse.core.commands.Command;%0A
 import o
@@ -237,16 +237,71 @@
 eption;%0A
+import org.eclipse.core.commands.ParameterizedCommand;%0A
 import o
@@ -513,16 +513,67 @@
 Dialog;%0A
+import org.eclipse.jface.resource.ImageDescriptor;%0A
 import o
@@ -670,28 +670,162 @@
 .ui.
-handlers.HandlerUtil
+PlatformUI;%0Aimport org.eclipse.ui.commands.ICommandService;%0Aimport org.eclipse.ui.handlers.HandlerUtil;%0Aimport org.eclipse.ui.progress.IProgressConstants2
 ;%0A%0Ap
@@ -2006,16 +2006,612 @@
      %7D;%0A
+        ICommandService service = (ICommandService) PlatformUI.getWorkbench()%0A            .getService(ICommandService.class);%0A        Command command = service.getCommand(%0A            %22org.fredy.eclipsepluginexample.ui.commands.sampleCommand%22);%0A        if (command != null) %7B%0A            job.setProperty(IProgressConstants2.COMMAND_PROPERTY,%0A                ParameterizedCommand.generateCommand(command, null));%0A        %7D%0A        job.setProperty(IProgressConstants2.ICON_PROPERTY,%0A            ImageDescriptor.createFromURL(%0A                SampleHandler.class.getResource(%22/icons/sample.gif%22)));%0A
         

Set properties in the job