Bug 161665 [Sync View] Remove from View not honoured when commit performed using "Commit All" toolbar button
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java
new file mode 100644
index 0000000..8af6f1f
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2006 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.mappings;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.diff.IDiff;
+import org.eclipse.team.core.diff.IThreeWayDiff;
+import org.eclipse.team.core.mapping.IResourceDiffTree;
+import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.ui.wizards.CommitWizard;
+import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
+import org.eclipse.ui.PlatformUI;
+
+public abstract class AbstractCommitAction extends CVSModelProviderAction {
+
+ public AbstractCommitAction(ISynchronizePageConfiguration configuration) {
+ super(configuration);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void execute() {
+ final List resources = new ArrayList();
+ try {
+ PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ ResourceTraversal[] traversals = getResourceTraversals(monitor);
+ resources.add(getOutgoingChanges(getSynchronizationContext().getDiffTree(), traversals, monitor));
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ });
+ } catch (InvocationTargetException e) {
+ Utils.handleError(getConfiguration().getSite().getShell(), e, null, null);
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ if (!resources.isEmpty() && ((IResource[])resources.get(0)).length > 0) {
+ Shell shell= getConfiguration().getSite().getShell();
+ try {
+ CommitWizard.run(getConfiguration().getSite().getPart(), shell, ((IResource[])resources.get(0)));
+ } catch (CVSException e) {
+ CVSUIPlugin.log(e);
+ }
+ }
+ }
+
+ protected abstract ResourceTraversal[] getResourceTraversals(IProgressMonitor monitor) throws CoreException;
+
+ protected IResource[] getOutgoingChanges(final IResourceDiffTree tree, ResourceTraversal[] traversals, IProgressMonitor monitor) {
+ final List resources = new ArrayList();
+ IDiff[] diffs = tree.getDiffs(traversals);
+ for (int i = 0; i < diffs.length; i++) {
+ IDiff diff = diffs[i];
+ if (hasLocalChange(diff)) {
+ IResource resource = ResourceDiffTree.getResourceFor(diff);
+ if (resource != null)
+ resources.add(resource);
+ }
+ }
+ return (IResource[]) resources.toArray(new IResource[resources.size()]);
+ }
+
+ private boolean hasLocalChange(IDiff diff) {
+ if (diff instanceof IThreeWayDiff) {
+ IThreeWayDiff twd = (IThreeWayDiff) diff;
+ return twd.getDirection() == IThreeWayDiff.OUTGOING
+ || twd.getDirection() == IThreeWayDiff.CONFLICTING;
+ }
+ return false;
+ }
+
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CommitAction.java
index bfb8d0a..fb3d28a 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CommitAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CommitAction.java
@@ -10,31 +10,16 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.mappings;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.diff.IDiff;
-import org.eclipse.team.core.diff.IThreeWayDiff;
-import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
-import org.eclipse.team.internal.ccvs.ui.wizards.CommitWizard;
-import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
-import org.eclipse.ui.PlatformUI;
-public class CommitAction extends CVSModelProviderAction implements IPropertyChangeListener {
+public class CommitAction extends AbstractCommitAction implements IPropertyChangeListener {
public CommitAction(final ISynchronizePageConfiguration configuration) {
super(configuration);
@@ -71,53 +56,10 @@
setEnabled(internalIsEnabled(getStructuredSelection()));
}
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.Action#run()
- */
- public void execute() {
- final List resources = new ArrayList();
- try {
- PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- ResourceTraversal[] traversals = getResourceTraversals(getStructuredSelection(), monitor);
- IDiff[] diffs = getSynchronizationContext().getDiffTree().getDiffs(traversals);
- for (int i = 0; i < diffs.length; i++) {
- IDiff diff = diffs[i];
- if (hasLocalChange(diff)) {
- IResource resource = ResourceDiffTree.getResourceFor(diff);
- if (resource != null)
- resources.add(resource);
- }
- }
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- }
- }
- private boolean hasLocalChange(IDiff diff) {
- if (diff instanceof IThreeWayDiff) {
- IThreeWayDiff twd = (IThreeWayDiff) diff;
- return twd.getDirection() == IThreeWayDiff.OUTGOING
- || twd.getDirection() == IThreeWayDiff.CONFLICTING;
- }
- return false;
- }
- });
- } catch (InvocationTargetException e) {
- Utils.handleError(getConfiguration().getSite().getShell(), e, null, null);
- } catch (InterruptedException e) {
- // Ignore
- }
- if (!resources.isEmpty()) {
- Shell shell= getConfiguration().getSite().getShell();
- try {
- CommitWizard.run(getConfiguration().getSite().getPart(), shell, (IResource[]) resources.toArray(new IResource[resources.size()]));
- } catch (CVSException e) {
- CVSUIPlugin.log(e);
- }
- }
+ protected ResourceTraversal[] getResourceTraversals(IProgressMonitor monitor)
+ throws CoreException {
+ return getResourceTraversals(getStructuredSelection(), monitor);
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceCommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceCommitAction.java
index 251e924..59e69e1 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceCommitAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceCommitAction.java
@@ -12,24 +12,19 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceTraversal;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.*;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.ICache;
import org.eclipse.team.core.ICacheListener;
import org.eclipse.team.core.diff.*;
import org.eclipse.team.core.mapping.ISynchronizationContext;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.wizards.CommitWizard;
import org.eclipse.team.ui.mapping.ITeamContentProviderManager;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
/**
* A commit action that will commit all outgoing changes in the context.
*/
-public class WorkspaceCommitAction extends CVSModelProviderAction implements IDiffChangeListener {
+public class WorkspaceCommitAction extends AbstractCommitAction implements IDiffChangeListener {
/**
* Create the action
@@ -86,21 +81,13 @@
setEnabled(enabled);
}
- public void execute() {
- ISynchronizationContext context = (ISynchronizationContext)getConfiguration().getProperty(ITeamContentProviderManager.P_SYNCHRONIZATION_CONTEXT);
- ResourceTraversal[] traversals = context.getScope().getTraversals();
- Shell shell= getConfiguration().getSite().getShell();
- try {
- // Include the subscriber operation as a job listener so that the busy feedback for the
- // commit will appear in the synchronize view
- CommitWizard.run(getConfiguration().getSite().getPart(), shell, traversals);
- } catch (CVSException e) {
- CVSUIPlugin.log(e);
- }
- }
-
protected IResource[] getTargetResources() {
return getSynchronizationContext().getScope().getRoots();
}
+ protected ResourceTraversal[] getResourceTraversals(IProgressMonitor monitor)
+ throws CoreException {
+ return getSynchronizationContext().getScope().getTraversals();
+ }
+
}