1 11 package org.eclipse.team.internal.core.mapping; 12 13 import java.util.*; 14 15 import org.eclipse.core.resources.IProject; 16 import org.eclipse.core.resources.ResourcesPlugin; 17 import org.eclipse.core.resources.mapping.*; 18 import org.eclipse.team.core.mapping.ISynchronizationScope; 19 import org.eclipse.team.core.mapping.provider.SynchronizationScopeManager; 20 21 31 public class ResourceMappingScope extends AbstractResourceMappingScope { 32 33 private ResourceMapping[] inputMappings; 34 private final Map mappingsToTraversals = Collections.synchronizedMap(new HashMap()); 35 private boolean hasAdditionalMappings; 36 private boolean hasAdditionalResources; 37 private final CompoundResourceTraversal compoundTraversal = new CompoundResourceTraversal(); 38 private final SynchronizationScopeManager manager; 39 40 public ResourceMappingScope(ResourceMapping[] selectedMappings, SynchronizationScopeManager manager) { 41 inputMappings = selectedMappings; 42 this.manager = manager; 43 } 44 45 52 public ResourceTraversal[] addMapping(ResourceMapping mapping, ResourceTraversal[] traversals) { 53 ResourceTraversal[] newTraversals = compoundTraversal.getUncoveredTraversals(traversals); 54 mappingsToTraversals.put(mapping, traversals); 55 compoundTraversal.addTraversals(traversals); 56 return newTraversals; 57 } 58 59 62 public ResourceMapping[] getInputMappings() { 63 return inputMappings; 64 } 65 66 69 public ResourceMapping[] getMappings() { 70 if (mappingsToTraversals.isEmpty()) 71 return inputMappings; 72 return (ResourceMapping[]) mappingsToTraversals.keySet().toArray(new ResourceMapping[mappingsToTraversals.size()]); 73 } 74 75 78 public ResourceTraversal[] getTraversals() { 79 return compoundTraversal.asTraversals(); 80 } 81 82 85 public ResourceTraversal[] getTraversals(ResourceMapping mapping) { 86 return (ResourceTraversal[])mappingsToTraversals.get(mapping); 87 } 88 89 92 public boolean hasAdditionalMappings() { 93 return hasAdditionalMappings; 94 } 95 96 101 public void setHasAdditionalMappings(boolean hasAdditionalMappings) { 102 this.hasAdditionalMappings = hasAdditionalMappings; 103 } 104 105 110 public void setHasAdditionalResources(boolean hasAdditionalResources) { 111 this.hasAdditionalResources = hasAdditionalResources; 112 } 113 114 117 public boolean hasAdditonalResources() { 118 return hasAdditionalResources; 119 } 120 121 public CompoundResourceTraversal getCompoundTraversal() { 122 return compoundTraversal; 123 } 124 125 128 public ISynchronizationScope asInputScope() { 129 return new ResourceMappingInputScope(this); 130 } 131 132 135 public IProject[] getProjects() { 136 ResourceMappingContext context = getContext(); 137 if (context instanceof RemoteResourceMappingContext) { 138 RemoteResourceMappingContext rrmc = (RemoteResourceMappingContext) context; 139 return rrmc.getProjects(); 140 } 141 return ResourcesPlugin.getWorkspace().getRoot().getProjects(); 142 } 143 144 147 public ResourceMappingContext getContext() { 148 return manager.getContext(); 149 } 150 151 public void refresh(ResourceMapping[] mappings) { 152 manager.refresh(mappings); 153 } 154 155 public void reset() { 156 mappingsToTraversals.clear(); 157 compoundTraversal.clear(); 158 hasAdditionalMappings = false; 159 hasAdditionalResources = false; 160 } 161 } 162 | Popular Tags |