Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-04-15 08:48:53 -0400
committerMichael Valenta2002-04-15 08:48:53 -0400
commitc8416a57300e5e3d7d81afb8c058f2dcb0f36706 (patch)
tree9bcb5d6dd6d20d356f498b5e925b4372d7abad7e
parent86ecd7da6ac70aa331e933f0127de110b0913368 (diff)
downloadeclipse.platform.team-c8416a57300e5e3d7d81afb8c058f2dcb0f36706.tar.gz
eclipse.platform.team-c8416a57300e5e3d7d81afb8c058f2dcb0f36706.tar.xz
eclipse.platform.team-c8416a57300e5e3d7d81afb8c058f2dcb0f36706.zip
13717: Should prompt when tagging with outgoing changes
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java75
1 files changed, 75 insertions, 0 deletions
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 c1fe5140b..b5ebe4fbd 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,21 +13,28 @@ 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.ICVSResource;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
@@ -41,6 +48,55 @@ public class TagAction extends TeamAction {
// The previously remembered tag
private static String previousTag = ""; //$NON-NLS-1$
+ /**
+ * Copied from CVSDecorationRunnable
+ */
+ protected boolean isDirty(IResource resource) {
+ 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 {
+
+ // a project can't be dirty, continue with its children
+ if (resource.getType() == IResource.PROJECT) {
+ return true;
+ }
+
+ // if the resource does not exist in the workbench or on the file system, stop searching.
+ if(!resource.exists()) {
+ return false;
+ }
+
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
+ try {
+ if (!cvsResource.isManaged()) {
+ if (cvsResource.isIgnored()) {
+ return false;
+ } else {
+ // new resource, show as dirty
+ throw DECORATOR_EXCEPTION;
+ }
+ }
+ if (!cvsResource.isFolder()) {
+ if (((ICVSFile) cvsResource).isModified()) {
+ // file has changed, show as dirty
+ throw DECORATOR_EXCEPTION;
+ }
+ }
+ } catch (CVSException e) {
+ return true;
+ }
+ // no change -- keep looking in children
+ return true;
+ }
+ }, IResource.DEPTH_INFINITE, true);
+ } catch (CoreException e) {
+ //if our exception was caught, we know there's a dirty child
+ return e == DECORATOR_EXCEPTION;
+ }
+ return false;
+ }
+
/*
* @see IActionDelegate#run(IAction)
*/
@@ -49,6 +105,25 @@ public class TagAction extends TeamAction {
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
+ final IResource[] resources = getSelectedResources();
+ boolean isAnyDirty = false;
+ for (int i = 0; i < resources.length; i++) {
+ if(isDirty(resources[i])) {
+ isAnyDirty = true;
+ }
+ }
+
+ // 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() {

Back to the top