Пример #1
0
 /**
  * Method filterResources filters the given resources using the given working set.
  *
  * @param current
  * @param resources
  * @return ICVSRemoteResource[]
  */
 public ICVSRemoteResource[] filterResources(
     IWorkingSet workingSet, ICVSRemoteResource[] resources) {
   if (workingSet == null) return resources;
   // get the projects associated with the working set
   IAdaptable[] adaptables = workingSet.getElements();
   Set projects = new HashSet();
   for (int i = 0; i < adaptables.length; i++) {
     IAdaptable adaptable = adaptables[i];
     Object adapted = adaptable.getAdapter(IResource.class);
     if (adapted != null) {
       // Can this code be generalized?
       IProject project = ((IResource) adapted).getProject();
       projects.add(project);
     }
   }
   List result = new ArrayList();
   for (int i = 0; i < resources.length; i++) {
     ICVSRemoteResource resource = resources[i];
     for (Iterator iter = projects.iterator(); iter.hasNext(); ) {
       IProject project = (IProject) iter.next();
       if (project.getName().equals(resource.getName())) {
         result.add(resource);
         break;
       }
     }
   }
   return (ICVSRemoteResource[]) result.toArray(new ICVSRemoteResource[result.size()]);
 }
Пример #2
0
 /**
  * Method getRepositoryRoots.
  *
  * @param iCVSRepositoryLocations
  * @return RepositoryRoot[]
  */
 private RepositoryRoot[] getRepositoryRoots(ICVSRepositoryLocation[] locations) {
   List roots = new ArrayList();
   for (int i = 0; i < locations.length; i++) {
     ICVSRepositoryLocation location = locations[i];
     RepositoryRoot root = getRepositoryRootFor(location);
     if (root != null) roots.add(root);
   }
   return (RepositoryRoot[]) roots.toArray(new RepositoryRoot[roots.size()]);
 }