1 11 package org.eclipse.core.internal.resources.mapping; 12 13 import org.eclipse.core.resources.*; 14 import org.eclipse.core.resources.mapping.*; 15 import org.eclipse.core.runtime.IProgressMonitor; 16 17 23 public class SimpleResourceMapping extends ResourceMapping { 24 private final IResource resource; 25 26 public SimpleResourceMapping(IResource resource) { 27 this.resource = resource; 28 } 29 30 33 public boolean contains(ResourceMapping mapping) { 34 if (mapping.getModelProviderId().equals(this.getModelProviderId())) { 35 Object object = mapping.getModelObject(); 36 if (object instanceof IResource) { 37 IResource other = (IResource) object; 38 return resource.getFullPath().isPrefixOf(other.getFullPath()); 39 } 40 if (object instanceof ShallowContainer) { 41 ShallowContainer sc = (ShallowContainer) object; 42 IResource other = sc.getResource(); 43 return resource.getFullPath().isPrefixOf(other.getFullPath()); 44 } 45 } 46 return false; 47 } 48 49 52 public Object getModelObject() { 53 return resource; 54 } 55 56 public String getModelProviderId() { 57 return ModelProvider.RESOURCE_MODEL_PROVIDER_ID; 58 } 59 60 63 public IProject[] getProjects() { 64 if (resource.getType() == IResource.ROOT) 65 return ((IWorkspaceRoot)resource).getProjects(); 66 return new IProject[] {resource.getProject()}; 67 } 68 69 72 public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) { 73 if (resource.getType() == IResource.ROOT) { 74 return new ResourceTraversal[] {new ResourceTraversal(((IWorkspaceRoot)resource).getProjects(), IResource.DEPTH_INFINITE, IResource.NONE)}; 75 } 76 return new ResourceTraversal[] {new ResourceTraversal(new IResource[] {resource}, IResource.DEPTH_INFINITE, IResource.NONE)}; 77 } 78 } 79 | Popular Tags |