Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2005-02-03 17:11:07 +0000
committerMichael Valenta2005-02-03 17:11:07 +0000
commit8ddc73ac90cffedbb52aeb2b01077984ad4724e6 (patch)
tree2efd574237a74249d4b5674f27eee4d68bf2ae19
parentc82c15fe0b2748ab09f81ee290a165fb64743fea (diff)
downloadeclipse.platform.team-8ddc73ac90cffedbb52aeb2b01077984ad4724e6.tar.gz
eclipse.platform.team-8ddc73ac90cffedbb52aeb2b01077984ad4724e6.tar.xz
eclipse.platform.team-8ddc73ac90cffedbb52aeb2b01077984ad4724e6.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.cvs.ui/questions.txt23
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java29
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java60
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java127
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UncommittedChangesDialog.java118
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java24
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties8
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java7
-rw-r--r--bundles/org.eclipse.team.ui/plugin.xml2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/MappingSelectionDialog.java5
12 files changed, 233 insertions, 174 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/questions.txt b/bundles/org.eclipse.team.cvs.ui/questions.txt
index 006d76839..4be7546e1 100644
--- a/bundles/org.eclipse.team.cvs.ui/questions.txt
+++ b/bundles/org.eclipse.team.cvs.ui/questions.txt
@@ -21,11 +21,14 @@ Should we add this? We could also remove the getProjects() from the traversal.
Pending Items:
- - Action nablement code is not mapping aware
+ - WorkspaceAction enablement code is not mapping aware
+ - However, enablement is performed used the resources obtained from the traversals
+ - The resources will be collected for each action. Would be nice to do it once and share the result
- - Decide how to convert selected resources into mappers. Choices are a single mapper for multiple resources or
+ - [DONE] Decide how to convert selected resources into mappers. Choices are a single mapper for multiple resources or
a mapper per resource. The advantage of the second approach is that the mapper list will display each resource
as opposed to a single entry that must be expanded or selected to see the resources it maps to.
+ - a mapper per resource will be used
- [DONE] CVS commands need to respect DO_NOT_RECURSE flag
- DONE and TESTED for Update, Commit, Add, Tag and Branch
@@ -34,10 +37,15 @@ Pending Items:
- [DONE] Commit needs to be reworked but I'm postponing this until Silvio is done
- - [DEFERRED] Sync/Compare with Tag/Merge are a bit more complicated.
- - they require a scope that will allow the particpant to access the depth of the traversals
+ - Sync/Compare with Tag/Merge are a bit more complicated.
+ - [DEFERRED] they require a scope that will allow the particpant to access the depth of the traversals
- for now, they will be deep on th roots of the traversals
+ - [DONE] not enabled properly (because they are not subclasses of WorkspaceTraversalAction)
+ - Replace with Latest/Tag
+ - [DONE] use Mapping dialog for dirty overwrite
+ - run operation on mapping
+
- [DEFERRED] EditAction, UneditAction, ShowEditorsAction, GenerateDiffFileAction do not follow the standard action/operation pattern.
- The patch is complicated by current architecture (i.e. single resource root)
@@ -63,15 +71,18 @@ Pending Items:
need to be added to provide access to the traversal depth
- Transitive adapters
- - [PATCH READY] transitivity from IResource to ResourceMapping in adapter manager
+ - [PATCH READY BUT NOT NEEDED] transitivity from IResource to ResourceMapping in adapter manager
- is this need if UI does special handing?
- [PATCH READY] add ResourceMapping support to objectContribution handling
- - repository persistant property filtering for ResourceMappings (PropertyTester)
+ - [PATCH READY] repository persistant property filtering for ResourceMappings (PropertyTester)
- remove WorkbenchResourceMapping action filter!
- Add to version control, ignore on Project
- Performance!!!
+
+ - Provide context on update, replace that allows client to see remote state
+ - update example to use the context
Summary of changes:
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java
index 81c4abf7b..953d8c852 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java
@@ -21,7 +21,7 @@ import org.eclipse.team.internal.ccvs.ui.tags.TagSource;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
-public class CompareWithTagAction extends WorkspaceAction {
+public class CompareWithTagAction extends WorkspaceTraversalAction {
public void execute(IAction action) throws InvocationTargetException, InterruptedException {
final IResource[] resources = getSelectedResources();
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 d182ccdb5..1bbaf45cb 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
@@ -12,47 +12,42 @@ package org.eclipse.team.internal.ccvs.ui.actions;
import java.lang.reflect.InvocationTargetException;
-import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation;
import org.eclipse.team.internal.core.InfiniteSubProgressMonitor;
-import org.eclipse.team.internal.ui.dialogs.IPromptCondition;
-public class ReplaceWithRemoteAction extends WorkspaceAction {
+public class ReplaceWithRemoteAction extends WorkspaceTraversalAction {
+
public void execute(IAction action) throws InvocationTargetException, InterruptedException {
-
- final IResource[][] resources = new IResource[][] {null};
+ final ResourceMapping[][] resourceMappings = new ResourceMapping[][] {null};
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
try {
monitor = Policy.monitorFor(monitor);
- monitor.beginTask(null, 100);
- resources[0] = checkOverwriteOfDirtyResources(getSelectedResources(), new InfiniteSubProgressMonitor(monitor, 100));
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- } finally {
+ monitor.beginTask(null, 100);
+ resourceMappings[0] = ReplaceWithTagAction.checkOverwriteOfDirtyResources(getShell(), getCVSResourceMappings(), new InfiniteSubProgressMonitor(monitor, 100));
+ } finally {
monitor.done();
}
}
}, false /* cancelable */, PROGRESS_BUSYCURSOR);
- if (resources[0] == null || resources[0].length == 0) return;
+ if(resourceMappings[0] == null || resourceMappings[0].length == 0) {
+ // nothing to do
+ return;
+ }
// Peform the replace in the background
- new ReplaceOperation(getTargetPart(), resources[0], null, true).run();
+ new ReplaceOperation(getTargetPart(), resourceMappings[0], null, true).run();
}
- protected IPromptCondition getPromptCondition(IResource[] dirtyResources) {
- return getOverwriteLocalChangesPrompt(dirtyResources);
- }
-
/**
* @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getErrorTitle()
*/
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 f0d90294f..5539c9415 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,50 +12,72 @@ package org.eclipse.team.internal.ccvs.ui.actions;
import java.lang.reflect.InvocationTargetException;
-import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.ui.IHelpContextIds;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation;
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;
/**
* Action for replace with tag.
*/
-public class ReplaceWithTagAction extends WorkspaceAction {
+public class ReplaceWithTagAction extends WorkspaceTraversalAction {
+
+ /* package*/ static UncommittedChangesDialog getPromptingDialog(Shell shell, ResourceMapping[] mappings) {
+ return new UncommittedChangesDialog(shell, Policy.bind("TagLocalAction.4"), mappings) { //$NON-NLS-1$
+ protected String getSingleMappingMessage(ResourceMapping mapping) {
+ String label = ResourceMappingResourceDisplayArea.getLabel(mapping);
+ return Policy.bind("ReplaceWithTagAction.0", label); //$NON-NLS-1$
+ }
+
+ protected String getMultipleMappingsMessage() {
+ return Policy.bind("ReplaceWithTagAction.1"); //$NON-NLS-1$
+ }
+ };
+ }
+
+ protected static ResourceMapping[] checkOverwriteOfDirtyResources(Shell shell, ResourceMapping[] mappings, IProgressMonitor monitor) {
+ // Prompt for any uncommitted changes
+ UncommittedChangesDialog dialog = getPromptingDialog(shell, mappings);
+ 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 IResource[][] resources = new IResource[][] {null};
+ final ResourceMapping[][] resourceMappings = new ResourceMapping[][] {null};
final CVSTag[] tag = new CVSTag[] {null};
final boolean[] recurse = new boolean[] {true};
// Show a busy cursor while display the tag selection dialog
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
-
- try {
- resources[0] =
- checkOverwriteOfDirtyResources(
- getSelectedResources(),
- null /* no progress just a busy cursor for now */);
- } catch (CVSException e) {
- throw new InvocationTargetException(e);
- }
- if(resources[0].length == 0) {
+ 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(resources[0]),
+ TagSelectionDialog dialog = new TagSelectionDialog(getShell(), TagSource.create(resourceMappings[0]),
Policy.bind("ReplaceWithTagAction.message"), //$NON-NLS-1$
Policy.bind("TagSelectionDialog.Select_a_Tag_1"), //$NON-NLS-1$
TagSelectionDialog.INCLUDE_ALL_TAGS,
@@ -71,20 +93,20 @@ public class ReplaceWithTagAction extends WorkspaceAction {
// 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(), resources[0], tag[0])) {
+ if(!CVSAction.checkForMixingTags(getShell(), getRootTraversalResources(resourceMappings[0], null, null), tag[0])) {
tag[0] = null;
return;
}
- } catch (CVSException e) {
+ } catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
}, false /* cancelable */, PROGRESS_BUSYCURSOR); //$NON-NLS-1$
- if (resources[0] == null || resources[0].length == 0 || tag[0] == null) return;
+ if (resourceMappings[0] == null || resourceMappings[0].length == 0 || tag[0] == null) return;
// Peform the replace in the background
- new ReplaceOperation(getTargetPart(), resources[0], tag[0], recurse[0]).run();
+ new ReplaceOperation(getTargetPart(), resourceMappings[0], tag[0], recurse[0]).run();
}
/**
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java
index 481798ff0..a9f46fcf5 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java
@@ -34,7 +34,7 @@ import org.eclipse.ui.PlatformUI;
/**
* Action to initiate a CVS workspace synchronize
*/
-public class SyncAction extends WorkspaceAction {
+public class SyncAction extends WorkspaceTraversalAction {
public void execute(IAction action) throws InvocationTargetException {
final IResource[] resources = getResourcesToSync();
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 8c27d6f2c..66d09c72c 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
@@ -10,129 +10,31 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.actions;
-import java.util.*;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.resources.mapping.ResourceTraversal;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.subscribers.Subscriber;
-import org.eclipse.team.core.subscribers.SubscriberResourceMappingContext;
-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.*;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
+import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.operations.ITagOperation;
import org.eclipse.team.internal.ccvs.ui.operations.TagOperation;
-import org.eclipse.team.internal.ui.dialogs.*;
-import org.eclipse.team.internal.ui.dialogs.MappingSelectionDialog;
import org.eclipse.team.internal.ui.dialogs.ResourceMappingResourceDisplayArea;
-public class TagLocalAction extends TagAction {
- private 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 class TagLocalAction extends TagAction {
- private final class UncommittedChangesDialog extends MappingSelectionDialog {
-
- private final Subscriber subscriber = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber();
- private final FastSyncInfoFilter resourceFilter = getResourceFilter();
-
- private UncommittedChangesDialog(Shell parentShell, String dialogTitle, ResourceMapping[] mappings) {
- super(parentShell, dialogTitle, mappings, new UncommittedFilter());
- }
-
- protected String getSingleMappingMessage(ResourceMapping mapping) {
- String label = ResourceMappingResourceDisplayArea.getLabel(mapping);
- return Policy.bind("TagLocalAction.0", label); //$NON-NLS-1$
- }
-
- protected String getMultipleMappingsMessage() {
- return Policy.bind("TagLocalAction.1"); //$NON-NLS-1$
- }
-
- protected String getResourceListMessage(ResourceMapping mapping) {
- if (mapping == null) {
- return Policy.bind("TagLocalAction.2"); //$NON-NLS-1$
- } else {
- String label = ResourceMappingResourceDisplayArea.getLabel(mapping);
- return Policy.bind("TagLocalAction.3", label); //$NON-NLS-1$
- }
- }
-
- /**
- * 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 = getMatchingMappings();
- if (matchingMappings.length > 0) {
- int code = open();
- if (code == OK) {
- Set result = new HashSet();
- result.addAll(Arrays.asList(mappings));
- 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 mappings;
- }
- }
-
- private ResourceMapping[] getMatchingMappings() {
- Set result = new HashSet();
- for (int i = 0; i < mappings.length; i++) {
- ResourceMapping mapping = mappings[i];
- if (matchesFilter(mapping)) {
- result.add(mapping);
- }
- }
- return (ResourceMapping[]) result.toArray(new ResourceMapping[result.size()]);
- }
-
- private boolean matchesFilter(ResourceMapping mapping) {
- try {
- mapping.visit(new SubscriberResourceMappingContext(subscriber), 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;
- }
- }, null);
- } catch (CoreException e) {
- if (e.getStatus().isOK()) {
- return true;
- }
- CVSUIPlugin.log(e);
- }
- return false;
- }
- }
-
ResourceMapping[] mappings;
protected boolean performPrompting() {
// Prompt for any uncommitted changes
mappings = getCVSResourceMappings();
- UncommittedChangesDialog dialog = new UncommittedChangesDialog(getShell(), Policy.bind("TagLocalAction.4"), mappings); //$NON-NLS-1$
+ UncommittedChangesDialog dialog = new UncommittedChangesDialog(getShell(), Policy.bind("TagLocalAction.4"), mappings) { //$NON-NLS-1$
+ protected String getSingleMappingMessage(ResourceMapping mapping) {
+ String label = ResourceMappingResourceDisplayArea.getLabel(mapping);
+ return Policy.bind("TagLocalAction.0", label); //$NON-NLS-1$
+ }
+
+ protected String getMultipleMappingsMessage() {
+ return Policy.bind("TagLocalAction.1"); //$NON-NLS-1$
+ }
+ };
mappings = dialog.promptToSelectMappings();
if(mappings.length == 0) {
// nothing to do
@@ -142,11 +44,6 @@ public class TagLocalAction extends TagAction {
return true;
}
- private FastSyncInfoFilter getResourceFilter() {
- // Return a filter that selects outgoing changes
- return new SyncInfoDirectionFilter(new int[] { SyncInfo.OUTGOING, SyncInfo.CONFLICTING });
- }
-
protected ITagOperation createTagOperation() {
if (mappings == null)
mappings = getCVSResourceMappings();
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
new file mode 100644
index 000000000..9de5fb43e
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UncommittedChangesDialog.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.subscribers.Subscriber;
+import org.eclipse.team.core.subscribers.SubscriberResourceMappingContext;
+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.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+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 });
+ }
+
+ final Subscriber subscriber = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber();
+ final FastSyncInfoFilter resourceFilter = getResourceFilter();
+
+ public UncommittedChangesDialog(Shell parentShell, String dialogTitle, ResourceMapping[] mappings) {
+ super(parentShell, dialogTitle, mappings, new UncommittedFilter());
+ }
+
+ protected String getResourceListMessage(ResourceMapping mapping) {
+ if (mapping == null) {
+ return Policy.bind("UncommittedChangesDialog.2"); //$NON-NLS-1$
+ } else {
+ String label = ResourceMappingResourceDisplayArea.getLabel(mapping);
+ return Policy.bind("UncommittedChangesDialog.3", label); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * 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 = getMatchingMappings();
+ if (matchingMappings.length > 0) {
+ int code = open();
+ if (code == OK) {
+ Set result = new HashSet();
+ result.addAll(Arrays.asList(getMappings()));
+ 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 getMappings();
+ }
+ }
+
+ ResourceMapping[] getMatchingMappings() {
+ Set result = new HashSet();
+ ResourceMapping[] mappings = getMappings();
+ for (int i = 0; i < mappings.length; i++) {
+ ResourceMapping mapping = mappings[i];
+ if (matchesFilter(mapping)) {
+ result.add(mapping);
+ }
+ }
+ return (ResourceMapping[]) result.toArray(new ResourceMapping[result.size()]);
+ }
+
+ boolean matchesFilter(ResourceMapping mapping) {
+ try {
+ mapping.visit(new SubscriberResourceMappingContext(subscriber), 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;
+ }
+ }, null);
+ } catch (CoreException e) {
+ if (e.getStatus().isOK()) {
+ return true;
+ }
+ CVSUIPlugin.log(e);
+ }
+ return false;
+ }
+} \ No newline at end of file
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 ad384958d..f1aec1bb2 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
@@ -10,12 +10,14 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.actions;
-import java.lang.reflect.InvocationTargetException;
import java.util.*;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.*;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
@@ -61,17 +63,17 @@ public abstract class WorkspaceTraversalAction extends WorkspaceAction {
return getSelectedResourceMappings(CVSProviderPlugin.getTypeId());
}
- /**
- * Return the selected traversals that are on CVS resources.
- * @return the selected traversals that are on CVS resources
- * @throws InvocationTargetException
- */
- private /* temporarily */ ResourceTraversal[] getSelectedTraversals() throws InvocationTargetException {
- try {
- return getSelectedTraversals(CVSProviderPlugin.getTypeId());
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
+ protected static IResource[] getRootTraversalResources(ResourceMapping[] mappings, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
+ List result = new ArrayList();
+ for (int i = 0; i < mappings.length; i++) {
+ ResourceMapping mapping = mappings[i];
+ ResourceTraversal[] traversals = mapping.getTraversals(context, monitor);
+ for (int j = 0; j < traversals.length; j++) {
+ ResourceTraversal traversal = traversals[j];
+ result.addAll(Arrays.asList(traversal.getResources()));
+ }
}
+ return (IResource[]) result.toArray(new IResource[result.size()]);
}
}
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 325b8b416..677456d51 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
@@ -722,8 +722,6 @@ TagAction.moveTag=&Move tag if it already exists
TagRootElement.0=Dates
TagLocalAction.0=There are uncommitted changes contained in ''{0}'' that will not be tagged. Should ''{0}'' be included in the operation?
TagLocalAction.1=The following contain &uncommitted changes that will not be versioned. Check those that should be included in the tag operation.
-TagLocalAction.2=Select an item to see the resources it contains.
-TagLocalAction.3=Preview the resources contained in ''{0}''
TagLocalAction.4=Tag with Uncommitted Changes
TagAction.moveTagConfirmTitle=Confirm Move Existing Tag
TagAction.moveTagConfirmMessage=If the tag {0} is already used in this project, it will be moved to the selected revisions. Are you sure you want to perform the tag operation?
@@ -1398,3 +1396,9 @@ ModeWizardSelectionPage.3=ASCII/Binary Property
ModeWizardSelectionPage.4=Path
ModeWizardSelectionPage.8=&Reset
ModeWizardSelectionPage.9=Reset the selected files to their current mode
+
+ReplaceWithTagAction.0=There are uncommitted changes contained in ''{0}'' that will be overwritten. Should ''{0}'' be included in the operation?
+ReplaceWithTagAction.1=The following contain &uncommitted changes that will be overwritten. Check those that should be included in the replace operation.
+ReplaceWithTagAction.4=Replace with Uncommitted Changes
+UncommittedChangesDialog.2=Select an item to see the dirty resources it contains.
+UncommittedChangesDialog.3=Preview the dirty resources contained in ''{0}''
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java
index aed689ba3..ada60fe14 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java
@@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.team.internal.ccvs.core.*;
@@ -33,7 +34,11 @@ public class ReplaceOperation extends UpdateOperation {
super(part, resources, new LocalOption[] { Update.IGNORE_LOCAL_CHANGES }, tag);
}
- /* (non-Javadoc)
+ public ReplaceOperation(IWorkbenchPart part, ResourceMapping[] mappings, CVSTag tag, boolean b) {
+ super(part, mappings, new LocalOption[] { Update.IGNORE_LOCAL_CHANGES }, tag);
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
*/
protected String getTaskName() {
diff --git a/bundles/org.eclipse.team.ui/plugin.xml b/bundles/org.eclipse.team.ui/plugin.xml
index 985ac6f31..c2cf431aa 100644
--- a/bundles/org.eclipse.team.ui/plugin.xml
+++ b/bundles/org.eclipse.team.ui/plugin.xml
@@ -59,7 +59,7 @@
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
- objectClass="org.eclipse.core.resources.IResource"
+ objectClass="org.eclipse.core.resources.mapping.ResourceMapping"
adaptable="true"
id="org.eclipse.team.ui.ResourceContributions">
<menu
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/MappingSelectionDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/MappingSelectionDialog.java
index 8eb5f33a0..02c0a2f30 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/MappingSelectionDialog.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/MappingSelectionDialog.java
@@ -171,4 +171,9 @@ public abstract class MappingSelectionDialog extends DetailsDialog implements IP
* @return the list label
*/
protected abstract String getResourceListMessage(ResourceMapping mapping);
+
+ public ResourceMapping[] getMappings() {
+ return mappings;
+ }
+
}

Back to the top