1 11 package org.eclipse.team.internal.core.mapping; 12 13 import java.util.HashSet ; 14 import java.util.Set ; 15 16 import org.eclipse.core.resources.mapping.*; 17 import org.eclipse.team.core.mapping.ISynchronizationScope; 18 import org.eclipse.team.internal.core.subscribers.AbstractSynchronizationScope; 19 20 23 public abstract class AbstractResourceMappingScope extends AbstractSynchronizationScope implements ISynchronizationScope { 24 25 28 public ResourceMapping getMapping(Object modelObject) { 29 ResourceMapping[] mappings = getMappings(); 30 for (int i = 0; i < mappings.length; i++) { 31 ResourceMapping mapping = mappings[i]; 32 if (mapping.getModelObject().equals(modelObject)) 33 return mapping; 34 } 35 return null; 36 } 37 38 41 public ResourceMapping[] getMappings(String id) { 42 Set result = new HashSet (); 43 ResourceMapping[] mappings = getMappings(); 44 for (int i = 0; i < mappings.length; i++) { 45 ResourceMapping mapping = mappings[i]; 46 if (mapping.getModelProviderId().equals(id)) { 47 result.add(mapping); 48 } 49 } 50 return (ResourceMapping[]) result.toArray(new ResourceMapping[result.size()]); 51 52 } 53 54 57 public ResourceTraversal[] getTraversals(String modelProviderId) { 58 ResourceMapping[] mappings = getMappings(modelProviderId); 59 CompoundResourceTraversal traversal = new CompoundResourceTraversal(); 60 for (int i = 0; i < mappings.length; i++) { 61 ResourceMapping mapping = mappings[i]; 62 ResourceTraversal[] traversals = getTraversals(mapping); 63 if (traversals != null) 64 traversal.addTraversals(traversals); 65 } 66 return traversal.asTraversals(); 67 } 68 69 72 public ModelProvider[] getModelProviders() { 73 Set result = new HashSet (); 74 ResourceMapping[] mappings = getMappings(); 75 for (int i = 0; i < mappings.length; i++) { 76 ResourceMapping mapping = mappings[i]; 77 ModelProvider modelProvider = mapping.getModelProvider(); 78 if (modelProvider != null) 79 result.add(modelProvider); 80 } 81 return (ModelProvider[]) result.toArray(new ModelProvider[result.size()]); 82 } 83 84 } 85 | Popular Tags |