Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-04-18 13:25:48 +0000
committerJean Michel-Lemieux2002-04-18 13:25:48 +0000
commit4e4e233681511a311099c461eb6d7511da464af5 (patch)
treec7776600a4978efab2b979043a80d10ff84b47fa
parent3dce15bdc19d0ec73acd8f329308c3191f6e59eb (diff)
downloadeclipse.platform.team-GetRevisionBranch.tar.gz
eclipse.platform.team-GetRevisionBranch.tar.xz
eclipse.platform.team-GetRevisionBranch.zip
*** empty log message ***GetRevisionBranch
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagConfigurationDialog.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java48
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java78
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java48
4 files changed, 103 insertions, 73 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagConfigurationDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagConfigurationDialog.java
index e96704bd4..43a53703d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagConfigurationDialog.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagConfigurationDialog.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
- * IBM - Initial API and implementation
+ * IBM - Initial implementation
******************************************************************************/
package org.eclipse.team.internal.ccvs.ui;
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java
index 7c30ea6f9..0ad109242 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java
@@ -1,28 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial implementation
+ ******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.actions;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.wizards.BranchWizard;
-import org.eclipse.team.ui.actions.TeamAction;
/**
* BranchAction tags the selected resources with a branch tag specified by the user,
* and optionally updates the local resources to point to the new branch.
*/
-public class BranchAction extends TeamAction {
+public class BranchAction extends CVSAction {
/*
* @see IActionDelegate#run(IAction)
*/
@@ -42,29 +40,7 @@ public class BranchAction extends TeamAction {
* @see TeamAction#isEnabled()
*/
protected boolean isEnabled() throws TeamException {
- IResource[] resources = getSelectedResources();
- // allow operation for homegeneous multiple selections
- if(resources.length>0) {
- int type = -1;
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- if(type!=-1) {
- if(type!=resource.getType()) return false;
- }
- if(RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) == null) {
- return false;
- }
- type = resource.getType();
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- if(cvsResource.isFolder()) {
- if( ! ((ICVSFolder)cvsResource).isCVSFolder()) return false;
- } else {
- if( ! cvsResource.isManaged()) return false;
- }
- }
- return true;
- }
- return false;
+ return isSelectionNonOverlapping();
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java
new file mode 100644
index 000000000..714b7423d
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial implementation
+ ******************************************************************************/
+package org.eclipse.team.internal.ccvs.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.team.core.RepositoryProvider;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.internal.ccvs.core.ICVSFolder;
+import org.eclipse.team.internal.ccvs.core.ICVSResource;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
+import org.eclipse.team.ui.actions.TeamAction;
+
+/**
+ * Contains helper methods for CVS actions.
+ *
+ * [Note: it would be nice to have common CVS error handling
+ * placed here and have all CVS actions subclass. For example
+ * error handling UI could provide a retry facility for actions
+ * if they have failed.]
+ */
+abstract public class CVSAction extends TeamAction {
+ /**
+ * Answers <code>true</code> if the current selection contains resource that don't
+ * have overlapping paths and <code>false</code> otherwise.
+ */
+ protected boolean isSelectionNonOverlapping() throws TeamException {
+ IResource[] resources = getSelectedResources();
+ // allow operation for non-overlapping resource selections
+ if(resources.length>0) {
+ List validPaths = new ArrayList(2);
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+
+ // only allow cvs resources to be selected
+ if(RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) == null) {
+ return false;
+ }
+
+ // check if this resource overlaps other selections
+ IPath resourceFullPath = resource.getFullPath();
+ if(!validPaths.isEmpty()) {
+ for (Iterator it = validPaths.iterator(); it.hasNext();) {
+ IPath path = (IPath) it.next();
+ if(path.isPrefixOf(resourceFullPath) ||
+ resourceFullPath.isPrefixOf(path)) {
+ return false;
+ }
+ }
+ }
+ validPaths.add(resourceFullPath);
+
+ // ensure that resources are managed
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
+ if(cvsResource.isFolder()) {
+ if( ! ((ICVSFolder)cvsResource).isCVSFolder()) return false;
+ } else {
+ if( ! cvsResource.isManaged()) return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java
index bdd975ce1..1bd1c021f 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java
@@ -1,24 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial implementation
+ ******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.actions;
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.merge.MergeWizard;
-import org.eclipse.team.ui.actions.TeamAction;
-public class MergeAction extends TeamAction {
+public class MergeAction extends CVSAction {
/*
* @see IActionDelegate#run(IAction)
*/
@@ -37,28 +35,6 @@ public class MergeAction extends TeamAction {
* @see TeamAction#isEnabled()
*/
protected boolean isEnabled() throws TeamException {
- IResource[] resources = getSelectedResources();
- // allow operation for homegeneous multiple selections
- if(resources.length>0) {
- int type = -1;
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- if(type!=-1) {
- if(type!=resource.getType()) return false;
- }
- if(RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) == null) {
- return false;
- }
- type = resource.getType();
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- if(cvsResource.isFolder()) {
- if( ! ((ICVSFolder)cvsResource).isCVSFolder()) return false;
- } else {
- if( ! cvsResource.isManaged()) return false;
- }
- }
- return true;
- }
- return false;
+ return isSelectionNonOverlapping();
}
}

Back to the top