1 11 package org.eclipse.team.internal.ccvs.core.mapping; 12 13 import java.util.HashSet ; 14 import java.util.Set ; 15 16 import org.eclipse.core.resources.IProject; 17 import org.eclipse.core.resources.IResource; 18 import org.eclipse.core.resources.mapping.*; 19 import org.eclipse.core.runtime.CoreException; 20 import org.eclipse.core.runtime.IProgressMonitor; 21 import org.eclipse.team.internal.core.subscribers.DiffChangeSet; 22 23 public class ChangeSetResourceMapping extends ResourceMapping { 24 25 private final DiffChangeSet changeSet; 26 27 public ChangeSetResourceMapping(DiffChangeSet changeSet) { 28 this.changeSet = changeSet; 29 } 30 31 public Object getModelObject() { 32 return changeSet; 33 } 34 35 public String getModelProviderId() { 36 return ChangeSetModelProvider.ID; 37 } 38 39 public IProject[] getProjects() { 40 Set result = new HashSet (); 41 IResource[] resources = changeSet.getResources(); 42 for (int i = 0; i < resources.length; i++) { 43 IResource resource = resources[i]; 44 result.add(resource.getProject()); 45 } 46 return (IProject[]) result.toArray(new IProject[result.size()]); 47 } 48 49 public ResourceTraversal[] getTraversals(ResourceMappingContext context, 50 IProgressMonitor monitor) throws CoreException { 51 IResource[] resources = changeSet.getResources(); 52 if (resources.length == 0) { 53 return new ResourceTraversal[0]; 54 } 55 return new ResourceTraversal[] { 56 new ResourceTraversal(resources, IResource.DEPTH_ZERO, IResource.NONE) 57 }; 58 } 59 60 } 61 | Popular Tags |