Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.team.core/META-INF/MANIFEST.MF4
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java20
-rw-r--r--bundles/org.eclipse.team.cvs.core/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java72
-rw-r--r--bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java31
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceCompareInputChangeNotifier.java35
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceDiffCompareInput.java53
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java50
9 files changed, 215 insertions, 54 deletions
diff --git a/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF
index ec82b814d..97cf318db 100644
--- a/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.team.core; singleton:=true
-Bundle-Version: 3.5.100.qualifier
+Bundle-Version: 3.6.0.qualifier
Bundle-Activator: org.eclipse.team.internal.core.TeamPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -24,5 +24,5 @@ Export-Package: org.eclipse.team.core,
Require-Bundle: 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.core.filesystem;bundle-version="[1.1.0,2.0.0)"
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java
index 00f0a3dc7..a9c4eeb3b 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -11,8 +11,7 @@
package org.eclipse.team.core.synchronize;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.*;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.variants.IResourceVariant;
@@ -184,7 +183,20 @@ public class SyncInfo implements IAdaptable {
public String getLocalContentIdentifier() {
return null;
}
-
+
+ /**
+ * Returns the author of the revision corresponding to the local resource or <code>null</code>
+ * if it doesn't have one. For example if the local file is shared in CVS this would be the
+ * revision author.
+ *
+ * @param monitor the progress monitor
+ * @return the author of the revision associated with the local file or <code>null</code>
+ * @since 3.6
+ */
+ public String getLocalAuthor(IProgressMonitor monitor) {
+ return null;
+ }
+
/**
* Returns the remote resource handle for the base resource,
* or <code>null</code> if the base resource does not exist.
diff --git a/bundles/org.eclipse.team.cvs.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.team.cvs.core/META-INF/MANIFEST.MF
index deccacd6b..39fad80c6 100644
--- a/bundles/org.eclipse.team.cvs.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.team.cvs.core/META-INF/MANIFEST.MF
@@ -18,7 +18,7 @@ Export-Package: org.eclipse.team.internal.ccvs.core;x-friends:="org.eclipse.team
org.eclipse.team.internal.ccvs.core.util;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui"
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.3.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.core.filesystem;bundle-version="[1.1.0,2.0.0)",
com.jcraft.jsch;bundle-version="[0.1.27,2.0.0)",
org.eclipse.jsch.core;bundle-version="[1.0.0,2.0.0)",
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java
index 2066da5c4..81b597ab7 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -23,6 +23,7 @@ import org.eclipse.team.internal.ccvs.core.resources.*;
import org.eclipse.team.internal.ccvs.core.syncinfo.*;
import org.eclipse.team.internal.ccvs.core.util.SyncFileChangeListener;
+
/**
* CVSSyncInfo
*/
@@ -343,25 +344,72 @@ public class CVSSyncInfo extends SyncInfo {
}
return result.toString();
}
-
+
+ public String getLocalContentIdentifier() {
+ ResourceSyncInfo info= getSyncInfoForLocal(getCVSFile());
+ return info != null ? info.getRevision() : null;
+ }
+
/* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.SyncInfo#getContentIdentifier()
+ * @see org.eclipse.team.core.synchronize.SyncInfo#getLocalAuthor(org.eclipse.core.runtime.IProgressMonitor)
+ * @since 3.6
*/
- public String getLocalContentIdentifier() {
- try {
- IResource local = getLocal();
- if (local != null && local.getType() == IResource.FILE) {
- // it's a file, return the revision number if we can find one
- ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile) local);
- ResourceSyncInfo info = cvsFile.getSyncInfo();
- if (info != null) {
- return info.getRevision();
+ public String getLocalAuthor(IProgressMonitor monitor) {
+ final ICVSFile cvsFile= getCVSFile();
+ if (cvsFile == null)
+ return null;
+
+ final ResourceSyncInfo info= getSyncInfoForLocal(cvsFile);
+ if (info == null)
+ return null;
+
+ final String localRevision= info.getRevision();
+ if (localRevision == null)
+ return null;
+
+ final ILogEntry entries[]= getLogEntries(cvsFile, monitor);
+ if (entries == null || entries.length == 0)
+ return null;
+
+ for (int i = 0; i < entries.length; i++) {
+ try {
+ if (localRevision.equals(entries[i].getRemoteFile().getRevision())) {
+ return entries[i].getAuthor();
}
+ } catch (TeamException e) {
+ CVSProviderPlugin.log(e);
}
+ }
+ return null;
+ }
+
+ private static ResourceSyncInfo getSyncInfoForLocal(ICVSFile cvsFile) {
+ if (cvsFile == null)
+ return null;
+
+ try {
+ return cvsFile.getSyncInfo();
} catch (CVSException e) {
CVSProviderPlugin.log(e);
return null;
}
+ }
+
+ private static ILogEntry[] getLogEntries(ICVSFile cvsFile, IProgressMonitor monitor) {
+ try {
+ return cvsFile.getLogEntries(monitor);
+ } catch (TeamException e) {
+ CVSProviderPlugin.log(e);
+ return null;
+ }
+ }
+
+ private ICVSFile getCVSFile() {
+ IResource local = getLocal();
+ if (local != null && local.getType() == IResource.FILE) {
+ return CVSWorkspaceRoot.getCVSFileFor((IFile)local);
+ }
return null;
}
+
}
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;
+ }
+
}

Back to the top