Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-04-19 15:31:29 +0000
committerJean Michel-Lemieux2002-04-19 15:31:29 +0000
commit9e689fa3c673e645eaa4647d82176e99618f516f (patch)
tree415ae466f8c68dcdad0496051c7e3044db947f94
parent37997ab658017386206e140dbc205ec3664943fc (diff)
downloadeclipse.platform.team-Root_ShareConnectionBranch.tar.gz
eclipse.platform.team-Root_ShareConnectionBranch.tar.xz
eclipse.platform.team-Root_ShareConnectionBranch.zip
Bug13102: Should warn user when tagging with outgoing changesRoot_ShareConnectionBranch
- new prompting dialog added to unify our prompting story.
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IPromptCondition.java29
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PromptingDialog.java119
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddToWorkspaceAction.java127
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java64
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java76
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java28
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java33
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java45
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties11
9 files changed, 257 insertions, 275 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IPromptCondition.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IPromptCondition.java
new file mode 100644
index 000000000..4ebe0cd6c
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IPromptCondition.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Input to a confirm prompt
+ */
+public interface IPromptCondition {
+ /**
+ * Answers <code>true</code> if a prompt is required for this resource and
+ * false otherwise.
+ */
+ public boolean needsPrompt(IResource resource);
+
+ /**
+ * Answers the message to include in the prompt.
+ */
+ public String promptMessage(IResource resource);
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PromptingDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PromptingDialog.java
new file mode 100644
index 000000000..61a56dafd
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PromptingDialog.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * A confirmation dialog helper that will either show a 'yes/no/yes to all/cancel'
+ * dialog to confirm an action performed on several resources or if only one
+ * resource is specified 'ok/cancel' will be shown.
+ */
+public class PromptingDialog {
+ private IResource[] resources;
+ private Shell shell;
+ private String[] buttons;
+ private boolean confirmOverwrite = true;
+ private IPromptCondition condition;
+ private String title;
+
+ /**
+ * Prompt for the given resources using the specific condition. The prompt dialog will
+ * have the title specified.
+ */
+ public PromptingDialog(Shell shell, IResource[] resources, IPromptCondition condition, String title) {
+ this.condition = condition;
+ this.resources = resources;
+ this.title = title;
+ this.shell = shell;
+ if(resources.length == 1) {
+ buttons = new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL};
+ } else {
+ buttons = new String[] {
+ IDialogConstants.YES_LABEL,
+ IDialogConstants.NO_LABEL,
+ IDialogConstants.YES_TO_ALL_LABEL,
+ IDialogConstants.CANCEL_LABEL};
+ }
+ }
+
+ /**
+ * Call to calculate and show prompt. If no resources satisfy the prompt condition
+ * a dialog won't be shown. The resources for which the user confirmed the action
+ * are returned.
+ */
+ public IResource[] promptForMultiple() throws InterruptedException {
+ List targetResources = new ArrayList();
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ if (condition.needsPrompt(resource) && confirmOverwrite) {
+ if (confirmOverwrite(condition.promptMessage(resource))) {
+ targetResources.add(resource);
+ }
+ } else {
+ targetResources.add(resource);
+ }
+ }
+ return (IResource[]) targetResources.toArray(new IResource[targetResources.size()]);
+ }
+
+ /**
+ * A helper prompt condition for prompting for CVS dirty state.
+ */
+ public static IPromptCondition getOverwriteLocalChangesPrompt() {
+ return new IPromptCondition() {
+ public boolean needsPrompt(IResource resource) {
+ return CVSDecorator.isDirty(resource);
+ }
+ public String promptMessage(IResource resource) {
+ return Policy.bind("ReplaceWithAction.localChanges", resource.getName());
+ }
+ };
+ }
+
+ /**
+ * Opens the confirmation dialog based on the prompt condition settings.
+ */
+ private boolean confirmOverwrite(String msg) throws InterruptedException {
+ if (!confirmOverwrite) {
+ return true;
+ }
+ final MessageDialog dialog =
+ new MessageDialog(shell, title, null, msg, MessageDialog.QUESTION, buttons, 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 or Cancel
+ return false;
+ case 2://Yes to all
+ confirmOverwrite = false;
+ return true;
+ case 3://Cancel
+ default:
+ throw new InterruptedException();
+ }
+ }
+}
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 7489befeb..5156ed251 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,23 +8,26 @@ package org.eclipse.team.internal.ccvs.ui.actions;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
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.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.client.Checkout;
+import org.eclipse.team.internal.ccvs.ui.*;
import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ccvs.ui.PromptingDialog;
import org.eclipse.team.ui.actions.TeamAction;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
@@ -67,6 +70,7 @@ public class AddToWorkspaceAction extends TeamAction {
}
return new ICVSRemoteFolder[0];
}
+
/*
* @see IActionDelegate#run(IAction)
*/
@@ -75,51 +79,39 @@ public class AddToWorkspaceAction extends TeamAction {
public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
try {
ICVSRemoteFolder[] folders = getSelectedRemoteFolders();
-
- monitor.beginTask(null, 100);
- monitor.setTaskName(getTaskName(folders));
-
-
- boolean yesToAll = false;
- boolean yesToAllExternal = false;
- int action;
+
List targetProjects = new ArrayList();
- List targetFolders = new ArrayList();
+ Map targetFolders = new HashMap();
for (int i = 0; i < folders.length; i++) {
String name = folders[i].getName();
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
- if (project.exists()) {
- action = confirmOverwrite(project, yesToAll);
- yesToAll = action == 2;
- } else {
- File location = new File(project.getParent().getLocation().toFile(), project.getName());
- action = confirmOverwriteExternalFile(location, yesToAllExternal);
- yesToAllExternal = action == 2;
- }
- switch (action) {
- // no
- case 1:
- break;
- // yes to all
- case 2:
- // yes
- case 0:
- targetFolders.add(folders[i]);
- targetProjects.add(project);
- break;
- // cancel
- case 3:
- default:
- return;
- }
+ targetFolders.put(name, folders[i]);
+ targetProjects.add(project);
}
- if (targetFolders.size() > 0) {
- CVSProviderPlugin.getProvider().checkout((ICVSRemoteFolder[])targetFolders.toArray(new ICVSRemoteFolder[targetFolders.size()]),
- (IProject[])targetProjects.toArray(new IProject[targetProjects.size()]),
- Policy.subMonitorFor(monitor, 100));
+
+ IResource[] projects = (IResource[]) targetProjects.toArray(new IResource[targetProjects.size()]);
+
+ PromptingDialog prompt = new PromptingDialog(getShell(), projects,
+ getOverwriteLocalAndFileSystemPrompt(),
+ Policy.bind("ReplaceWithAction.confirmOverwrite"));
+ projects = prompt.promptForMultiple();
+
+ monitor.beginTask(null, 100);
+ if (projects.length != 0) {
+ IProject[] localFolders = new IProject[projects.length];
+ ICVSRemoteFolder[] remoteFolders = new ICVSRemoteFolder[projects.length];
+ for (int i = 0; i < projects.length; i++) {
+ localFolders[i] = (IProject)projects[i];
+ remoteFolders[i] = (ICVSRemoteFolder)targetFolders.get(projects[i].getName());
+ }
+
+ monitor.setTaskName(getTaskName(remoteFolders));
+ CVSProviderPlugin.getProvider().checkout(remoteFolders, localFolders, Policy.subMonitorFor(monitor, 100));
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
}
}
}, Policy.bind("AddToWorkspaceAction.checkoutFailed"), this.PROGRESS_DIALOG); //$NON-NLS-1$
@@ -135,45 +127,30 @@ public class AddToWorkspaceAction extends TeamAction {
}
}
- private int confirmOverwrite(IProject project, boolean yesToAll) {
- if (yesToAll) return 2;
- if ( ! project.exists()) return 0;
- final MessageDialog dialog =
- new MessageDialog(shell, Policy.bind("AddToWorkspaceAction.confirmOverwrite"), null, Policy.bind("AddToWorkspaceAction.thisResourceExists", project.getName()), MessageDialog.QUESTION, //$NON-NLS-1$ //$NON-NLS-2$
- 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();
+ 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;
}
- });
- return result[0];
- }
-
- private int confirmOverwriteExternalFile(File location, boolean yesToAll) {
- if (yesToAll) return 2;
- if ( ! location.exists()) return 0;
- final MessageDialog dialog =
- new MessageDialog(shell, Policy.bind("AddToWorkspaceAction.confirmOverwrite"), null, Policy.bind("AddToWorkspaceAction.thisExternalFileExists", location.getName()), MessageDialog.QUESTION, //$NON-NLS-1$ //$NON-NLS-2$
- 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();
+ public String promptMessage(IResource resource) {
+ File localLocation = getFileLocation(resource);
+ if(resource.exists()) {
+ return Policy.bind("AddToWorkspaceAction.thisResourceExists", resource.getName());
+ } else {
+ return Policy.bind("AddToWorkspaceAction.thisExternalFileExists", resource.getName());
+ }
}
- });
- return result[0];
+ 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/CheckoutAsAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java
index eeb61a213..0e132db42 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAsAction.java
@@ -6,27 +6,21 @@ package org.eclipse.team.internal.ccvs.ui.actions;
*/
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.team.internal.ccvs.core.client.Checkout;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.ui.actions.TeamAction;
+import org.eclipse.team.internal.ccvs.ui.PromptingDialog;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
/**
@@ -34,40 +28,7 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation;
* -Works only for remote folders
* -Does not prompt for project name; uses folder name instead
*/
-public class CheckoutAsAction extends TeamAction {
- /**
- * Returns the selected 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) {
- 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;
- }
- }
- }
- }
- if (resources != null && !resources.isEmpty()) {
- return (ICVSRemoteFolder[])resources.toArray(new ICVSRemoteFolder[resources.size()]);
- }
- return new ICVSRemoteFolder[0];
- }
+public class CheckoutAsAction extends AddToWorkspaceAction {
/*
* @see IActionDelegate#run(IAction)
*/
@@ -102,19 +63,16 @@ public class CheckoutAsAction extends TeamAction {
}
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(dialog.getValue());
- 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")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- if (!confirm[0]) return;
+
+ PromptingDialog prompt = new PromptingDialog(getShell(), new IResource[] {project},
+ getOverwriteLocalAndFileSystemPrompt(),
+ Policy.bind("ReplaceWithAction.confirmOverwrite"));
+ IResource[] resources = prompt.promptForMultiple();
+ if(resources.length != 0) {
+ monitor.beginTask(null, 100);
+ monitor.setTaskName(Policy.bind("CheckoutAsAction.taskname", name, project.getName())); //$NON-NLS-1$
+ CVSProviderPlugin.getProvider().checkout(folders, new IProject[] { project }, Policy.subMonitorFor(monitor, 100));
}
- monitor.beginTask(null, 100);
- monitor.setTaskName(Policy.bind("CheckoutAsAction.taskname", name, project.getName())); //$NON-NLS-1$
- CVSProviderPlugin.getProvider().checkout(folders, new IProject[] { project }, Policy.subMonitorFor(monitor, 100));
} catch (TeamException e) {
throw new InvocationTargetException(e);
}
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
deleted file mode 100644
index e231a02e8..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java
+++ /dev/null
@@ -1,76 +0,0 @@
-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.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.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.ui.actions.TeamAction;
-
-public abstract class ReplaceWithAction extends TeamAction {
- private boolean confirmOverwrite = true;
-
- /**
- * 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;
- }
-
- /**
- * It's important to note that actions have state and subclasses should
- * reset the confirmation setting before calling getConfirmOverwrite().
- */
- protected void setConfirmOverwrite(boolean shouldConfirm) {
- this.confirmOverwrite = shouldConfirm;
- }
-}
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 375debfe3..130ebcb11 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,7 +6,6 @@ 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;
@@ -20,31 +19,26 @@ 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.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.ui.CVSDecorator;
import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ccvs.ui.PromptingDialog;
+import org.eclipse.team.ui.actions.TeamAction;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
-public class ReplaceWithRemoteAction extends ReplaceWithAction {
+public class ReplaceWithRemoteAction extends TeamAction {
public void run(IAction action) {
run(new WorkspaceModifyOperation() {
public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
try {
- // Check if any resource is dirty.
- setConfirmOverwrite(true);
- IResource[] candidateResources = getSelectedResources();
- List targetResources = new ArrayList();
- for (int i = 0; i < candidateResources.length; i++) {
- IResource resource = candidateResources[i];
- if (CVSDecorator.isDirty(resource) && getConfirmOverwrite()) {
- if (confirmOverwrite(Policy.bind("ReplaceWithRemoteAction.localChanges", resource.getName()))) { //$NON-NLS-1$
- targetResources.add(resource);
- }
- } else {
- targetResources.add(resource);
- }
+ PromptingDialog dialog = new PromptingDialog(getShell(), getSelectedResources(),
+ PromptingDialog.getOverwriteLocalChangesPrompt(),
+ Policy.bind("ReplaceWithAction.confirmOverwrite"));
+ IResource[] resources = dialog.promptForMultiple();
+ if(resources.length == 0) {
+ // nothing to do
+ return;
}
// Do the replace
- Hashtable table = getProviderMapping((IResource[])targetResources.toArray(new IResource[targetResources.size()]));
+ Hashtable table = getProviderMapping(resources);
Set keySet = table.keySet();
monitor.beginTask("", keySet.size() * 1000); //$NON-NLS-1$
monitor.setTaskName(Policy.bind("ReplaceWithRemoteAction.replacing")); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java
index ca3b13148..f37e61c8a 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java
@@ -17,9 +17,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
-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.CVSException;
@@ -29,15 +27,16 @@ import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
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.CVSDecorator;
import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ccvs.ui.PromptingDialog;
import org.eclipse.team.internal.ccvs.ui.TagSelectionDialog;
+import org.eclipse.team.ui.actions.TeamAction;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
/**
* Action for replace with tag.
*/
-public class ReplaceWithTagAction extends ReplaceWithAction {
+public class ReplaceWithTagAction extends TeamAction {
/*
* Method declared on IActionDelegate.
*/
@@ -50,26 +49,14 @@ public class ReplaceWithTagAction extends ReplaceWithAction {
// Show a busy cursor while display the tag selection dialog
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- final IResource[] resources = getSelectedResources();
- boolean isAnyDirty = false;
- for (int i = 0; i < resources.length; i++) {
- if(CVSDecorator.isDirty(resources[i])) {
- isAnyDirty = true;
- }
- }
-
- // Confirm overwrite of locally modified resources
- if (isAnyDirty) {
- 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")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- if (!result[0]) return;
+ PromptingDialog prompt = new PromptingDialog(getShell(), getSelectedResources(),
+ PromptingDialog.getOverwriteLocalChangesPrompt(),
+ Policy.bind("ReplaceWithAction.confirmOverwrite"));
+ final IResource[] resources = prompt.promptForMultiple();
+ if(resources.length == 0) {
+ // nothing to do
+ return;
}
-
// show the tags for the projects of the selected resources
IProject[] projects = new IProject[resources.length];
for (int i = 0; i < resources.length; i++) {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java
index 7bb5f7a40..99711e09c 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java
@@ -13,35 +13,30 @@ import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
-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.CVSException;
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.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
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.core.syncinfo.ResourceSyncInfo;
+import org.eclipse.team.internal.ccvs.ui.*;
import org.eclipse.team.internal.ccvs.ui.CVSDecorator;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ccvs.ui.PromptingDialog;
import org.eclipse.team.ui.actions.TeamAction;
/**
@@ -57,27 +52,27 @@ public class TagAction extends TeamAction {
public void run(IAction action) {
final List messages = new ArrayList();
run(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
- final IResource[] resources = getSelectedResources();
- boolean isAnyDirty = false;
- for (int i = 0; i < resources.length; i++) {
- if(CVSDecorator.isDirty(resources[i])) {
- isAnyDirty = true;
+
+ IPromptCondition condition = new IPromptCondition() {
+ public boolean needsPrompt(IResource resource) {
+ return CVSDecorator.isDirty(resource);
+ }
+ public String promptMessage(IResource resource) {
+ return Policy.bind("TagAction.uncommittedChanges", resource.getName());
}
+ };
+
+ PromptingDialog prompt = new PromptingDialog(getShell(), getSelectedResources(),
+ condition,
+ Policy.bind("TagAction.uncommittedChangesTitle"));
+ IResource[] resources = prompt.promptForMultiple();
+ if(resources.length == 0) {
+ // nothing to do
+ return;
}
- // Confirm tagging with locally modified resources
- if (isAnyDirty) {
- final Shell shell = getShell();
- final boolean[] result = new boolean[] { false };
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- result[0] = MessageDialog.openConfirm(getShell(), Policy.bind("TagAction.uncommittedChangesTitle"), Policy.bind("TagAction.uncommittedChanges")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- if (!result[0]) return;
- }
final String[] result = new String[1];
getShell().getDisplay().syncExec(new Runnable() {
public void run() {
@@ -85,7 +80,7 @@ public class TagAction extends TeamAction {
}
});
if (result[0] == null) return;
- Hashtable table = getProviderMapping();
+ Hashtable table = getProviderMapping(resources);
Set keySet = table.keySet();
monitor.beginTask(null, keySet.size() * 1000);
Iterator iterator = keySet.iterator();
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 c515aa8b6..56056e7e0 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
@@ -372,7 +372,9 @@ ReplaceWithTagAction.mixingTags=You are mixing tags within a project. This may
ReplaceWithRemoteAction.replacing=Replacing
ReplaceWithRemoteAction.problemMessage=Error Replacing With Latest From Repository
-ReplaceWithRemoteAction.localChanges={0} has local changes which you are about to overwrite. Do you wish to overwrite?
+
+ReplaceWithAction.confirmOverwrite=Confirm Overwrite
+ReplaceWithAction.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
@@ -489,8 +491,8 @@ TagAction.tagWarningTitle=Warnings Occured
TagAction.tagProblemsMessage=Problems reported during tag operation
TagAction.tagResources=Tag Resources
TagAction.enterTag=Please enter a version tag:
-TagAction.uncommittedChangesTitle=Uncommitted Changes
-TagAction.uncommittedChanges=You are tagging resources that have uncommitted changes. These changes are not in the repository and will not be included in the version you are creating.
+TagAction.uncommittedChangesTitle=Confirm Uncommitted Changes
+TagAction.uncommittedChanges=You are tagging ''{0}'' that has uncommitted changes. These changes are not in the repository and will not be included in the version you are creating. Do you still want to tag this resource?
UpdateAction.update=Problems encountered performing update
UpdateAction.updating=Updating...
@@ -597,9 +599,6 @@ 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
-ReplaceWithAction.Confirm_Overwrite_3=Confirm Overwrite
-
-
ExtMethodPreferencePage_message=These variables define the external connection program to use with the \'ext\' connection method.\nThese values should be the same as the \'ext\' CVS command-line environment variable settings
ExtMethodPreferencePage_CVS_RSH=CVS_RSH:
ExtMethodPreferencePage_Browse=&Browse...

Back to the top