title: How to set worked precisely in IProgressMonitor in Eclipse plugin?
body: <p>The method <code>org.eclipse.core.runtime.IProgressMonitor.worked(int)</code> receives integer which means increment. This means, that the only units available are natural units. It can't be percents, for example.</p>
  
  <p>So, if I process some files in the job, I can't report the counting stage, because the first method I should call is <code>org.eclipse.core.runtime.IProgressMonitor.beginTask(String, int)</code> which requires me to know the total amount.</p>
  
  <p>How to accomplish?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I wrote a wrapper below, but this looks absurd one need to do so:</p>
  
  <pre><code>public class ProgressMonitorDoubleWrapper implements IProgressMonitor {
  
      private IProgressMonitor delegate;
      private int currentWork, totalWork;
      private double currentWorkDouble;
  
      public ProgressMonitorDoubleWrapper(IProgressMonitor monitor) {
          this.delegate = monitor;
      }
  
      @Override
      public void beginTask(String name, int totalWork) {
          beginTask(name, (double) totalWork); 
      }
  
      public void beginTask(String name, double totalWork) {
          this.totalWork = (int) totalWork;
          currentWork = 0;
          currentWorkDouble = 0;
          delegate.beginTask(name, this.totalWork);
      }
  
      @Override
      public void done() {
          delegate.done();
      }
  
      @Override
      public void internalWorked(double work) {
          delegate.internalWorked(work);
      }
  
      @Override
      public boolean isCanceled() {
          return delegate.isCanceled();
      }
  
      @Override
      public void setCanceled(boolean value) {
          delegate.setCanceled(value);
      }
  
      @Override
      public void setTaskName(String name) {
          delegate.setTaskName(name);
      }
  
      @Override
      public void subTask(String name) {
          delegate.subTask(name);
      }
  
      @Override
      public void worked(int work) {
          worked((double)work);
      }
  
      public void worked(double work) {
          currentWorkDouble += work;
          int increment = (int)(currentWorkDouble - (double)currentWork);
          currentWork += increment;
          delegate.worked(increment);
      }
  
  }
  </code></pre>