Question

On click of OK button of my JFace dialog i would like to show progress on the workbench status line. How would I achieve this?

Was it helpful?

Solution

You use a Job (org.eclipse.core.runtime.jobs.Job) to show progress in the status line progress indicator:

Job job = new MyJob();

job.schedule();


class MyJob extends Job
{
  MyJob()
  {
    super("Job name");
  }

  public IStatus run(IProgressMonitor monitor) 
  {
    monitor.beginTask("Job", workCount);
    try
     {
        ... work
     }
    finally
     {
       monitor.done();
     }

    return Status.OK_STATUS;
  }
}

The job runs in the background so will actually run after your dialog closes.

Note: If you use a Wizard that has a progress bar at the bottom of the wizard that you can use (how you use this is different).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top