1 11 package org.eclipse.team.internal.ccvs.ui.operations; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 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 22 32 public final class WorkspaceResourceMapper extends ResourceMapping { 33 34 private final IResource resource; 35 private final int depth; 36 37 44 public static ResourceMapping[] asResourceMappers(final IResource[] resources, int depth) { 45 List result = new ArrayList (); 46 for (int i = 0; i < resources.length; i++) { 47 IResource resource = resources[i]; 48 result.add(new WorkspaceResourceMapper(resource, depth)); 49 } 50 return (ResourceMapping[]) result.toArray(new ResourceMapping[result.size()]); 51 } 52 53 public WorkspaceResourceMapper(IResource resource, int depth) { 54 this.resource = resource; 55 this.depth = depth; 56 } 57 public Object getModelObject() { 58 return resource; 59 } 60 public IProject[] getProjects() { 61 return new IProject[] { resource.getProject() }; 62 } 63 public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { 64 return asTraversal(resource, depth, context); 65 } 66 private ResourceTraversal[] asTraversal(IResource resource, final int depth, ResourceMappingContext context) { 67 return new ResourceTraversal[] { new ResourceTraversal(new IResource[] { resource }, depth, IResource.NONE)} ; 68 } 69 public boolean contains(ResourceMapping mapping) { 70 return false; 71 } 72 73 public String getModelProviderId() { 74 return ModelProvider.RESOURCE_MODEL_PROVIDER_ID; 75 } 76 } 77 | Popular Tags |