1 11 package org.eclipse.core.internal.resources.mapping; 12 13 import org.eclipse.core.resources.IProject; 14 import org.eclipse.core.resources.IResource; 15 import org.eclipse.core.resources.mapping.*; 16 import org.eclipse.core.runtime.IProgressMonitor; 17 18 21 public class ShallowResourceMapping extends ResourceMapping { 22 23 private final ShallowContainer container; 24 25 public ShallowResourceMapping(ShallowContainer container) { 26 this.container = container; 27 } 28 29 public Object getModelObject() { 30 return container; 31 } 32 33 public String getModelProviderId() { 34 return ModelProvider.RESOURCE_MODEL_PROVIDER_ID; 35 } 36 37 public IProject[] getProjects() { 38 return new IProject[] { container.getResource().getProject() }; 39 } 40 41 public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) { 42 return new ResourceTraversal[] { new ResourceTraversal(new IResource[] { container.getResource() }, IResource.DEPTH_ONE, IResource.NONE)}; 43 } 44 45 public boolean contains(ResourceMapping mapping) { 46 if (mapping.getModelProviderId().equals(this.getModelProviderId())) { 47 Object object = mapping.getModelObject(); 48 IResource resource = container.getResource(); 49 if (object instanceof ShallowContainer) { 51 ShallowContainer sc = (ShallowContainer) object; 52 return sc.getResource().equals(resource); 53 } 54 if (object instanceof IResource) { 55 IResource other = (IResource) object; 56 return other.getType() == IResource.FILE 57 && resource.getFullPath().equals(other.getFullPath().removeLastSegments(1)); 58 } 59 } 60 return false; 61 } 62 63 } 64 | Popular Tags |