コード例 #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
 private IAction getAction(Job job) {
   Object property = job.getProperty(IProgressConstants.ACTION_PROPERTY);
   if (property instanceof IAction) {
     return (IAction) property;
   }
   return null;
 }
コード例 #3
0
 private boolean suppressAuthentication() {
   Job job = Job.getJobManager().currentJob();
   if (job != null) {
     return job.getProperty(SUPPRESS_AUTHENTICATION_JOB_MARKER) != null;
   }
   return false;
 }
コード例 #4
0
  private JobTreeElement[] findJobsToRemove(JobTreeElement info) {

    if (info.isJobInfo()) {
      Job myJob = ((JobInfo) info).getJob();

      if (myJob != null) {

        Object prop = myJob.getProperty(ProgressManagerUtil.KEEPONE_PROPERTY);
        if (prop instanceof Boolean && ((Boolean) prop).booleanValue()) {
          ArrayList found = null;
          JobTreeElement[] all;
          synchronized (keptjobinfos) {
            all = (JobTreeElement[]) keptjobinfos.toArray(new JobTreeElement[keptjobinfos.size()]);
          }
          for (int i = 0; i < all.length; i++) {
            JobTreeElement jte = all[i];
            if (jte != info && jte.isJobInfo()) {
              Job job = ((JobInfo) jte).getJob();
              if (job != null && job != myJob && job.belongsTo(myJob)) {
                if (found == null) {
                  found = new ArrayList();
                }
                found.add(jte);
              }
            }
          }
          if (found != null) {
            return (JobTreeElement[]) found.toArray(new JobTreeElement[found.size()]);
          }
        }
      }
    }
    return null;
  }
コード例 #5
0
 static void disposeAction(JobTreeElement jte) {
   if (jte.isJobInfo()) {
     JobInfo ji = (JobInfo) jte;
     Job job = ji.getJob();
     if (job != null) {
       Object prop = job.getProperty(IProgressConstants.ACTION_PROPERTY);
       if (prop instanceof ActionFactory.IWorkbenchAction) {
         ((ActionFactory.IWorkbenchAction) prop).dispose();
       }
     }
   }
 }
コード例 #6
0
  /** Returns true if JobInfo indicates that it must be kept. */
  static boolean keep(JobInfo info) {
    Job job = info.getJob();
    if (job != null) {
      Object prop = job.getProperty(ProgressManagerUtil.KEEP_PROPERTY);
      if (prop instanceof Boolean) {
        if (((Boolean) prop).booleanValue()) {
          return true;
        }
      }

      prop = job.getProperty(ProgressManagerUtil.KEEPONE_PROPERTY);
      if (prop instanceof Boolean) {
        if (((Boolean) prop).booleanValue()) {
          return true;
        }
      }

      IStatus status = job.getResult();
      if (status != null && status.getSeverity() == IStatus.ERROR) {
        return true;
      }
    }
    return false;
  }