/** * 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()]); }
/** A repository root has been added. Notify any listeners. */ public void rootAdded(ICVSRepositoryLocation root) { Iterator it = listeners.iterator(); while (it.hasNext()) { IRepositoryListener listener = (IRepositoryListener) it.next(); listener.repositoryAdded(root); } }
private void broadcastRepositoriesChanged(ICVSRepositoryLocation[] roots) { if (roots.length == 0) return; Iterator it = listeners.iterator(); while (it.hasNext()) { IRepositoryListener listener = (IRepositoryListener) it.next(); listener.repositoriesChanged(roots); } }
private void writeState(XMLWriter writer) { writer.startTag(RepositoriesViewContentHandler.REPOSITORIES_VIEW_TAG, null, true); // Write the repositories Collection repos = Arrays.asList(getKnownRepositoryLocations()); Iterator it = repos.iterator(); while (it.hasNext()) { CVSRepositoryLocation location = (CVSRepositoryLocation) it.next(); RepositoryRoot root = getRepositoryRootFor(location); root.writeState(writer); } writer.endTag(RepositoriesViewContentHandler.REPOSITORIES_VIEW_TAG); }
/** Purge any cahced information. */ public void purgeCache() { for (Iterator iter = repositoryRoots.values().iterator(); iter.hasNext(); ) { RepositoryRoot root = (RepositoryRoot) iter.next(); root.clearCache(); } }