1 11 package org.eclipse.team.internal.core.subscribers; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 import org.eclipse.core.resources.*; 17 import org.eclipse.core.resources.mapping.*; 18 import org.eclipse.team.core.mapping.ISynchronizationScope; 19 import org.eclipse.team.internal.core.mapping.AbstractResourceMappingScope; 20 21 24 public class RootResourceSynchronizationScope extends AbstractResourceMappingScope { 25 26 private IResource[] roots; 27 28 public RootResourceSynchronizationScope(IResource[] roots) { 29 this.roots = roots; 30 } 31 32 public ResourceTraversal[] getTraversals() { 33 return new ResourceTraversal[] {new ResourceTraversal(roots, IResource.DEPTH_INFINITE, IResource.NONE)}; 34 } 35 36 41 public void setRoots(IResource[] roots) { 42 this.roots = roots; 43 fireTraversalsChangedEvent(getTraversals(), getMappings()); 44 } 45 46 public ResourceMapping[] getInputMappings() { 47 return getMappings(); 48 } 49 50 public ISynchronizationScope asInputScope() { 51 return this; 52 } 53 54 public ResourceMapping[] getMappings() { 55 List result = new ArrayList (); 56 for (int i = 0; i < roots.length; i++) { 57 IResource resource = roots[i]; 58 Object o = resource.getAdapter(ResourceMapping.class); 59 if (o instanceof ResourceMapping) { 60 result.add(o); 61 } 62 } 63 return (ResourceMapping[]) result.toArray(new ResourceMapping[result.size()]); 64 } 65 66 public ResourceTraversal[] getTraversals(ResourceMapping mapping) { 67 Object object = mapping.getModelObject(); 68 if (object instanceof IResource) { 69 IResource resource = (IResource) object; 70 return new ResourceTraversal[] {new ResourceTraversal(new IResource[] { resource }, IResource.DEPTH_INFINITE, IResource.NONE)}; 71 } 72 return null; 73 } 74 75 public boolean hasAdditionalMappings() { 76 return false; 77 } 78 79 public boolean hasAdditonalResources() { 80 return false; 81 } 82 83 public IProject[] getProjects() { 84 return ResourcesPlugin.getWorkspace().getRoot().getProjects(); 85 } 86 87 public ResourceMappingContext getContext() { 88 return ResourceMappingContext.LOCAL_CONTEXT; 89 } 90 91 public void refresh(ResourceMapping[] mappings) { 92 } 94 95 } 96 | Popular Tags |