コード例 #1
0
  public void run(
      final INonInterruptibleRunnableWithProgress runnable, final IProgressMonitor monitor)
      throws InvocationTargetException {
    Runnable actualRunnable =
        new Runnable() {
          @Override
          public void run() {
            try {
              runnable.run(monitor);
            } catch (InvocationTargetException e) {
              model.crashed(e);
            } catch (RuntimeException e) {
              model.crashed(e);
            } catch (Error e) {
              model.crashed(e);
            } catch (Throwable e) {
              model.crashed(new InvocationTargetException(e));
            } finally {
              synchronized (model) {
                model.finished();
                model.notifyAll();
              }
              progressComponent.dispose();
            }
          }
        };
    defaultExecuter.execute(actualRunnable);

    try {
      if (millisecondsUntilDialogPopup > 0) {
        synchronized (model) {
          if (!model.isFinished()) {
            model.wait(millisecondsUntilDialogPopup);
          }
        }
      }
      if (!model.isFinished()) {
        progressComponent.show();
      }
      model.throwThrowableIfAny();
    } catch (InterruptedException e) {
      throw new RuntimeException(
          "InterruptedException during non interruptable progress", e); // $NON-NLS-1$
    }
  }
コード例 #2
0
  public void run(
      final IInterruptibleRunnableWithProgress runnable,
      final IProgressMonitor progressMonitor,
      final IObservableCancelable cancelable)
      throws InterruptedException, InvocationTargetException {
    Runnable actualRunnable =
        new Runnable() {
          @Override
          public void run() {
            try {
              runnable.run(progressMonitor, cancelable);
            } catch (InterruptedException e) {
              model.interrupted(e);
            } catch (InvocationTargetException e) {
              model.crashed(e);
            } catch (RuntimeException e) {
              model.crashed(e);
            } catch (Error e) {
              model.crashed(e);
            } catch (Throwable e) {
              model.crashed(new InvocationTargetException(e));
            } finally {
              synchronized (model) {
                model.finished();
                model.notifyAll();
              }
              progressComponent.dispose();
            }
          }
        };
    defaultExecuter.execute(actualRunnable);

    synchronized (model) {
      if (!model.isFinished()) {
        model.wait(millisecondsUntilDialogPopup);
      }
    }
    if (!model.isFinished()) {
      progressComponent.show();
    }

    model.throwThrowableIfAny();
  }