use of org.eclipse.core.resources.mapping.ResourceMappingContext in project egit by eclipse.
the class GitResourceVariantTreeTest method collectResources.
private static Set<IResource> collectResources(ResourceMapping[] mappings) throws CoreException {
final Set<IResource> resources = new HashSet<IResource>();
ResourceMappingContext context = ResourceMappingContext.LOCAL_CONTEXT;
for (ResourceMapping mapping : mappings) {
ResourceTraversal[] traversals = mapping.getTraversals(context, new NullProgressMonitor());
for (ResourceTraversal traversal : traversals) {
resources.addAll(Arrays.asList(traversal.getResources()));
}
}
return resources;
}
use of org.eclipse.core.resources.mapping.ResourceMappingContext in project egit by eclipse.
the class ModelTestCase method prepareModelContext.
protected IMergeContext prepareModelContext(Repository repository, IFile workspaceFile, String srcRev, String dstRev) throws Exception {
Set<IResource> includedResources = new HashSet<IResource>(Arrays.asList(workspaceFile));
Set<IResource> newResources = new HashSet<IResource>(includedResources);
Set<ResourceMapping> allMappings = new HashSet<ResourceMapping>();
ResourceMappingContext mappingContext = ResourceMappingContext.LOCAL_CONTEXT;
ModelProvider provider = ModelProvider.getModelProviderDescriptor(SampleModelProvider.SAMPLE_PROVIDER_ID).getModelProvider();
do {
Set<IResource> copy = newResources;
newResources = new HashSet<IResource>();
for (IResource resource : copy) {
ResourceMapping[] mappings = provider.getMappings(resource, mappingContext, new NullProgressMonitor());
allMappings.addAll(Arrays.asList(mappings));
newResources.addAll(collectResources(mappings, mappingContext));
}
} while (includedResources.addAll(newResources));
ResourceMapping[] mappings = allMappings.toArray(new ResourceMapping[allMappings.size()]);
GitSynchronizeData gsd = new GitSynchronizeData(repository, srcRev, dstRev, true, includedResources);
GitSynchronizeDataSet gsds = new GitSynchronizeDataSet(gsd);
GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(gsds);
subscriber.init(new NullProgressMonitor());
GitSubscriberResourceMappingContext resourceMappingContext = new GitSubscriberResourceMappingContext(subscriber, gsds);
SubscriberScopeManager manager = new SubscriberScopeManager(subscriber.getName(), mappings, subscriber, resourceMappingContext, true);
manager.initialize(new NullProgressMonitor());
GitSubscriberMergeContext mergeContext = new GitSubscriberMergeContext(subscriber, manager, gsds);
// Wait for asynchronous update of the diff tree to end
Job.getJobManager().join(mergeContext, new NullProgressMonitor());
return mergeContext;
}
use of org.eclipse.core.resources.mapping.ResourceMappingContext in project egit by eclipse.
the class GitChangeSetContentProvider method getTraversals.
@Override
protected ResourceTraversal[] getTraversals(ISynchronizationContext context, Object object) {
if (object instanceof IAdaptable) {
if (traversalCache.containsKey(object)) {
return traversalCache.get(object);
}
ResourceMapping rm = getResourceMapping(object);
if (rm == null) {
return null;
}
GitSubscriberMergeContext ctx = (GitSubscriberMergeContext) getContext();
ResourceMappingContext rmCtx = new GitSubscriberResourceMappingContext((GitResourceVariantTreeSubscriber) ctx.getSubscriber(), ctx.getSyncData());
try {
ResourceTraversal[] traversals = rm.getTraversals(rmCtx, new NullProgressMonitor());
traversalCache.put(object, traversals);
return traversals;
} catch (CoreException e) {
Activator.logError(e.getMessage(), e);
}
}
return null;
}
Aggregations