Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames2002-02-01 16:45:13 +0000
committerjames2002-02-01 16:45:13 +0000
commitab83e8614a776a73254e4a01041fdd135c37f925 (patch)
treeb3071ce9922c57cc4683725655c368434d8f86d2
parent45b44c1817b9e7e2c9f1b9cef03c5bb2ab793b5f (diff)
downloadeclipse.platform.team-ab83e8614a776a73254e4a01041fdd135c37f925.tar.gz
eclipse.platform.team-ab83e8614a776a73254e4a01041fdd135c37f925.tar.xz
eclipse.platform.team-ab83e8614a776a73254e4a01041fdd135c37f925.zip
8781: "Yes to All" in overwrite on Check Out
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java62
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties2
2 files changed, 52 insertions, 12 deletions
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 5a3e94cb8..b5a89b0b1 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
@@ -8,12 +8,14 @@ package org.eclipse.team.internal.ccvs.ui.actions;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
@@ -72,29 +74,65 @@ public class AddToWorkspaceAction extends TeamAction {
public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
try {
ICVSRemoteFolder[] folders = getSelectedRemoteFolders();
- IProject[] projects = new IProject[folders.length];
+ boolean yesToAll = false;
+ List targetProjects = new ArrayList();
+ List targetFolders = new ArrayList();
for (int i = 0; i < folders.length; i++) {
String name = folders[i].getName();
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
- if (project.exists()) {
- // Make sure the user understands they will overwrite the project.
- final boolean[] confirm = new boolean[] { false };
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- confirm[0] = MessageDialog.openConfirm(shell, Policy.bind("confirmOverwriteTitle"), Policy.bind("confirmOverwrite"));
- }
- });
- if (!confirm[0]) return;
+ if (!yesToAll) {
+ switch (confirmOverwrite(project)) {
+ // yes
+ case 0:
+ targetFolders.add(folders[i]);
+ targetProjects.add(project);
+ break;
+ // no
+ case 1:
+ break;
+ // yes to all
+ case 2:
+ yesToAll = true;
+ targetFolders.add(folders[i]);
+ targetProjects.add(project);
+ break;
+ // cancel
+ case 3:
+ default:
+ return;
+ }
+ } else {
+ targetFolders.add(folders[i]);
+ targetProjects.add(project);
}
- projects[i] = project;
}
- CVSProviderPlugin.getProvider().checkout(folders, projects, monitor);
+ if (targetFolders.size() > 0) {
+ CVSProviderPlugin.getProvider().checkout((ICVSRemoteFolder[]) targetFolders.toArray(new ICVSRemoteFolder[targetFolders.size()]), (IProject[])targetProjects.toArray(new IProject[targetProjects.size()]), monitor);
+ }
} catch (TeamException e) {
throw new InvocationTargetException(e);
}
}
}, Policy.bind("AddToWorkspaceAction.add"), this.PROGRESS_DIALOG);
}
+ private int confirmOverwrite(IProject project) {
+ if (!project.exists()) return 0;
+ final MessageDialog dialog =
+ new MessageDialog(shell, Policy.bind("AddToWorkspaceAction.confirmOverwrite"), null, Policy.bind("AddToWorkspaceAction.thisResourceExists", project.getName()), MessageDialog.QUESTION,
+ new String[] {
+ IDialogConstants.YES_LABEL,
+ IDialogConstants.NO_LABEL,
+ IDialogConstants.YES_TO_ALL_LABEL,
+ IDialogConstants.CANCEL_LABEL},
+ 0);
+ final int[] result = new int[1];
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ result[0] = dialog.open();
+ }
+ });
+ return result[0];
+ }
/*
* @see TeamAction#isEnabled()
*/
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 9d9d1677f..d2167655c 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
@@ -12,6 +12,8 @@ AddAction.add=Add
AddAction.adding=Adding...
AddToWorkspaceAction.add=Checkout
+AddToWorkspaceAction.thisResourceExists=The resource "{0}" already exists in the workspace. Overwrite?
+AddToWorkspaceAction.confirmOverwrite=Confirm Overwrite
AutoDefineTagsAction.defineTags = Auto-discover tags

Back to the top