1 11 package org.eclipse.core.resources.mapping; 12 13 import java.util.*; 14 import org.eclipse.core.resources.IProject; 15 import org.eclipse.core.runtime.*; 16 17 25 public final class CompositeResourceMapping extends ResourceMapping { 26 27 private final ResourceMapping[] mappings; 28 private final Object modelObject; 29 private IProject[] projects; 30 private String providerId; 31 32 37 public CompositeResourceMapping(String providerId, Object modelObject, ResourceMapping[] mappings) { 38 this.modelObject = modelObject; 39 this.mappings = mappings; 40 this.providerId = providerId; 41 } 42 43 46 public boolean contains(ResourceMapping mapping) { 47 for (int i = 0; i < mappings.length; i++) { 48 ResourceMapping childMapping = mappings[i]; 49 if (childMapping.contains(mapping)) { 50 return true; 51 } 52 } 53 return false; 54 } 55 56 60 public ResourceMapping[] getMappings() { 61 return mappings; 62 } 63 64 67 public Object getModelObject() { 68 return modelObject; 69 } 70 71 74 public String getModelProviderId() { 75 return providerId; 76 } 77 78 81 public IProject[] getProjects() { 82 if (projects == null) { 83 Set result = new HashSet(); 84 for (int i = 0; i < mappings.length; i++) { 85 ResourceMapping mapping = mappings[i]; 86 result.addAll(Arrays.asList(mapping.getProjects())); 87 } 88 projects = (IProject[]) result.toArray(new IProject[result.size()]); 89 } 90 return projects; 91 } 92 93 96 public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { 97 if (monitor == null) 98 monitor = new NullProgressMonitor(); 99 try { 100 monitor.beginTask("", 100 * mappings.length); List result = new ArrayList(); 102 for (int i = 0; i < mappings.length; i++) { 103 ResourceMapping mapping = mappings[i]; 104 result.addAll(Arrays.asList(mapping.getTraversals(context, new SubProgressMonitor(monitor, 100)))); 105 } 106 return (ResourceTraversal[]) result.toArray(new ResourceTraversal[result.size()]); 107 } finally { 108 monitor.done(); 109 } 110 } 111 112 } 113 | Popular Tags |