use of org.eclipse.egit.core.synchronize.GitSubscriberMergeContext in project egit by eclipse.
the class GitModelSynchronize method fireSynchronizeAction.
private static void fireSynchronizeAction(final IWorkbenchWindow window, final GitSynchronizeDataSet gsdSet, final ResourceMapping[] mappings) {
final GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(gsdSet);
Job syncJob = new WorkspaceJob(UIText.GitModelSynchronize_fetchGitDataJobName) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
subscriber.init(monitor);
return Status.OK_STATUS;
}
@Override
public boolean belongsTo(Object family) {
if (JobFamilies.SYNCHRONIZE_READ_DATA.equals(family))
return true;
return super.belongsTo(family);
}
};
syncJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
RemoteResourceMappingContext remoteContext = new GitSubscriberResourceMappingContext(subscriber, gsdSet);
SubscriberScopeManager manager = new SubscriberScopeManager(subscriber.getName(), mappings, subscriber, remoteContext, true);
GitSubscriberMergeContext context = new GitSubscriberMergeContext(subscriber, manager, gsdSet);
final GitModelSynchronizeParticipant participant = new GitModelSynchronizeParticipant(context);
TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] { participant });
IWorkbenchPart activePart = null;
if (window != null)
activePart = window.getActivePage().getActivePart();
participant.run(activePart);
}
});
syncJob.setUser(true);
syncJob.schedule();
}
use of org.eclipse.egit.core.synchronize.GitSubscriberMergeContext in project egit by eclipse.
the class GitModelSynchronizeParticipant method restoreContext.
@Override
protected MergeContext restoreContext(ISynchronizationScopeManager manager) throws CoreException {
GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(gsds);
subscriber.init(new NullProgressMonitor());
return new GitSubscriberMergeContext(subscriber, manager, gsds);
}
use of org.eclipse.egit.core.synchronize.GitSubscriberMergeContext in project egit by eclipse.
the class GitChangeSetContentProvider method getModelRoot.
@Override
protected Object getModelRoot() {
if (modelRoot == null) {
GitSubscriberMergeContext context = (GitSubscriberMergeContext) getContext();
modelRoot = new GitModelRoot(context.getSyncData());
}
return modelRoot;
}
use of org.eclipse.egit.core.synchronize.GitSubscriberMergeContext in project egit by eclipse.
the class ModelTestCase method prepareContext.
protected IMergeContext prepareContext(Repository repository, IFile workspaceFile, String srcRev, String dstRev) throws Exception {
GitSynchronizeData gsd = new GitSynchronizeData(repository, srcRev, dstRev, true, Collections.<IResource>singleton(workspaceFile));
GitSynchronizeDataSet gsds = new GitSynchronizeDataSet(gsd);
GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(gsds);
subscriber.init(new NullProgressMonitor());
ResourceMapping mapping = AdapterUtils.adapt(workspaceFile, ResourceMapping.class);
SubscriberScopeManager manager = new SubscriberScopeManager(subscriber.getName(), new ResourceMapping[] { mapping }, subscriber, 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.egit.core.synchronize.GitSubscriberMergeContext 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;
}
Aggregations