Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java1
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java118
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java31
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UncommittedChangesDialog.java132
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java23
-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.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java10
7 files changed, 94 insertions, 228 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java
index b0ff28239..03f98b145 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java
@@ -1013,7 +1013,6 @@ public class CVSUIMessages extends NLS {
public static String ReplaceWithTagAction_0;
public static String ReplaceWithTagAction_1;
public static String ReplaceWithTagAction_2;
- public static String ReplaceWithTagAction_4;
public static String UncommittedChangesDialog_2;
public static String UncommittedChangesDialog_3;
public static String UncommittedChangesDialog_4;
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 130fdd12e..24682b1b1 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
@@ -12,93 +12,53 @@ package org.eclipse.team.internal.ccvs.ui.actions;
import java.lang.reflect.InvocationTargetException;
-import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.resources.mapping.ResourceMappingContext;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.window.Window;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.ui.*;
-import org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation;
+import org.eclipse.team.internal.ccvs.ui.operations.*;
import org.eclipse.team.internal.ccvs.ui.tags.TagSelectionDialog;
import org.eclipse.team.internal.ccvs.ui.tags.TagSource;
-import org.eclipse.team.internal.core.InfiniteSubProgressMonitor;
-import org.eclipse.team.internal.ui.dialogs.ResourceMappingResourceDisplayArea;
-import org.eclipse.ui.PlatformUI;
/**
* Action for replace with tag.
*/
public class ReplaceWithTagAction extends WorkspaceTraversalAction {
- /* package*/ static UncommittedChangesDialog getPromptingDialog(final Shell shell, final ResourceMapping[] mappings) {
- final UncommittedChangesDialog[] dialog = new UncommittedChangesDialog[] { null };
- try {
- PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- dialog[0] = new UncommittedChangesDialog(shell, CVSUIMessages.ReplaceWithTagAction_4, mappings, monitor) {
- protected String getSingleMappingMessage(ResourceMapping mapping) {
- String label = ResourceMappingResourceDisplayArea.getLabel(mapping);
- if (getAllMappings().length == 1) {
- return NLS.bind(CVSUIMessages.ReplaceWithTagAction_2, new String[] { label });
- }
- return NLS.bind(CVSUIMessages.ReplaceWithTagAction_0, new String[] { label });
- }
-
- protected String getMultipleMappingsMessage() {
- return CVSUIMessages.ReplaceWithTagAction_1;
- }
- protected String getHelpContextId() {
- return IHelpContextIds.REPLACE_OVERWRITE_PROMPT;
- }
- };
- }
- });
- } catch (InvocationTargetException e) {
- CVSUIPlugin.openError(shell, null, null, e);
- return null;
- } catch (InterruptedException e) {
- return null;
- }
- return dialog[0];
- }
-
- protected static ResourceMapping[] checkOverwriteOfDirtyResources(Shell shell, ResourceMapping[] mappings, IProgressMonitor monitor) {
- // Prompt for any uncommitted changes
- UncommittedChangesDialog dialog = getPromptingDialog(shell, mappings);
- if (dialog == null) return null;
- mappings = dialog.promptToSelectMappings();
- if(mappings.length == 0) {
- // nothing to do
- return null;
- }
-
- return mappings;
- }
-
/*
* Method declared on IActionDelegate.
*/
public void execute(IAction action) throws InterruptedException, InvocationTargetException {
// Setup the holders
- final ResourceMapping[][] resourceMappings = new ResourceMapping[][] {null};
final CVSTag[] tag = new CVSTag[] {null};
+ final ReplaceOperation replaceOperation = new ReplaceOperation(getTargetPart(), getCVSResourceMappings(), tag[0]);
+ if (hasOutgoingChanges(replaceOperation)) {
+ final boolean[] keepGoing = new boolean[] { true };
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ OutgoingChangesDialog dialog = new OutgoingChangesDialog(getShell(), replaceOperation.getScope(),
+ CVSUIMessages.ReplaceWithTagAction_2,
+ CVSUIMessages.ReplaceWithTagAction_0,
+ CVSUIMessages.ReplaceWithTagAction_1);
+ int result = dialog.open();
+ keepGoing[0] = result == Window.OK;
+ }
+ });
+ if (!keepGoing[0])
+ return;
+ }
+
// Show a busy cursor while display the tag selection dialog
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
monitor = Policy.monitorFor(monitor);
- resourceMappings[0] = checkOverwriteOfDirtyResources(getShell(), getCVSResourceMappings(), new InfiniteSubProgressMonitor(monitor, 100));
- if(resourceMappings[0] == null || resourceMappings[0].length == 0) {
- // nothing to do
- return;
- }
- TagSelectionDialog dialog = new TagSelectionDialog(getShell(), TagSource.create(resourceMappings[0]),
+ TagSelectionDialog dialog = new TagSelectionDialog(getShell(), TagSource.create(replaceOperation.getScope().getMappings()),
CVSUIMessages.ReplaceWithTagAction_message,
CVSUIMessages.TagSelectionDialog_Select_a_Tag_1,
TagSelectionDialog.INCLUDE_ALL_TAGS,
@@ -113,7 +73,7 @@ public class ReplaceWithTagAction extends WorkspaceTraversalAction {
// For non-projects determine if the tag being loaded is the same as the resource's parent
// If it's not, warn the user that they will have strange sync behavior
try {
- if(!CVSAction.checkForMixingTags(getShell(), getRootTraversalResources(resourceMappings[0], ResourceMappingContext.LOCAL_CONTEXT, null), tag[0])) {
+ if(!CVSAction.checkForMixingTags(getShell(), replaceOperation.getScope().getRoots(), tag[0])) {
tag[0] = null;
return;
}
@@ -123,10 +83,42 @@ public class ReplaceWithTagAction extends WorkspaceTraversalAction {
}
}, false /* cancelable */, PROGRESS_BUSYCURSOR);
- if (resourceMappings[0] == null || resourceMappings[0].length == 0 || tag[0] == null) return;
+ if (tag[0] == null) return;
// Peform the replace in the background
- new ReplaceOperation(getTargetPart(), resourceMappings[0], tag[0]).run();
+ replaceOperation.setTag(tag[0]);
+ replaceOperation.run();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ccvs.ui.actions.TagAction#performPrompting(org.eclipse.team.internal.ccvs.ui.operations.ITagOperation)
+ */
+ protected boolean performPrompting(ITagOperation operation) {
+ if (operation instanceof TagOperation) {
+ final TagOperation tagOperation = (TagOperation) operation;
+ try {
+ if (hasOutgoingChanges(tagOperation)) {
+ final boolean[] keepGoing = new boolean[] { true };
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ OutgoingChangesDialog dialog = new OutgoingChangesDialog(getShell(), tagOperation.getScope(),
+ CVSUIMessages.TagLocalAction_2,
+ CVSUIMessages.TagLocalAction_0,
+ CVSUIMessages.TagLocalAction_1);
+ int result = dialog.open();
+ keepGoing[0] = result == Window.OK;
+ }
+ });
+ return keepGoing[0];
+ }
+ return true;
+ } catch (InterruptedException e) {
+ // Ignore
+ } catch (InvocationTargetException e) {
+ handle(e);
+ }
+ }
+ return false;
}
/**
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java
index 58b10d465..bd5746115 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java
@@ -12,14 +12,12 @@ package org.eclipse.team.internal.ccvs.ui.actions;
import java.lang.reflect.InvocationTargetException;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.ui.*;
-import org.eclipse.team.internal.ccvs.ui.operations.*;
-import org.eclipse.ui.PlatformUI;
+import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
+import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
+import org.eclipse.team.internal.ccvs.ui.operations.ITagOperation;
+import org.eclipse.team.internal.ccvs.ui.operations.TagOperation;
/**
* Action that tags the local workspace with a version tag.
@@ -56,27 +54,6 @@ public class TagLocalAction extends TagAction {
}
return false;
}
-
- private boolean hasOutgoingChanges(final RepositoryProviderOperation operation) throws InvocationTargetException, InterruptedException {
- final boolean[] hasChange = new boolean[] { false };
- PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
- try {
- monitor.beginTask("Looking for uncommitted changes", 100);
- operation.buildScope(Policy.subMonitorFor(monitor, 50));
- hasChange[0] = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().hasLocalChanges(
- operation.getScope().getTraversals(),
- Policy.subMonitorFor(monitor, 50));
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- });
- return hasChange[0];
- }
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.ui.actions.TagAction#createTagOperation()
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UncommittedChangesDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UncommittedChangesDialog.java
deleted file mode 100644
index 7d557863c..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UncommittedChangesDialog.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.actions;
-
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.resources.mapping.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.subscribers.Subscriber;
-import org.eclipse.team.core.synchronize.FastSyncInfoFilter;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ui.dialogs.*;
-
-public abstract class UncommittedChangesDialog extends MappingSelectionDialog {
-
- public static final class UncommittedFilter implements IResourceMappingResourceFilter {
- public boolean select(IResource resource,
- ResourceMapping mapping, ResourceTraversal traversal)
- throws CoreException {
- SyncInfo info = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().getSyncInfo(resource);
- return (info != null && getResourceFilter().select(info));
- }
- }
-
- public static FastSyncInfoFilter getResourceFilter() {
- // Return a filter that selects outgoing changes
- return new SyncInfoDirectionFilter(new int[] { SyncInfo.OUTGOING, SyncInfo.CONFLICTING });
- }
-
- private final ResourceMapping[] allMappings;
-
-
- public UncommittedChangesDialog(Shell parentShell, String dialogTitle, ResourceMapping[] mappings, IProgressMonitor monitor) {
- super(parentShell, dialogTitle, getMatchingMappings(mappings, CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(), getResourceFilter(), monitor), new UncommittedFilter());
- allMappings = mappings;
- }
-
-
- protected String getResourceListMessage(ResourceMapping mapping) {
- if (mapping == null) {
- return CVSUIMessages.UncommittedChangesDialog_2;
- } else {
- String label = ResourceMappingResourceDisplayArea.getLabel(mapping);
- if (mapping.getModelObject() instanceof IFile) {
- return NLS.bind(CVSUIMessages.UncommittedChangesDialog_4, new String[] { label });
- }
- return NLS.bind(CVSUIMessages.UncommittedChangesDialog_3, new String[] { label });
- }
- }
-
- /**
- * Prompt for any mappings that match the given filter in order to allow the
- * user to explicitly include/exclude those mappings.
- * @return the mappings that either didn't match the filter or were selected by the user
- */
- public ResourceMapping[] promptToSelectMappings() {
- ResourceMapping[] matchingMappings = getMappings();
- if (matchingMappings.length > 0) {
- int code = open();
- if (code == OK) {
- Set result = new HashSet();
- result.addAll(Arrays.asList(allMappings));
- result.removeAll(Arrays.asList(matchingMappings));
- result.addAll(Arrays.asList(getCheckedMappings()));
- return (ResourceMapping[]) result.toArray(new ResourceMapping[result.size()]);
- }
- return new ResourceMapping[0];
- } else {
- // No mappings match the filter so return them all
- return allMappings;
- }
- }
-
- private static ResourceMapping[] getMatchingMappings(ResourceMapping[] mappings, final Subscriber subscriber, final FastSyncInfoFilter resourceFilter, IProgressMonitor monitor) {
- Set result = new HashSet();
- for (int i = 0; i < mappings.length; i++) {
- ResourceMapping mapping = mappings[i];
- if (matchesFilter(mapping, subscriber, resourceFilter, monitor)) {
- result.add(mapping);
- }
- }
- return (ResourceMapping[]) result.toArray(new ResourceMapping[result.size()]);
- }
-
- private static boolean matchesFilter(ResourceMapping mapping, final Subscriber subscriber, final FastSyncInfoFilter resourceFilter, IProgressMonitor monitor) {
- try {
- mapping.accept(ResourceMappingContext.LOCAL_CONTEXT, new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- SyncInfo info = subscriber.getSyncInfo(resource);
- if (info != null && resourceFilter.select(info)) {
- throw new CoreException(Status.OK_STATUS);
- }
- return true;
- }
- }, monitor);
- } catch (CoreException e) {
- if (e.getStatus().isOK()) {
- return true;
- }
- CVSUIPlugin.log(e);
- }
- return false;
- }
-
-
- public ResourceMapping[] getAllMappings() {
- return allMappings;
- }
-
- protected boolean includeCancelButton() {
- if (super.includeCancelButton()) {
- return getAllMappings().length > 1;
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java
index 18366be8f..ddda3f158 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java
@@ -23,6 +23,8 @@ import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.subscribers.Subscriber;
import org.eclipse.team.core.subscribers.SubscriberResourceMappingContext;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation;
import org.eclipse.ui.PlatformUI;
/**
@@ -122,4 +124,25 @@ public abstract class WorkspaceTraversalAction extends WorkspaceAction {
}
return false;
}
+
+ protected boolean hasOutgoingChanges(final RepositoryProviderOperation operation) throws InvocationTargetException, InterruptedException {
+ final boolean[] hasChange = new boolean[] { false };
+ PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ try {
+ monitor.beginTask("Looking for uncommitted changes", 100);
+ operation.buildScope(Policy.subMonitorFor(monitor, 50));
+ hasChange[0] = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().hasLocalChanges(
+ operation.getScope().getTraversals(),
+ Policy.subMonitorFor(monitor, 50));
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
+ }
+ }
+ });
+ return hasChange[0];
+ }
}
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 55b0be2af..e66fdbb80 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
@@ -1068,10 +1068,9 @@ ModelReplaceOperation_1=The selected elements contain local changes. You may cho
ModelReplaceOperation_2=&Overwrite
ModelReplaceOperation_3=&Preview
-ReplaceWithTagAction_0=There are uncommitted changes in ''{0}'' that will be overwritten. Should ''{0}'' be replaced?
-ReplaceWithTagAction_1=The following contain &uncommitted changes that will be overwritten. Check those that should be included in the replace operation.
-ReplaceWithTagAction_2=There are uncommitted changes in ''{0}'' that will be overwritten. Should the replace proceed?
-ReplaceWithTagAction_4=Replace with Uncommitted Changes
+ReplaceWithTagAction_0=The selected elements contain uncommitted changes that will be overwritten. Should the replace proceed?
+ReplaceWithTagAction_1=The following elements contain &uncommitted changes that will be overwritten.
+ReplaceWithTagAction_2=Replace with Uncommitted Changes
UncommittedChangesDialog_2=Select an item to see the dirty resources it contains.
UncommittedChangesDialog_3=&The dirty resources contained in ''{0}''
UncommittedChangesDialog_4=&The full path of ''{0}''
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java
index 7170389b3..7e004895a 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java
@@ -36,7 +36,7 @@ import org.eclipse.ui.IWorkbenchPart;
*/
public class UpdateOperation extends SingleCommandOperation {
- CVSTag tag;
+ private CVSTag tag;
/**
* Create an UpdateOperation that will perform on update on the given resources
@@ -147,4 +147,12 @@ public class UpdateOperation extends SingleCommandOperation {
protected ResourceMappingContext getResourceMappingContext() {
return SubscriberResourceMappingContext.createContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber());
}
+
+ public CVSTag getTag() {
+ return tag;
+ }
+
+ public void setTag(CVSTag tag) {
+ this.tag = tag;
+ }
}

Back to the top