Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2005-02-04 21:58:31 +0000
committerMichael Valenta2005-02-04 21:58:31 +0000
commit1c2c4008ef211672f69092bc185df6f2e99f5247 (patch)
tree0599c6a0c3a3e010f8dcd0e2342638b815490efd /bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java
parent246d18feb154eb5159823ab2ca727f7474bfc45d (diff)
downloadeclipse.platform.team-1c2c4008ef211672f69092bc185df6f2e99f5247.tar.gz
eclipse.platform.team-1c2c4008ef211672f69092bc185df6f2e99f5247.tar.xz
eclipse.platform.team-1c2c4008ef211672f69092bc185df6f2e99f5247.zip
Release ResourceMapping support to HEAD
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java')
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java79
1 files changed, 79 insertions, 0 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java
new file mode 100644
index 000000000..61ee35199
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ccvs.ui.actions;
+
+import java.util.*;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.*;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+
+
+/**
+ * A specialized workspace actions that operates on resource traversals
+ * instead of resources/
+ */
+public abstract class WorkspaceTraversalAction extends WorkspaceAction {
+
+ /**
+ * Override to use the roots of the traversals as the selected resources.
+ * On it's own, this would be enough to make the actions work but all the operations
+ * would be deep (which is bad) so subclasses will need to look for traversals
+ * when executed.
+ * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#getSelectedResources()
+ */
+ protected IResource[] getSelectedResourcesWithOverlap() {
+ try {
+ // Get all the traversals since enablement may be based on entire selection
+ ResourceTraversal[] traversals = getSelectedTraversals(null, null);
+ Set resources = new HashSet();
+ for (int i = 0; i < traversals.length; i++) {
+ ResourceTraversal traversal = traversals[i];
+ resources.addAll(Arrays.asList(traversal.getResources()));
+ }
+ return (IResource[]) resources.toArray(new IResource[resources.size()]);
+ } catch (TeamException e) {
+ CVSUIPlugin.log(e);
+ return new IResource[0];
+ }
+ }
+
+
+ /**
+ * Return the selected mappings that contain resources
+ * within a CVS managed project.
+ * @return the selected mappings that contain resources
+ * within a CVS managed project
+ */
+ protected ResourceMapping[] getCVSResourceMappings() {
+ return getSelectedResourceMappings(CVSProviderPlugin.getTypeId());
+ }
+
+ protected static IResource[] getRootTraversalResources(ResourceMapping[] mappings, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
+ List result = new ArrayList();
+ for (int i = 0; i < mappings.length; i++) {
+ ResourceMapping mapping = mappings[i];
+ ResourceTraversal[] traversals = mapping.getTraversals(context, monitor);
+ for (int j = 0; j < traversals.length; j++) {
+ ResourceTraversal traversal = traversals[j];
+ result.addAll(Arrays.asList(traversal.getResources()));
+ }
+ }
+ return (IResource[]) result.toArray(new IResource[result.size()]);
+ }
+
+}

Back to the top