Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames2002-02-15 16:44:19 -0500
committerjames2002-02-15 16:44:19 -0500
commit9c5c19f74d21826a510991a728824cefb41a3cda (patch)
tree6bdc8b0c6401f74c8281ca27c0aafbbcdc95f9dd
parent6ac0e18258bd94daea43c3d3ae8f0a29b1df1614 (diff)
downloadeclipse.platform.team-9c5c19f74d21826a510991a728824cefb41a3cda.tar.gz
eclipse.platform.team-9c5c19f74d21826a510991a728824cefb41a3cda.tar.xz
eclipse.platform.team-9c5c19f74d21826a510991a728824cefb41a3cda.zip
9934: Too may prompts to overwrite
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java50
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java26
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties7
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/actions/TeamAction.java11
4 files changed, 77 insertions, 17 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java
index 9ea92bb7d..b7246e93a 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java
@@ -10,6 +10,8 @@ import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
@@ -17,13 +19,16 @@ import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.ui.actions.TeamAction;
+import org.eclipse.team.internal.ccvs.ui.Policy;
public abstract class ReplaceWithAction extends TeamAction {
+ private boolean confirmOverwrite = true;
+
/**
* Copied from CVSDecorationRunnable
*/
protected boolean isDirty(IResource resource) {
- final CoreException DECORATOR_EXCEPTION = new CoreException(new Status(IStatus.OK, "id", 1, "", null));
+ final CoreException DECORATOR_EXCEPTION = new CoreException(new Status(IStatus.OK, "id", 1, "", null)); //$NON-NLS-1$ //$NON-NLS-2$
try {
resource.accept(new IResourceVisitor() {
public boolean visit(IResource resource) throws CoreException {
@@ -73,4 +78,47 @@ public abstract class ReplaceWithAction extends TeamAction {
}
return false;
}
+
+ /**
+ * The user is attempting to load a project that already exists in
+ * the workspace. Prompt the user to confirm overwrite and return
+ * their choice.
+ */
+ protected boolean confirmOverwrite(String msg) throws InterruptedException {
+ if (!confirmOverwrite) {
+ return true;
+ }
+ String title = Policy.bind("ReplaceWithAction.Confirm_Overwrite_3"); //$NON-NLS-1$
+ final MessageDialog dialog =
+ new MessageDialog(shell, title, null, msg, MessageDialog.QUESTION,
+ new String[] {
+ IDialogConstants.YES_LABEL,
+ IDialogConstants.NO_LABEL,
+ IDialogConstants.YES_TO_ALL_LABEL,
+ IDialogConstants.CANCEL_LABEL},
+ 0);
+ // run in syncExec because callback is from an operation,
+ // which is probably not running in the UI thread.
+ shell.getDisplay().syncExec(
+ new Runnable() {
+ public void run() {
+ dialog.open();
+ }
+ });
+ switch (dialog.getReturnCode()) {
+ case 0://Yes
+ return true;
+ case 1://No
+ return false;
+ case 2://Yes to all
+ confirmOverwrite = false;
+ return true;
+ case 3://Cancel
+ default:
+ throw new InterruptedException();
+ }
+ }
+ protected boolean getConfirmOverwrite() {
+ return confirmOverwrite;
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java
index dc490c594..3a628196d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java
@@ -6,6 +6,7 @@ package org.eclipse.team.internal.ccvs.ui.actions;
*/
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
@@ -31,24 +32,21 @@ public class ReplaceWithRemoteAction extends ReplaceWithAction {
public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
try {
// Check if any resource is dirty.
- IResource[] resources = getSelectedResources();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
+ IResource[] candidateResources = getSelectedResources();
+ List targetResources = new ArrayList();
+ for (int i = 0; i < candidateResources.length; i++) {
+ IResource resource = candidateResources[i];
CVSTeamProvider provider = (CVSTeamProvider)TeamPlugin.getManager().getProvider(resource.getProject());
- if (isDirty(resource)) {
- // Warn the user they have local changes that will be overwritten
- final Shell shell = getShell();
- final boolean[] result = new boolean[] { false };
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- result[0] = MessageDialog.openQuestion(getShell(), Policy.bind("question"), Policy.bind("localChanges"));
- }
- });
- if (!result[0]) return;
+ if (isDirty(resource) && getConfirmOverwrite()) {
+ if (confirmOverwrite(Policy.bind("ReplaceWithRemoteAction.localChanges", resource.getName()))) {
+ targetResources.add(resource);
+ }
+ } else {
+ targetResources.add(resource);
}
}
// Do the replace
- Hashtable table = getProviderMapping();
+ Hashtable table = getProviderMapping((IResource[])targetResources.toArray(new IResource[targetResources.size()]));
Set keySet = table.keySet();
monitor.beginTask("", keySet.size() * 1000);
monitor.setTaskName(Policy.bind("ReplaceWithRemoteAction.replacing"));
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 223c91f83..c7067afff 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
@@ -243,6 +243,7 @@ ReplaceWithTagAction.replace=Error Replacing With Tag
ReplaceWithRemoteAction.replacing=Replacing
ReplaceWithRemoteAction.problemMessage=Error Replacing With Remote
+ReplaceWithRemoteAction.localChanges={0} has local changes which you are about to overwrite. Do you wish to overwrite?
RepositoryDialog.getRepository=Select a repository
RepositoryDialog.description=Select a repository to connect your project to
@@ -391,4 +392,8 @@ the_tag_applied_to_the_resource_43=the tag applied to the resource
keyword_subsitution_rule_for_the_resource_44=keyword subsitution rule for the resource
last_revision_loaded_into_workspace_45=last revision loaded into workspace
flag_indicating_that_the_file_has_outgoing_changes_46=flag indicating that the file has outgoing changes
-flag_indicating_that_the_file_has_been_added_to_the_server_47=flag indicating that the file has been added to the server \ No newline at end of file
+flag_indicating_that_the_file_has_been_added_to_the_server_47=flag indicating that the file has been added to the server
+
+ReplaceWithAction.Confirm_Overwrite_3=Confirm Overwrite
+
+
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/actions/TeamAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/actions/TeamAction.java
index d26e9527c..176338a99 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/actions/TeamAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/actions/TeamAction.java
@@ -268,7 +268,16 @@ public abstract class TeamAction extends ActionDelegate implements IObjectAction
* @return a hashtable mapping providers to their selected resources
*/
protected Hashtable getProviderMapping() {
- IResource[] resources = getSelectedResources();
+ return getProviderMapping(getSelectedResources());
+ }
+ /**
+ * Convenience method that maps the given resources to their providers.
+ * The returned Hashtable has keys which are ITeamProviders, and values
+ * which are Lists of IResources that are shared with that provider.
+ *
+ * @return a hashtable mapping providers to their resources
+ */
+ protected Hashtable getProviderMapping(IResource[] resources) {
Hashtable result = new Hashtable();
for (int i = 0; i < resources.length; i++) {
ITeamProvider provider = TeamPlugin.getManager().getProvider(resources[i].getProject());

Back to the top