Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-05-13 14:10:51 -0400
committerMichael Valenta2002-05-13 14:10:51 -0400
commite599ee42c39fb3959d4c45fedcbf34a6358d4dc6 (patch)
tree4133dcce651e9bf28dcdb6bc4ccd2625b99dc13e /bundles/org.eclipse.team.cvs.ui
parentb57d875e2ba9dc5b3079886025e1cf290e7fc2c1 (diff)
downloadeclipse.platform.team-e599ee42c39fb3959d4c45fedcbf34a6358d4dc6.tar.gz
eclipse.platform.team-e599ee42c39fb3959d4c45fedcbf34a6358d4dc6.tar.xz
eclipse.platform.team-e599ee42c39fb3959d4c45fedcbf34a6358d4dc6.zip
14332: CVS Module aliases disabled in M5 build
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui')
-rw-r--r--bundles/org.eclipse.team.cvs.ui/plugin.properties3
-rw-r--r--bundles/org.eclipse.team.cvs.ui/plugin.xml10
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java73
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java33
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java124
5 files changed, 180 insertions, 63 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.properties b/bundles/org.eclipse.team.cvs.ui/plugin.properties
index 314e4bc5d..1c0ff538e 100644
--- a/bundles/org.eclipse.team.cvs.ui/plugin.properties
+++ b/bundles/org.eclipse.team.cvs.ui/plugin.properties
@@ -91,6 +91,9 @@ ConfigureTags.tooltip=Configure the branch and version tags shown in the workben
CommitAction.label=&Commit...
CommitAction.tooltip=Commit
+CheckoutAction.label=Check Out &Module
+CheckoutAction.tooltip=Check out a module defined in CVSROOT/modules from the repository to the workspace
+
AddToWorkspaceAction.label=&Check Out As Project
AddToWorkspaceAction.tooltip=Check out a module from the repository to the workspace
diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml b/bundles/org.eclipse.team.cvs.ui/plugin.xml
index 2361db6bf..b04c8dd9d 100644
--- a/bundles/org.eclipse.team.cvs.ui/plugin.xml
+++ b/bundles/org.eclipse.team.cvs.ui/plugin.xml
@@ -313,6 +313,16 @@
id="org.eclipse.team.ccvs.ui.showHistory">
</action>
</objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.team.internal.ccvs.core.resources.RemoteModule"
+ id="org.eclipse.team.ccvs.ui.RemoteModuleContributions">
+ <action
+ label="%CheckoutAction.label"
+ tooltip="%CheckoutAction.tooltip"
+ class="org.eclipse.team.internal.ccvs.ui.actions.CheckoutAction"
+ id="org.eclipse.team.ccvs.ui.checkout">
+ </action>
+ </objectContribution>
<objectContribution
objectClass="org.eclipse.team.internal.ccvs.core.ILogEntry"
id="org.eclipse.team.ccvs.ui.LogEntryContributions">
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java
index 84ef87e27..49bbf9e77 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java
@@ -36,39 +36,22 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation;
* -Works only for remote folders
* -Does not prompt for project name; uses folder name instead
*/
-public class AddToWorkspaceAction extends CVSAction {
+public class AddToWorkspaceAction extends CheckoutAction {
/**
- * Returns the selected remote folders
+ * Returns the selected remote folders.
+ * Remove any module aliases as they may cause problems on checkout this way
*/
protected ICVSRemoteFolder[] getSelectedRemoteFolders() {
- ArrayList resources = null;
- if (!selection.isEmpty()) {
- resources = new ArrayList();
- Iterator elements = ((IStructuredSelection) selection).iterator();
- while (elements.hasNext()) {
- Object next = elements.next();
- if (next instanceof ICVSRemoteFolder) {
- if (!Checkout.ALIAS.isElementOf(((ICVSRemoteFolder)next).getLocalOptions())) {
- resources.add(next);
- }
- continue;
- }
- if (next instanceof IAdaptable) {
- IAdaptable a = (IAdaptable) next;
- Object adapter = a.getAdapter(ICVSRemoteFolder.class);
- if (adapter instanceof ICVSRemoteFolder) {
- if (!Checkout.ALIAS.isElementOf(((ICVSRemoteFolder)adapter).getLocalOptions())) {
- resources.add(adapter);
- }
- continue;
- }
- }
+ ICVSRemoteFolder[] allFolders = super.getSelectedRemoteFolders();
+ if (allFolders.length == 0) return allFolders;
+ ArrayList resources = new ArrayList();
+ for (int i = 0; i < allFolders.length; i++) {
+ ICVSRemoteFolder folder = allFolders[i];
+ if (!Checkout.ALIAS.isElementOf(folder.getLocalOptions())) {
+ resources.add(folder);
}
}
- if (resources != null && !resources.isEmpty()) {
- return (ICVSRemoteFolder[])resources.toArray(new ICVSRemoteFolder[resources.size()]);
- }
- return new ICVSRemoteFolder[0];
+ return (ICVSRemoteFolder[])resources.toArray(new ICVSRemoteFolder[resources.size()]);
}
/*
@@ -116,40 +99,6 @@ public class AddToWorkspaceAction extends CVSAction {
}
}, Policy.bind("AddToWorkspaceAction.checkoutFailed"), this.PROGRESS_DIALOG); //$NON-NLS-1$
}
-
- private static String getTaskName(ICVSRemoteFolder[] remoteFolders) {
- if (remoteFolders.length == 1) {
- ICVSRemoteFolder folder = remoteFolders[0];
- return Policy.bind("AddToWorkspace.taskName1", folder.getRepositoryRelativePath()); //$NON-NLS-1$
- }
- else {
- return Policy.bind("AddToWorkspace.taskNameN", new Integer(remoteFolders.length).toString()); //$NON-NLS-1$
- }
- }
-
- protected IPromptCondition getOverwriteLocalAndFileSystemPrompt() {
- return new IPromptCondition() {
- // prompt if resource in workspace exists or exists in local file system
- public boolean needsPrompt(IResource resource) {
- File localLocation = getFileLocation(resource);
- if(resource.exists() || localLocation.exists()) {
- return true;
- }
- return false;
- }
- public String promptMessage(IResource resource) {
- File localLocation = getFileLocation(resource);
- if(resource.exists()) {
- return Policy.bind("AddToWorkspaceAction.thisResourceExists", resource.getName());//$NON-NLS-1$
- } else {
- return Policy.bind("AddToWorkspaceAction.thisExternalFileExists", resource.getName());//$NON-NLS-1$
- }//$NON-NLS-1$
- }
- private File getFileLocation(IResource resource) {
- return new File(resource.getParent().getLocation().toFile(), resource.getName());
- }
- };
- }
/*
* @see TeamAction#isEnabled()
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
index 00beee131..9b575fb5e 100644
--- 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
@@ -35,6 +35,7 @@ import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSStatus;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
+import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.AvoidableMessageDialog;
@@ -281,7 +282,37 @@ abstract public class CVSAction extends TeamAction {
}
return new ICVSResource[0];
}
-
+
+ /**
+ * Get selected CVS remote folders
+ */
+ protected ICVSRemoteFolder[] getSelectedRemoteFolders() {
+ ArrayList resources = null;
+ if (!selection.isEmpty()) {
+ resources = new ArrayList();
+ Iterator elements = ((IStructuredSelection) selection).iterator();
+ while (elements.hasNext()) {
+ Object next = elements.next();
+ if (next instanceof ICVSRemoteFolder) {
+ resources.add(next);
+ continue;
+ }
+ if (next instanceof IAdaptable) {
+ IAdaptable a = (IAdaptable) next;
+ Object adapter = a.getAdapter(ICVSRemoteFolder.class);
+ if (adapter instanceof ICVSRemoteFolder) {
+ resources.add(adapter);
+ continue;
+ }
+ }
+ }
+ }
+ if (resources != null && !resources.isEmpty()) {
+ return (ICVSRemoteFolder[])resources.toArray(new ICVSRemoteFolder[resources.size()]);
+ }
+ return new ICVSRemoteFolder[0];
+ }
+
/**
* Checks if a the resources' parent's tags are different then the given tag.
* Prompts the user that they are adding mixed tags and returns <code>true</code> if
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java
new file mode 100644
index 000000000..9314fb497
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * 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.lang.reflect.InvocationTargetException;
+import java.util.HashSet;
+import java.util.Set;
+import java.io.File;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.IAction;
+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.CVSProviderPlugin;
+import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.ui.IPromptCondition;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ccvs.ui.PromptingDialog;
+
+/**
+ * The purpose of the CheckoutAction is to allow the checkout of module aliases into the
+ */
+public class CheckoutAction extends CVSAction {
+
+ /**
+ * @see CVSAction#execute(IAction)
+ */
+ protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
+
+ // Fetch the module expansions for the folder
+ final ICVSRemoteFolder[] remoteFolders = getSelectedRemoteFolders();
+ final String[][] expansions = new String[1][0];
+ expansions[0] = null;
+ CVSUIPlugin.runWithProgress(getShell(), true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ expansions[0] = CVSProviderPlugin.getProvider().getExpansions(remoteFolders, monitor);
+ } catch (CVSException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ });
+ if (expansions[0] == null) return;
+
+ // If the folder exists, inform the user that it will be overridden
+ Set targetProjects = new HashSet();
+ for (int i = 0; i < expansions[0].length; i++) {
+ String string = expansions[0][i];
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(new Path(string).segment(0));
+ targetProjects.add(project);
+ }
+ IResource[] projects = (IResource[]) targetProjects.toArray(new IResource[targetProjects.size()]);
+ PromptingDialog prompt = new PromptingDialog(getShell(), projects,
+ getOverwriteLocalAndFileSystemPrompt(),
+ Policy.bind("ReplaceWithAction.confirmOverwrite"));//$NON-NLS-1$
+ if (prompt.promptForMultiple().length != projects.length) return;
+
+ CVSUIPlugin.runWithProgress(getShell(), true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ monitor.setTaskName(getTaskName(remoteFolders));
+ CVSProviderPlugin.getProvider().checkout(remoteFolders, null, Policy.subMonitorFor(monitor, 100));
+ } catch (TeamException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ });
+ }
+
+ /**
+ * @see TeamAction#isEnabled()
+ */
+ protected boolean isEnabled() throws TeamException {
+ return getSelectedRemoteFolders().length == 1;
+ }
+
+ protected static String getTaskName(ICVSRemoteFolder[] remoteFolders) {
+ if (remoteFolders.length == 1) {
+ ICVSRemoteFolder folder = remoteFolders[0];
+ return Policy.bind("AddToWorkspace.taskName1", folder.getRepositoryRelativePath()); //$NON-NLS-1$
+ }
+ else {
+ return Policy.bind("AddToWorkspace.taskNameN", new Integer(remoteFolders.length).toString()); //$NON-NLS-1$
+ }
+ }
+
+ protected IPromptCondition getOverwriteLocalAndFileSystemPrompt() {
+ return new IPromptCondition() {
+ // prompt if resource in workspace exists or exists in local file system
+ public boolean needsPrompt(IResource resource) {
+ File localLocation = getFileLocation(resource);
+ if(resource.exists() || localLocation.exists()) {
+ return true;
+ }
+ return false;
+ }
+ public String promptMessage(IResource resource) {
+ File localLocation = getFileLocation(resource);
+ if(resource.exists()) {
+ return Policy.bind("AddToWorkspaceAction.thisResourceExists", resource.getName());//$NON-NLS-1$
+ } else {
+ return Policy.bind("AddToWorkspaceAction.thisExternalFileExists", resource.getName());//$NON-NLS-1$
+ }//$NON-NLS-1$
+ }
+ private File getFileLocation(IResource resource) {
+ return new File(resource.getParent().getLocation().toFile(), resource.getName());
+ }
+ };
+ }
+}

Back to the top