RSS

Search Engine

Wednesday, June 30, 2010

Example

The following assumes that you are familiar with Eclipse RCP development .

Create a new Eclipse RCP project "de.vogella.jobs.first" with the "Hello RCP" example. Create one command "de.vogella.jobs.first.runJob1" with the following default handler.

   
package de.vogella.jobs.first.handler;


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.ui.handlers.HandlerUtil;

public class RunJob1 extends AbstractHandler {

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
Job job = new Job("First Job"){
@Override
protected IStatus run(IProgressMonitor monitor) {

for (int i=0; i<10;>

Add the command to the menu.

Run your application to see the Job API in action.

0 comments:

Post a Comment