Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames2002-04-05 13:23:24 -0500
committerjames2002-04-05 13:23:24 -0500
commit770c72dec587bc390d892881e04ac6540143847e (patch)
tree3cffd2790540c903a486e6087f83e60ff4185dad
parent3d7ada4a541081a52709a1cb1042e1cce2b4540c (diff)
downloadeclipse.platform.team-770c72dec587bc390d892881e04ac6540143847e.tar.gz
eclipse.platform.team-770c72dec587bc390d892881e04ac6540143847e.tar.xz
eclipse.platform.team-770c72dec587bc390d892881e04ac6540143847e.zip
12230: Compare view: doesn't give revision info
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java78
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties2
2 files changed, 69 insertions, 11 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java
index 441392c76..b5894feaa 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java
@@ -26,9 +26,16 @@ import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Composite;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
import org.eclipse.team.ccvs.core.ICVSFile;
+import org.eclipse.team.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.ccvs.core.ICVSResource;
@@ -121,6 +128,13 @@ public class CVSCompareEditorInput extends CompareEditorInput {
if (element instanceof ResourceEditionNode) {
ICVSRemoteResource edition = ((ResourceEditionNode)element).getRemoteResource();
ICVSResource resource = (ICVSResource)edition;
+ if (edition instanceof ICVSRemoteFile) {
+ try {
+ return resource.getName() + " " + ((ICVSRemoteFile)edition).getRevision();
+ } catch (TeamException e) {
+ // fall through
+ }
+ }
try {
if (edition.isContainer()) {
CVSTag tag = ((ICVSRemoteFolder)edition).getTag();
@@ -220,19 +234,10 @@ public class CVSCompareEditorInput extends CompareEditorInput {
*/
private void initLabels() {
CompareConfiguration cc = (CompareConfiguration) getCompareConfiguration();
-
- String leftLabel = getLabel(left);
- cc.setLeftLabel(leftLabel);
- cc.setLeftImage(left.getImage());
-
- String rightLabel = getLabel(right);
- cc.setRightLabel(rightLabel);
- cc.setRightImage(right.getImage());
-
+ setLabels(cc, new StructuredSelection());
+
String title;
if (ancestor != null) {
- cc.setAncestorLabel(getLabel(ancestor));
- cc.setAncestorImage(ancestor.getImage());
title = Policy.bind("CVSCompareEditorInput.titleAncestor", new Object[] {guessResourceName(), getVersionLabel(ancestor), getVersionLabel(left), getVersionLabel(right)} );
} else {
String leftName = null;
@@ -249,6 +254,46 @@ public class CVSCompareEditorInput extends CompareEditorInput {
setTitle(title);
}
+ private void setLabels(CompareConfiguration cc, IStructuredSelection selection) {
+ ITypedElement left = this.left;
+ ITypedElement right = this.right;
+ ITypedElement ancestor = this.ancestor;
+
+ if (selection.size() == 1) {
+ Object s = selection.getFirstElement();
+ if (s instanceof ResourceDiffNode) {
+ ResourceDiffNode node = (ResourceDiffNode)s;
+ left = node.getLeft();
+ right = node.getRight();
+ ancestor = node.getAncestor();
+ if (left == null) {
+ cc.setLeftLabel(Policy.bind("CVSCompareEditorInput.noWorkspaceFile"));
+ cc.setLeftImage(right.getImage());
+ }
+ if (right == null) {
+ cc.setRightLabel(Policy.bind("CVSCompareEditorInput.noRepositoryFile"));
+ cc.setRightImage(left.getImage());
+ }
+ if (ancestor == null) ancestor = this.ancestor;
+ }
+ }
+
+ if (left != null) {
+ cc.setLeftLabel(getLabel(left));
+ cc.setLeftImage(left.getImage());
+ }
+
+ if (right != null) {
+ cc.setRightLabel(getLabel(right));
+ cc.setRightImage(right.getImage());
+ }
+
+ if (ancestor != null) {
+ cc.setAncestorLabel(getLabel(ancestor));
+ cc.setAncestorImage(ancestor.getImage());
+ }
+ }
+
/* (Non-javadoc)
* Method declared on CompareEditorInput
*/
@@ -397,4 +442,15 @@ public class CVSCompareEditorInput extends CompareEditorInput {
private boolean considerContentIfRevisionOrPathDiffers() {
return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS);
}
+ public Viewer createDiffViewer(Composite parent) {
+ Viewer viewer = super.createDiffViewer(parent);
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ CompareConfiguration cc = getCompareConfiguration();
+ setLabels(cc, (IStructuredSelection)event.getSelection());
+ }
+ });
+ return viewer;
+ }
+
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
index c44b1d6a0..151234a8b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
@@ -68,6 +68,8 @@ CVSCompareEditorInput.titleNoAncestor=Compare {0} {1} and {2}
CVSCompareEditorInput.titleNoAncestorDifferent=Compare {0} {1} and {2} {3}
CVSCompareEditorInput.workspace=Workspace: {0}
CVSCompareEditorInput.workspaceLabel=<workspace>
+CVSCompareEditorInput.noWorkspaceFile=No workspace file
+CVSCompareEditorInput.noRepositoryFile=No repository file
CVSCompareRevisionsInput.addToWorkspace=Get
CVSCompareRevisionsInput.compareResourceAndVersions=Compare {0} <workspace> and versions

Back to the top