Search in sources :

Example 6 with GitResourceVariantTreeSubscriber

use of org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber in project egit by eclipse.

the class GitModelSynchronizeParticipant method asCompareInput.

@Override
public ICompareInput asCompareInput(Object object) {
    final ICompareInput input = super.asCompareInput(object);
    final ISynchronizationContext ctx = getContext();
    if (input instanceof ResourceDiffCompareInput && ctx instanceof SubscriberMergeContext) {
        // Team only considers local resources as "left"
        // We'll use the cached data instead as left could be remote
        final IResource resource = ((ResourceNode) input.getLeft()).getResource();
        final Subscriber subscriber = ((SubscriberMergeContext) ctx).getSubscriber();
        if (resource instanceof IFile && subscriber instanceof GitResourceVariantTreeSubscriber) {
            try {
                final IFileRevision revision = ((GitResourceVariantTreeSubscriber) subscriber).getSourceFileRevision((IFile) resource);
                if (revision == null) {
                    final ITypedElement newSource = new GitCompareFileRevisionEditorInput.EmptyTypedElement(resource.getName());
                    ((ResourceDiffCompareInput) input).setLeft(newSource);
                } else if (!(revision instanceof WorkspaceFileRevision)) {
                    final ITypedElement newSource = new FileRevisionTypedElement(revision, getLocalEncoding(resource));
                    ((ResourceDiffCompareInput) input).setLeft(newSource);
                }
            } catch (TeamException e) {
                // Keep the input from super as-is
                String error = NLS.bind(UIText.GitModelSynchronizeParticipant_noCachedSourceVariant, resource.getName());
                Activator.logError(error, e);
            }
        }
    }
    return input;
}
Also used : IFile(org.eclipse.core.resources.IFile) ISynchronizationContext(org.eclipse.team.core.mapping.ISynchronizationContext) IFileRevision(org.eclipse.team.core.history.IFileRevision) ITypedElement(org.eclipse.compare.ITypedElement) WorkspaceFileRevision(org.eclipse.egit.core.internal.storage.WorkspaceFileRevision) ICompareInput(org.eclipse.compare.structuremergeviewer.ICompareInput) ResourceDiffCompareInput(org.eclipse.team.internal.ui.mapping.ResourceDiffCompareInput) ResourceNode(org.eclipse.compare.ResourceNode) TeamException(org.eclipse.team.core.TeamException) Subscriber(org.eclipse.team.core.subscribers.Subscriber) GitResourceVariantTreeSubscriber(org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber) SubscriberMergeContext(org.eclipse.team.core.subscribers.SubscriberMergeContext) GitSubscriberMergeContext(org.eclipse.egit.core.synchronize.GitSubscriberMergeContext) GitResourceVariantTreeSubscriber(org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber) FileRevisionTypedElement(org.eclipse.egit.ui.internal.revision.FileRevisionTypedElement) IResource(org.eclipse.core.resources.IResource)

Example 7 with GitResourceVariantTreeSubscriber

use of org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber in project egit by eclipse.

the class GitModelSynchronizeParticipant method createScopeManager.

@Override
protected ISynchronizationScopeManager createScopeManager(ResourceMapping[] mappings) {
    GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(gsds);
    subscriber.init(new NullProgressMonitor());
    GitSubscriberResourceMappingContext context = new GitSubscriberResourceMappingContext(subscriber, gsds);
    return new SynchronizationScopeManager(UIText.GitModelSynchronizeParticipant_initialScopeName, mappings, context, true);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ISynchronizationScopeManager(org.eclipse.team.core.mapping.ISynchronizationScopeManager) SynchronizationScopeManager(org.eclipse.team.core.mapping.provider.SynchronizationScopeManager) GitSubscriberResourceMappingContext(org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext) GitResourceVariantTreeSubscriber(org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber)

Example 8 with GitResourceVariantTreeSubscriber

use of org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber in project egit by eclipse.

the class GitScopeUtil method createScopeManager.

/**
 * Creates a new {@link SubscriberScopeManager} for the given set of
 * {@link IResource}s
 *
 * @param resources
 * @param monitor
 * @return {@link SubscriberScopeManager}
 */
private static SubscriberScopeManager createScopeManager(final IResource[] resources, IProgressMonitor monitor) {
    ResourceMapping[] mappings = GitScopeUtil.getResourceMappings(resources);
    GitSynchronizeDataSet set = new GitSynchronizeDataSet();
    final GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(set);
    monitor.setTaskName(UIText.GitModelSynchronize_fetchGitDataJobName);
    subscriber.init(monitor);
    SubscriberScopeManager manager = new SubscriberScopeManager(UIText.GitScopeOperation_GitScopeManager, mappings, subscriber, true);
    return manager;
}
Also used : GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) SubscriberScopeManager(org.eclipse.team.core.subscribers.SubscriberScopeManager) ResourceMapping(org.eclipse.core.resources.mapping.ResourceMapping) GitResourceVariantTreeSubscriber(org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber)

Aggregations

GitResourceVariantTreeSubscriber (org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 GitSubscriberMergeContext (org.eclipse.egit.core.synchronize.GitSubscriberMergeContext)5 GitSynchronizeDataSet (org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet)4 SubscriberScopeManager (org.eclipse.team.core.subscribers.SubscriberScopeManager)4 ResourceMapping (org.eclipse.core.resources.mapping.ResourceMapping)3 GitSubscriberResourceMappingContext (org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext)3 GitSynchronizeData (org.eclipse.egit.core.synchronize.dto.GitSynchronizeData)3 IResource (org.eclipse.core.resources.IResource)2 IFileRevision (org.eclipse.team.core.history.IFileRevision)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ITypedElement (org.eclipse.compare.ITypedElement)1 ResourceNode (org.eclipse.compare.ResourceNode)1 ICompareInput (org.eclipse.compare.structuremergeviewer.ICompareInput)1 IFile (org.eclipse.core.resources.IFile)1 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 ModelProvider (org.eclipse.core.resources.mapping.ModelProvider)1 RemoteResourceMappingContext (org.eclipse.core.resources.mapping.RemoteResourceMappingContext)1 ResourceMappingContext (org.eclipse.core.resources.mapping.ResourceMappingContext)1