Below piece of code shows how can we run the eclipse jobs interactively by showing eclipse progress dialog using Eclipse Jobs API.
Job installationJob = new Job("Creating a new creating catalog...")
Job installationJob = new Job("Creating a new creating catalog...")
{
@Override
public IStatus run(IProgressMonitor monitor)
{
try
{
monitor.beginTask("creating catalog...", 10);
//do your task here
}
finally
{
monitor.done();
}
return Status.OK_STATUS;
}
};
installationJob.setPriority(Job.INTERACTIVE);
//This is alternative to the installationJob.setUser(true);
//sometimes setUser(true) doesn't show up the progress dialog, in those cases below piece of code can be used.
PlatformUI.getWorkbench().getProgressService()
.showInDialog(Display.getDefault().getActiveShell(), installationJob);
installationJob.schedule();