diff options
author | Michael Valenta | 2004-05-13 01:28:21 +0000 |
---|---|---|
committer | Michael Valenta | 2004-05-13 01:28:21 +0000 |
commit | 06fa910c6d139bd9a23073029fee06b7e38f15e0 (patch) | |
tree | 2df4ace23c9517556c1c418b6fc8147be429a872 | |
parent | a04d00fcd18c953cd99c40ede47de50d5d6a3c52 (diff) | |
download | eclipse.platform.team-branch_20040512_CVSVariantTreeExperiments.tar.gz eclipse.platform.team-branch_20040512_CVSVariantTreeExperiments.tar.xz eclipse.platform.team-branch_20040512_CVSVariantTreeExperiments.zip |
*** empty log message ***branch_20040512_CVSVariantTreeExperiments
6 files changed, 93 insertions, 2 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java index 318a41af7..ff4af896a 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java @@ -15,6 +15,7 @@ import java.util.List; import org.eclipse.core.resources.*; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.core.Assert; @@ -157,4 +158,16 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore throw TeamException.asTeamException(e); } } + + /* (non-Javadoc) + * @see org.eclipse.team.core.variants.ResourceVariantByteStore#run(org.eclipse.core.resources.IWorkspaceRunnable, org.eclipse.core.runtime.IProgressMonitor) + */ + public void run(IResource root, IWorkspaceRunnable runnable, IProgressMonitor monitor) + throws TeamException { + try { + ResourcesPlugin.getWorkspace().run(runnable, root, 0, monitor); + } catch (CoreException e) { + throw TeamException.asTeamException(e); + } + } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantByteStore.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantByteStore.java index 495fceefc..7caf8f09e 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantByteStore.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantByteStore.java @@ -11,6 +11,10 @@ package org.eclipse.team.core.variants; import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.team.core.TeamException; /** @@ -110,4 +114,23 @@ public abstract class ResourceVariantByteStore { } return true; } + + /** + * Run the given action which may contain multiple modfications + * to the byte store. By default, the action is run. Subclasses + * may override to obtain scheduling rules or batch deltas (if + * the byte store modifies workspace resources). + * @param root the root resource for all modifications + * @param action the action to perform + * @param monitor a progress monitor. + * @exception CoreException if the operation failed. + * @exception OperationCanceledException if the operation is canceled. + */ + public void run(IResource root, IWorkspaceRunnable runnable, IProgressMonitor monitor) throws TeamException { + try { + runnable.run(monitor); + } catch (CoreException e) { + throw TeamException.asTeamException(e); + } + } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java index 619de1ab1..8a496e514 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java @@ -11,6 +11,9 @@ package org.eclipse.team.core.variants; import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.team.core.TeamException; /** @@ -93,4 +96,19 @@ public abstract class ResourceVariantTree extends AbstractResourceVariantTree { if (remote == null) return null; return remote.asBytes(); } + + /* (non-Javadoc) + * @see org.eclipse.team.core.variants.AbstractResourceVariantTree#collectChanges(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant, int, org.eclipse.core.runtime.IProgressMonitor) + */ + protected IResource[] collectChanges(final IResource local, + final IResourceVariant remote, final int depth, IProgressMonitor monitor) + throws TeamException { + final IResource[][] resources = new IResource[][] { null }; + getByteStore().run(local, new IWorkspaceRunnable() { + public void run(IProgressMonitor monitor) throws CoreException { + resources[0] = ResourceVariantTree.super.collectChanges(local, remote, depth, monitor); + } + }, monitor); + return resources[0]; + } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java index 35d75081b..fafe387a2 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java @@ -11,6 +11,9 @@ package org.eclipse.team.core.variants; import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.team.core.TeamException; /** @@ -64,6 +67,12 @@ public abstract class ThreeWayRemoteTree extends ResourceVariantTree { } } + /** + * Create a remote resource variant tree that stores and obtains + * it's bytes from the remote slot of the synchronizer of the + * given subscriber + * @param subscriber a three-way subscriber + */ public ThreeWayRemoteTree(ThreeWaySubscriber subscriber) { super(new RemoteResourceVariantByteStore(subscriber.getSynchronizer())); this.subscriber = subscriber; @@ -83,7 +92,26 @@ public abstract class ThreeWayRemoteTree extends ResourceVariantTree { return getSubscriber().getResourceVariant(resource, getByteStore().getBytes(resource)); } + /** + * Return the subscriber associated with this resource variant tree. + * @return the subscriber associated with this resource variant tree + */ protected ThreeWaySubscriber getSubscriber() { return subscriber; } + + /* (non-Javadoc) + * @see org.eclipse.team.core.variants.AbstractResourceVariantTree#collectChanges(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant, int, org.eclipse.core.runtime.IProgressMonitor) + */ + protected IResource[] collectChanges(final IResource local, + final IResourceVariant remote, final int depth, IProgressMonitor monitor) + throws TeamException { + final IResource[][] resources = new IResource[][] { null }; + getSubscriber().getSynchronizer().run(local, new IWorkspaceRunnable() { + public void run(IProgressMonitor monitor) throws CoreException { + resources[0] = ThreeWayRemoteTree.super.collectChanges(local, remote, depth, monitor); + } + }, monitor); + return resources[0]; + } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java index 55b5c0691..62ecdb943 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java @@ -376,12 +376,12 @@ public class ThreeWaySynchronizer implements IFlushOperation { * @param monitor a progress monitor * @throws TeamException */ - public void run(ISchedulingRule resourceRule, IWorkspaceRunnable runnable, IProgressMonitor monitor) throws TeamException { + public void run(IResource resourceRule, IWorkspaceRunnable runnable, IProgressMonitor monitor) throws TeamException { monitor = Policy.monitorFor(monitor); monitor.beginTask(null, 100); ISchedulingRule rule = beginBatching(resourceRule, Policy.subMonitorFor(monitor, 10)); try { - runnable.run(Policy.subMonitorFor(monitor, 80)); + cache.run(resourceRule, runnable, Policy.subMonitorFor(monitor, 80)); } catch (CoreException e) { throw TeamException.asTeamException(e); } finally { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DescendantResourceVariantByteStore.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DescendantResourceVariantByteStore.java index 77cb91d1f..bfeeb4286 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DescendantResourceVariantByteStore.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DescendantResourceVariantByteStore.java @@ -14,6 +14,8 @@ import java.util.HashSet; import java.util.Set; import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.variants.*; @@ -171,4 +173,11 @@ public abstract class DescendantResourceVariantByteStore extends ResourceVariant } return (IResource[]) members.toArray(new IResource[members.size()]); } + + /* (non-Javadoc) + * @see org.eclipse.team.core.variants.ResourceVariantByteStore#run(org.eclipse.core.resources.IResource, org.eclipse.core.resources.IWorkspaceRunnable, org.eclipse.core.runtime.IProgressMonitor) + */ + public void run(IResource root, IWorkspaceRunnable runnable, IProgressMonitor monitor) throws TeamException { + remoteStore.run(root, runnable, monitor); + } } |