use of org.eclipse.egit.ui.internal.revision.FileRevisionTypedElement 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;
}
Aggregations