diff options
author | Dani Megert | 2010-08-24 15:09:21 +0000 |
---|---|---|
committer | Dani Megert | 2010-08-24 15:09:21 +0000 |
commit | 13d664e00c712be7cec0dd9b8d688d5cc69ed7a8 (patch) | |
tree | 511554be2722b81ae8a93a4ff5a996a8035c8926 /bundles/org.eclipse.team.ui | |
parent | fd143b0acb1bcb6df9e4a08dba0c792fa3b1b36b (diff) | |
download | eclipse.platform.team-13d664e00c712be7cec0dd9b8d688d5cc69ed7a8.tar.gz eclipse.platform.team-13d664e00c712be7cec0dd9b8d688d5cc69ed7a8.tar.xz eclipse.platform.team-13d664e00c712be7cec0dd9b8d688d5cc69ed7a8.zip |
Fixed bug 138853: [Sync View] Compare editor opened by Synchronize view only shows right author
Diffstat (limited to 'bundles/org.eclipse.team.ui')
5 files changed, 136 insertions, 35 deletions
diff --git a/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF index 6922d8c34..6da90f51e 100644 --- a/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF @@ -24,7 +24,7 @@ Export-Package: org.eclipse.team.internal.ui;x-friends:="org.eclipse.team.cvs.ss Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.3.0,4.0.0)";resolution:=optional, org.eclipse.core.resources;bundle-version="[3.3.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", - org.eclipse.team.core;bundle-version="[3.3.0,4.0.0)", + org.eclipse.team.core;bundle-version="[3.6.0,4.0.0)", org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", org.eclipse.compare;bundle-version="[3.3.0,4.0.0)", org.eclipse.ui.forms;bundle-version="[3.3.0,4.0.0)", diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java index 6c035f601..276b63f4d 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java @@ -355,30 +355,49 @@ public class Utils { final IResourceVariant base = sync.getBase(); String baseAuthor = null; String remoteAuthor = null; + String localAuthor = null; String localContentId = sync.getLocalContentIdentifier(); + String remoteContentId= remote != null ? remote.getContentIdentifier() : null; + String baseContentId= base != null ? base.getContentIdentifier() : null; if (isShowAuthor()) { baseAuthor = getAuthor(base, monitor); - remoteAuthor = getAuthor(remote, monitor); + if (baseContentId != null && baseContentId.equals(remoteContentId)) + remoteAuthor= baseAuthor; + else + remoteAuthor= getAuthor(remote, monitor); + + if (localContentId != null) { + if (localContentId.equals(baseContentId)) + localAuthor= baseAuthor; + else if (localContentId.equals(remoteAuthor)) + localAuthor= remoteAuthor; + else + localAuthor= sync.getLocalAuthor(monitor); + } } if (localContentId != null) { - config.setLeftLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_localLabelExists, new String[] { localContentId })); + if (localAuthor != null) { + config.setLeftLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_localLabelAuthorExists, new String[] { localContentId, localAuthor })); + } else { + config.setLeftLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_localLabelExists, new String[] { localContentId })); + } } else { config.setLeftLabel(TeamUIMessages.SyncInfoCompareInput_localLabel); } if (remote != null) { if (remoteAuthor != null) { - config.setRightLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_remoteLabelAuthorExists, new String[] { remote.getContentIdentifier(), remoteAuthor })); + config.setRightLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_remoteLabelAuthorExists, new String[] { remoteContentId, remoteAuthor })); } else { - config.setRightLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_remoteLabelExists, new String[] { remote.getContentIdentifier() })); + config.setRightLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_remoteLabelExists, new String[] { remoteContentId })); } } else { config.setRightLabel(TeamUIMessages.SyncInfoCompareInput_remoteLabel); } if (base != null) { if (baseAuthor != null) { - config.setAncestorLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_baseLabelAuthorExists, new String[] { base.getContentIdentifier(), baseAuthor })); + config.setAncestorLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_baseLabelAuthorExists, new String[] { baseContentId, baseAuthor })); } else { - config.setAncestorLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_baseLabelExists, new String[] { base.getContentIdentifier() })); + config.setAncestorLabel(NLS.bind(TeamUIMessages.SyncInfoCompareInput_baseLabelExists, new String[] { baseContentId })); } } else { config.setAncestorLabel(TeamUIMessages.SyncInfoCompareInput_baseLabel); diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceCompareInputChangeNotifier.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceCompareInputChangeNotifier.java index ad82d5fee..519ef26b7 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceCompareInputChangeNotifier.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceCompareInputChangeNotifier.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,6 +31,7 @@ import org.eclipse.team.core.mapping.ISynchronizationContext; import org.eclipse.team.core.mapping.provider.ResourceDiffTree; import org.eclipse.team.internal.ui.*; import org.eclipse.team.internal.ui.history.FileRevisionTypedElement; +import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement; /** * A change notifier for resource-based compare inputs. @@ -60,7 +61,7 @@ public class ResourceCompareInputChangeNotifier extends CompareInputChangeNotifi if (author != null) { return NLS.bind(TeamUIMessages.SyncInfoCompareInput_baseLabelAuthorExists, new String[] { revision.getContentIdentifier(), author }); } else if (revision.isPropertyMissing()) { - fetchAuthors(input); + fetchAuthors(rdci); } } return NLS.bind(TeamUIMessages.SyncInfoCompareInput_baseLabelExists, new String[] { revision.getContentIdentifier() }); @@ -82,6 +83,17 @@ public class ResourceCompareInputChangeNotifier extends CompareInputChangeNotifi ResourceDiffCompareInput rdci = (ResourceDiffCompareInput) input; String localContentId = rdci.getLocalContentId(); if (localContentId != null) { + ITypedElement element= rdci.getLeft(); + if (element instanceof LocalResourceTypedElement) { + if (TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SHOW_AUTHOR_IN_COMPARE_EDITOR)) { + String author= ((LocalResourceTypedElement)element).getAuthor(); + if (author != null) { + return NLS.bind(TeamUIMessages.SyncInfoCompareInput_localLabelAuthorExists, new String[] { localContentId, author }); + } else { // NOTE: Must not check for revision#isPropertyMissing() as this will always return true for the workspace file revision + fetchAuthors(rdci); + } + } + } return NLS.bind(TeamUIMessages.SyncInfoCompareInput_localLabelExists, new String[] { localContentId }); } else { return TeamUIMessages.SyncInfoCompareInput_localLabel; @@ -107,7 +119,7 @@ public class ResourceCompareInputChangeNotifier extends CompareInputChangeNotifi if (author != null) { return NLS.bind(TeamUIMessages.SyncInfoCompareInput_remoteLabelAuthorExists, new String[] { revision.getContentIdentifier(), author }); } else if (revision.isPropertyMissing()) { - fetchAuthors(input); + fetchAuthors(rdci); } } return NLS.bind(TeamUIMessages.SyncInfoCompareInput_remoteLabelExists, new String[] { revision.getContentIdentifier() }); @@ -161,6 +173,8 @@ public class ResourceCompareInputChangeNotifier extends CompareInputChangeNotifi } private final CompareInputLabelProvider labelProvider = new CompareInputLabelProvider(); + + private Object fetchingInput; /** * Create a notifier @@ -298,7 +312,10 @@ public class ResourceCompareInputChangeNotifier extends CompareInputChangeNotifi return labelProvider; } - public void fetchAuthors(final Object input) { + public void fetchAuthors(final ResourceDiffCompareInput input) { + if (fetchingInput == input) + return; + fetchingInput= input; runInBackground(new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { fetchAuthors(input, monitor); @@ -306,13 +323,9 @@ public class ResourceCompareInputChangeNotifier extends CompareInputChangeNotifi }); } - protected void fetchAuthors(Object input, IProgressMonitor monitor) throws CoreException { - if (input instanceof ResourceDiffCompareInput) { - ResourceDiffCompareInput rdci = (ResourceDiffCompareInput) input; - if (rdci.updateAuthorInfo(monitor)) { - fireLabelProviderChange(input); - } - } + protected void fetchAuthors(ResourceDiffCompareInput input, IProgressMonitor monitor) throws CoreException { + if (input.updateAuthorInfo(monitor)) + fireLabelProviderChange(input); } private void fireLabelProviderChange(Object input) { diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceDiffCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceDiffCompareInput.java index 803a67af8..942dc9cfb 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceDiffCompareInput.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceDiffCompareInput.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * Copyright (c) 2006, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -293,14 +293,22 @@ public class ResourceDiffCompareInput extends AbstractCompareInput implements IS } } - private boolean propogateAuthorIfSameRevision(FileRevisionTypedElement oldContributor, - FileRevisionTypedElement newContributor) { + private boolean propogateAuthorIfSameRevision(FileRevisionTypedElement oldContributor, FileRevisionTypedElement newContributor) { if (oldContributor == null || newContributor == null) return false; - String author = oldContributor.getAuthor(); - if (newContributor.getAuthor() == null - && author != null - && oldContributor.getContentIdentifier().equals(newContributor.getContentIdentifier())) { + String author= oldContributor.getAuthor(); + if (newContributor.getAuthor() == null && author != null && oldContributor.getContentIdentifier().equals(newContributor.getContentIdentifier())) { + newContributor.setAuthor(author); + return true; + } + return false; + } + + private boolean propogateAuthorIfSameRevision(FileRevisionTypedElement oldContributor, LocalResourceTypedElement newContributor) { + if (oldContributor == null || newContributor == null) + return false; + String author= oldContributor.getAuthor(); + if (newContributor.getAuthor() == null && author != null && oldContributor.getContentIdentifier().equals(getLocalContentId())) { newContributor.setAuthor(author); return true; } @@ -312,7 +320,7 @@ public class ResourceDiffCompareInput extends AbstractCompareInput implements IS * @return whether the diff associated with this input has changed */ public boolean needsUpdate() { - IDiff newNode = context.getDiffTree().getDiff(getResource()); + IDiff newNode= context.getDiffTree().getDiff(getResource()); return newNode == null || !newNode.equals(node); } @@ -325,21 +333,32 @@ public class ResourceDiffCompareInput extends AbstractCompareInput implements IS } public boolean updateAuthorInfo(IProgressMonitor monitor) throws CoreException { - boolean authorFound = false; - FileRevisionTypedElement ancestor = (FileRevisionTypedElement)getAncestor(); - FileRevisionTypedElement right = (FileRevisionTypedElement)getRight(); + boolean fireEvent= false; + FileRevisionTypedElement ancestor= (FileRevisionTypedElement)getAncestor(); + FileRevisionTypedElement right= (FileRevisionTypedElement)getRight(); + LocalResourceTypedElement left= (LocalResourceTypedElement)getLeft(); + if (ancestor != null && ancestor.getAuthor() == null) { ancestor.fetchAuthor(monitor); - if (right != null && propogateAuthorIfSameRevision(ancestor, right)) { - return true; - } - authorFound = ancestor.getAuthor() != null; + fireEvent|= ancestor.getAuthor() != null; } + + fireEvent|= propogateAuthorIfSameRevision(ancestor, right); + fireEvent|= propogateAuthorIfSameRevision(ancestor, left); + if (right != null && right.getAuthor() == null) { right.fetchAuthor(monitor); - authorFound |= right.getAuthor() != null; + fireEvent|= right.getAuthor() != null; } - return authorFound; + + fireEvent|= propogateAuthorIfSameRevision(right, left); + + if (left != null && left.getAuthor() == null) { + left.fetchAuthor(monitor); + fireEvent|= fireEvent= left.getAuthor() != null; + } + + return fireEvent; } } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java index 0e0a735a2..85b92b33c 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java @@ -17,6 +17,9 @@ import org.eclipse.compare.ResourceNode; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.*; +import org.eclipse.team.core.history.IFileHistoryProvider; +import org.eclipse.team.core.history.IFileRevision; +import org.eclipse.team.internal.ui.Utils; import org.eclipse.ui.IEditorInput; /** @@ -49,6 +52,7 @@ public class LocalResourceTypedElement extends ResourceNode implements IAdaptabl private boolean exists; private boolean useSharedDocument = true; private EditableSharedDocumentAdapter.ISharedDocumentAdapterListener sharedDocumentListener; + private String author; /** * Creates an element for the given resource. @@ -343,4 +347,50 @@ public class LocalResourceTypedElement extends ResourceNode implements IAdaptabl this.sharedDocumentListener = sharedDocumentListener; } + /** + * Returns the author of the workspace file revision if any. + * + * @return the author or <code>null</code> if the author has not been fetched or is not + * available + * @since 3.7 + * @see #fetchAuthor(IProgressMonitor) + */ + public String getAuthor() { + return author; + } + + /** + * Fetches the author from the repository. + * + * @param monitor the progress monitor + * @throws CoreException if fetching the revision properties fails + * @since 3.7 + */ + public void fetchAuthor(IProgressMonitor monitor) throws CoreException { + author= null; + + IFileHistoryProvider fileHistoryProvider= Utils.getHistoryProvider(getResource()); + if (fileHistoryProvider == null) + return; + + IFileRevision revision= fileHistoryProvider.getWorkspaceFileRevision(getResource()); + if (revision == null) + return; + + // NOTE: Must not check for revision#isPropertyMissing() as this will always return true for the workspace file revision + revision= revision.withAllProperties(monitor); + + author= revision.getAuthor(); + } + + /** + * Sets the author. + * + * @param author the author + * @since 3.7 + */ + public void setAuthor(String author) { + this.author= author; + } + } |