/** * Retrieves a collection of files that may be committed based on the user's selection when they * performed the commit action. That is, even if the user only selected one folder when the action * was performed, if the folder contains any files that could be committed, they will be returned. * * @return a collection of files that is eligible to be committed based on the user's selection */ private Set<String> getSelectedFiles() { Set<String> preselectionCandidates = new LinkedHashSet<String>(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); // iterate through all the files that may be committed for (String fileName : files) { URI uri = new File(repo.getWorkTree(), fileName).toURI(); IFile[] workspaceFiles = root.findFilesForLocationURI(uri); if (workspaceFiles.length > 0) { IFile file = workspaceFiles[0]; for (IResource resource : selectedResources) { // if any selected resource contains the file, add it as a // preselection candidate if (resource.contains(file)) { preselectionCandidates.add(fileName); break; } } } else { // could be file outside of workspace for (IResource resource : selectedResources) { if (resource.getFullPath().toFile().equals(new File(uri))) { preselectionCandidates.add(fileName); } } } } return preselectionCandidates; }