Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-10-21 23:45:13 +0000
committerMichael Valenta2003-10-21 23:45:13 +0000
commitcf532a3889fb8d5f173d20ab0a4fdd055f5eee46 (patch)
tree4e351be7e35b3d2099349982359ff40c91a72569
parent7243b23ffc42b86a47a7b523c23b7de8678ac91c (diff)
downloadeclipse.platform.team-cf532a3889fb8d5f173d20ab0a4fdd055f5eee46.tar.gz
eclipse.platform.team-cf532a3889fb8d5f173d20ab0a4fdd055f5eee46.tar.xz
eclipse.platform.team-cf532a3889fb8d5f173d20ab0a4fdd055f5eee46.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteResourcesAction.java49
1 files changed, 43 insertions, 6 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteResourcesAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteResourcesAction.java
index 1ccf064e5..039f9eee7 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteResourcesAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteResourcesAction.java
@@ -18,10 +18,16 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.CVSTag;
+import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
+import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
+import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.ui.CVSCompareEditorInput;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.ResourceEditionNode;
+import org.eclipse.team.internal.ccvs.ui.operations.RemoteCompareOperation;
/**
* This action is used for comparing two arbitrary remote resources. This is
@@ -37,22 +43,53 @@ public class CompareRemoteResourcesAction extends CVSAction {
MessageDialog.openError(getShell(), Policy.bind("CompareRemoteResourcesAction.unableToCompare"), Policy.bind("CompareRemoteResourcesAction.selectTwoResources")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
- ResourceEditionNode left = new ResourceEditionNode(editions[0]);
- ResourceEditionNode right = new ResourceEditionNode(editions[1]);
- CompareUI.openCompareEditorOnPage(
- new CVSCompareEditorInput(left, right),
- getTargetPage());
+ if (isSameFolder(editions)) {
+ // Run the compare operation in the background
+ try {
+ new RemoteCompareOperation(null, editions[0], getTag(editions[1]))
+ .run();
+ } catch (CVSException e) {
+ throw new InvocationTargetException(e);
+ } catch (InterruptedException e) {
+ // Ignored
+ }
+ } else {
+ ResourceEditionNode left = new ResourceEditionNode(editions[0]);
+ ResourceEditionNode right = new ResourceEditionNode(editions[1]);
+ CompareUI.openCompareEditorOnPage(
+ new CVSCompareEditorInput(left, right),
+ getTargetPage());
+ }
}
}, false /* cancelable */, PROGRESS_BUSYCURSOR);
}
+ protected CVSTag getTag(ICVSRemoteResource resource) throws CVSException {
+ CVSTag tag = null;
+ if (resource.isContainer()) {
+ tag = ((ICVSRemoteFolder)resource).getTag();
+ } else {
+ ResourceSyncInfo info = ((ICVSRemoteFile)resource).getSyncInfo();
+ if (info != null) tag = info.getTag();
+ }
+ if (tag == null) tag = CVSTag.DEFAULT;
+ return tag;
+ }
+
+ protected boolean isSameFolder(ICVSRemoteResource[] editions) {
+ return editions[0].getRepository().equals(editions[1].getRepository())
+ && editions[0].getRepositoryRelativePath().equals(editions[1].getRepositoryRelativePath());
+ }
+
/*
* @see TeamAction#isEnabled()
*/
protected boolean isEnabled() throws TeamException {
ICVSRemoteResource[] resources = getSelectedRemoteResources();
if (resources.length != 2) return false;
- return resources[0].isContainer() == resources[1].isContainer();
+ if (resources[0].isContainer() != resources[1].isContainer()) return false;
+ // Don't allow comparisons of two unrelated remote projects
+ return !resources[0].isContainer() || isSameFolder(resources);
}
}

Back to the top