private synchronized void refresh(ProjectDependency key) {
   if (dependenciesViewer == null || dependenciesViewer.getTable().isDisposed()) {
     return;
   }
   // dependenciesViewer.refresh();
   try {
     for (TableItem item : dependenciesViewer.getTable().getItems()) {
       @SuppressWarnings("unchecked")
       final ProjectDependency projectDep = (ProjectDependency) item.getData();
       if (projectDep.equals(key)) {
         dependenciesViewer.refresh(projectDep, false);
         // Don't force check when there's an existing dependency, only uncheck if they're is not.
         if (dependencyMap.get(projectDep) == null) {
           Job job = identificationJobs.get(projectDep);
           if (job != null && job.getState() == Job.NONE) {
             dependenciesViewer.setChecked(projectDep, false);
           }
         }
         setPageComplete(hasNoRunningJobs());
         return;
       }
     }
   } finally {
     displayWarning();
     enableIdentificationButtons();
   }
 }
 public IResource[] getResourcesToDelete() {
   List<IResource> resources = new ArrayList<IResource>(dependencyMap.size());
   IPath projectPath = project.getLocation();
   IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
   for (ProjectDependency pd : dependencyMap.keySet()) {
     if (pd.getDependencyKind() == DependencyKind.Archive) {
       IPath p = pd.getPath();
       if (projectPath.isPrefixOf(p)) {
         p = p.removeFirstSegments(projectPath.segmentCount() - 1);
       }
       IFile f = root.getFile(p);
       if (f.exists() && project.equals(f.getProject())) {
         resources.add(f);
       }
     }
   }
   return resources.toArray(new IResource[0]);
 }
  private void initJobs() {
    if (identificationJobs == null) {
      identificationJobs = new HashMap<ProjectDependency, IdentificationJob>(dependencyMap.size());

      Table t = dependenciesViewer.getTable();
      IFileIdentificationManager fileIdentificationManager = new FileIdentificationManager();

      for (final TableItem item : t.getItems()) {
        final ProjectDependency projectDep = (ProjectDependency) item.getData();
        Dependency mavenDep = dependencyMap.get(projectDep);
        if (mavenDep != null) {
          // already identified
          continue;
        }
        File jar;
        try {
          final IdentificationJob job;
          if (projectDep.getDependencyKind() == ProjectDependency.DependencyKind.Project) {
            job =
                new IdentifyProjectJob(
                    "Search the Maven coordinates for " + projectDep.getPath(),
                    projectDep.getPath());
          } else if (projectDep.getDependencyKind() == ProjectDependency.DependencyKind.Archive) {
            jar = ConversionUtils.getFile(projectDep.getPath());
            job =
                new IdentifyJarJob(
                    "Search the Maven coordinates for " + jar.getAbsolutePath(),
                    fileIdentificationManager,
                    jar);
          } else {
            job =
                new DependencyResolutionJob(
                    "Resolve the Maven dependency for " + projectDep.getPath());
          }

          job.addJobChangeListener(
              new IJobChangeListener() {

                @Override
                public void sleeping(IJobChangeEvent event) {
                  // refreshUI();
                }

                @Override
                public void scheduled(IJobChangeEvent event) {
                  // refreshUI();
                }

                @Override
                public void running(IJobChangeEvent event) {
                  refreshUI();
                }

                @Override
                public void done(IJobChangeEvent event) {
                  Dependency d = job.getDependency();
                  dependencyMap.put(projectDep, d);
                  if (d != null) {
                    dependencyResolution.put(getKey(d), job.isResolvable());
                  }
                  refreshUI();
                }

                @Override
                public void awake(IJobChangeEvent event) {
                  // refreshUI();
                }

                @Override
                public void aboutToRun(IJobChangeEvent event) {
                  // refreshUI();
                }

                private void refreshUI() {
                  Display.getDefault()
                      .syncExec(
                          new Runnable() {
                            @Override
                            public void run() {
                              refresh(projectDep);
                            }
                          });
                }
              });
          identificationJobs.put(projectDep, job);
        } catch (CoreException e) {
          e.printStackTrace();
        }
      }
    }
  }