Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to achieve eclipse Progress bar with Details button like eclipse workspace job

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

enter image description here

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)
   {
     //
   }

}

like image 776
Sambit Avatar asked Jul 23 '18 15:07

Sambit


1 Answers

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.

like image 89
Sambit Avatar answered Oct 27 '22 09:10

Sambit