I am working on Eclipse RCP application, I want to achieve the eclipse workspace job with a Dialog with the buttons like "Run in Background", "Cancel" and "Details". I tried all the options but all my efforts did not bear fruit. However I am able to create ProgressBar with ProgressMonitor dialog with cancel button. I want to achieve like the image given below. Please help me in this regard. I also went through the following link along with other links. I also tried with IProgressService but it did not work. Currently I am working in Eclipse Photon version.
https://www.eclipse.org/articles/Article-Concurrency/jobs-api.html
I provide below the code for workspace job
public void show11() {
Job job =
new WorkspaceJob("name") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
for (int i = 0; i < 10; i++) {
System.out.println("This is a MYJob");
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
monitor.subTask("Copying file " + (i + 1) + " of " + "workload" + "...");
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
try
{
job.join();
}
catch (InterruptedException e)
{
//
}
}
Finally I solved this problem. It is assumed that "Run in Background" is set by default for eclipse RCP application. In my case I had to switch of this option from Eclipse, still it did not work. I have done manually to make it false in my eclipse rcp. I provide below. the code.
WorkbenchPlugin.getDefault().getPreferenceStore().setValue("RUN_IN_BACKGROUND", false);
Those who are facing this kind of problem, they can set this value programmatically while developing eclipse rcp application.
I would like to thank Greg Sir (greg-449) for providing some tips and information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With