コード例 #1
0
  /**
   * @param ji
   * @param job
   */
  private void execute(JobInfo ji, Job job) {

    Object prop = job.getProperty(IProgressConstants.ACTION_PROPERTY);
    if (prop instanceof IAction && ((IAction) prop).isEnabled()) {
      IAction action = (IAction) prop;
      action.run();
      removeTopElement(ji);
    }

    prop = job.getProperty(IProgressConstants2.COMMAND_PROPERTY);
    if (prop instanceof ParameterizedCommand) {
      ParameterizedCommand command = (ParameterizedCommand) prop;
      IWorkbenchWindow window = getWindow();
      IHandlerService service = (IHandlerService) window.getService(IHandlerService.class);
      Exception exception = null;
      try {
        service.executeCommand(command, null);
        removeTopElement(ji);
      } catch (ExecutionException e) {
        exception = e;
      } catch (NotDefinedException e) {
        exception = e;
      } catch (NotEnabledException e) {
        exception = e;
      } catch (NotHandledException e) {
        exception = e;
      }

      if (exception != null) {
        Status status =
            new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, exception.getMessage(), exception);
        StatusManager.getManager().handle(status, StatusManager.LOG | StatusManager.SHOW);
      }
    }
  }
コード例 #2
0
  void doAction() {

    JobTreeElement[] jobTreeElements = FinishedJobs.getInstance().getKeptElements();
    // search from end (youngest)
    for (int i = jobTreeElements.length - 1; i >= 0; i--) {
      if (jobTreeElements[i] instanceof JobInfo) {
        JobInfo ji = (JobInfo) jobTreeElements[i];
        Job job = ji.getJob();
        if (job != null) {

          IStatus status = job.getResult();
          if (status != null && status.getSeverity() == IStatus.ERROR) {
            StatusAdapter statusAdapter = StatusAdapterHelper.getInstance().getStatusAdapter(ji);

            if (statusAdapter == null) statusAdapter = new StatusAdapter(status);

            StatusManager.getManager().handle(statusAdapter, StatusManager.SHOW);

            removeTopElement(ji);
          }

          execute(ji, job);
        }
      }
    }

    progressRegion.processDoubleClick();
    refresh();
  }