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

1

5

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

}

Authenticate answered 23/7, 2018 at 15:59 Comment(10)
So why not just use a Job or WorkspaceJob with setUser(true) which will display this dialogBellyful
Hi Greg, I followed all your all posts in stackoverflow, but it is not working as per the image given.I want to achieve with the three buttons like "Run in Background", "Cancel" and "Details >>".Authenticate
Sorry but with setUser(true) Eclipse displays org.eclipse.ui.internal.progress.ProgressMonitorFocusJobDialog which has these three buttons. Show us the code you are trying.Bellyful
Hi Greg, I have posted the code.Authenticate
With the above code, it does not pop up the dialog box.Authenticate
Calling job.join() blocks the UI thread so the dialog cannot be displayed - don't do this in the UI thread.Bellyful
I tried by commenting out the code, still it does not pop up the dialog. It runs in my progressView view.Authenticate
Check you don't have 'Always run in background' selected in the General page of the Preferences.Bellyful
I checked it, still it does not.Authenticate
I found a similar issue, the link is given below. eclipsezone.com/eclipse/forums/t30941.html. This is my exact problem in Photon.Authenticate
A
7

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.

Authenticate answered 23/7, 2018 at 18:47 Comment(2)
Sure Sir. I will do it.Authenticate
OK Sir, got it and did it.Authenticate

© 2022 - 2024 — McMap. All rights reserved.