Source:
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { Collection<?> collection = (Collection<?>) receiver; if (collection.isEmpty()) return false; if ("projectsSingleRepository".equals(property)) { Repository repository = getRepositoryOfProjects(collection, true); return testRepositoryProperties(repository, args); } else if ("projectsWithRepositories".equals(property)) { Repository repository = getRepositoryOfProjects(collection, false); return repository != null; } else if ("resourcesSingleRepository".equals(property)) { IStructuredSelection selection = getStructuredSelection(collection); IResource[] resources = SelectionUtils .getSelectedResources(selection); Repository repository = getRepositoryOfResources(resources); return testRepositoryProperties(repository, args); } else if ("fileOrFolderInRepository".equals(property)) { if (collection.size() != 1) return false; IStructuredSelection selection = getStructuredSelection(collection); if (selection.size() != 1) return false; Object firstElement = selection.getFirstElement(); IContainer container = AdapterUtils.adapt(firstElement, IContainer.class); RepositoryMapping mapping = null; if (container != null) { mapping = RepositoryMapping.getMapping(container); } if (container != null && mapping != null) { if (container.equals(mapping.getContainer())) { return false; } else { return testRepositoryProperties(mapping.getRepository(), args); } } IResource resource = AdapterUtils.adapt(firstElement, IResource.class); if ((resource != null) && (resource instanceof IFile || resource instanceof IFolder)) { RepositoryMapping m = RepositoryMapping.getMapping(resource); if (m != null) { return testRepositoryProperties(m.getRepository(), args); } } } else if ("resourcesAllInRepository".equals(property)) { IStructuredSelection selection = getStructuredSelection(collection); IResource[] resources = SelectionUtils .getSelectedResources(selection); return haveRepositories(resources); } return false; }

Target:
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { Collection<?> collection = (Collection<?>) receiver; if (collection.isEmpty()) return false; if ("projectsSingleRepository".equals(property)) { Repository repository = getRepositoryOfProjects(collection, true); return testRepositoryProperties(repository, args); } else if ("projectsWithRepositories".equals(property)) { Repository repository = getRepositoryOfProjects(collection, false); return repository != null; } else if ("resourcesSingleRepository".equals(property)) { IStructuredSelection selection = getStructuredSelection(collection); IResource[] resources = SelectionUtils .getSelectedResources(selection); Repository repository = getRepositoryOfResources(resources); return testRepositoryProperties(repository, args); } else if ("fileOrFolderInRepository".equals(property)) { if (collection.size() != 1) return false; IStructuredSelection selection = getStructuredSelection(collection); if (selection.size() != 1) return false; Object firstElement = selection.getFirstElement(); IResource resource = AdapterUtils.adapt(firstElement, IResource.class); if ((resource != null) && (resource instanceof IFile || resource instanceof IFolder)) { RepositoryMapping m = RepositoryMapping.getMapping(resource); if (m != null) { if ((resource instanceof IFolder) && resource.equals(m.getContainer())) { return false; } else { return testRepositoryProperties(m.getRepository(), args); } } } } else if ("resourcesAllInRepository".equals(property)) { IStructuredSelection selection = getStructuredSelection(collection); IResource[] resources = SelectionUtils .getSelectedResources(selection); return haveRepositories(resources); } return false; }