Exemplo n.º 1
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;
  }
Exemplo n.º 2
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();
       }
     }
   }
 }
Exemplo n.º 3
0
  boolean remove(JobTreeElement jte) {
    boolean fire = false;
    boolean removed = false;

    synchronized (keptjobinfos) {
      if (keptjobinfos.remove(jte)) {
        removed = true;
        finishedTime.remove(jte);
        disposeAction(jte);

        // delete all elements that have jte as their direct or indirect
        // parent
        JobTreeElement jtes[] =
            (JobTreeElement[]) keptjobinfos.toArray(new JobTreeElement[keptjobinfos.size()]);
        for (int i = 0; i < jtes.length; i++) {
          JobTreeElement parent = (JobTreeElement) jtes[i].getParent();
          if (parent != null) {
            if (parent == jte || parent.getParent() == jte) {
              if (keptjobinfos.remove(jtes[i])) {
                disposeAction(jtes[i]);
              }
              finishedTime.remove(jtes[i]);
            }
          }
        }
        fire = true;
      }
    }

    if (fire) {
      // notify listeners
      Object l[] = getListeners();
      for (int i = 0; i < l.length; i++) {
        KeptJobsListener jv = (KeptJobsListener) l[i];
        jv.removed(jte);
      }
    }
    return removed;
  }