/** * 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()]); }
/* * Add a single log entry to the model. * * @param info * @param logs * @param remoteResource */ private void addSingleRevision( SyncInfo info, LogEntryCache logs, ICVSRemoteResource remoteResource) { ILogEntry logEntry = logs.getLogEntry(remoteResource); if (remoteResource != null && !remoteResource.isFolder()) { // For incoming deletions grab the comment for the latest on the same branch // which is now in the attic. try { String remoteRevision = ((ICVSRemoteFile) remoteResource).getRevision(); if (isDeletedRemotely(info)) { ILogEntry[] logEntries = logs.getLogEntries(remoteResource); for (int i = 0; i < logEntries.length; i++) { ILogEntry entry = logEntries[i]; String revision = entry.getRevision(); if (entry.isDeletion() && ResourceSyncInfo.isLaterRevision(revision, remoteRevision)) { logEntry = entry; } } } } catch (TeamException e) { // continue and skip deletion checks } } addRemoteChange(info, remoteResource, logEntry); }