1 11 package org.eclipse.team.core.variants; 12 13 import org.eclipse.core.resources.IResource; 14 import org.eclipse.core.resources.IWorkspaceRunnable; 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.core.runtime.IProgressMonitor; 17 import org.eclipse.team.core.TeamException; 18 19 28 public abstract class ThreeWayRemoteTree extends ResourceVariantTree { 29 30 private ThreeWaySubscriber subscriber; 31 32 37 static class RemoteResourceVariantByteStore extends ResourceVariantByteStore { 38 private ThreeWaySynchronizer synchronizer; 39 public RemoteResourceVariantByteStore(ThreeWaySynchronizer synchronizer) { 40 this.synchronizer = synchronizer; 41 } 42 public void dispose() { 43 } 45 public byte[] getBytes(IResource resource) throws TeamException { 46 return getSynchronizer().getRemoteBytes(resource); 47 } 48 public boolean setBytes(IResource resource, byte[] bytes) throws TeamException { 49 return getSynchronizer().setRemoteBytes(resource, bytes); 50 } 51 public boolean flushBytes(IResource resource, int depth) throws TeamException { 52 return false; 55 } 56 public boolean isVariantKnown(IResource resource) throws TeamException { 57 return getSynchronizer().hasSyncBytes(resource); 58 } 59 public boolean deleteBytes(IResource resource) throws TeamException { 60 return getSynchronizer().removeRemoteBytes(resource); 61 } 62 public IResource[] members(IResource resource) throws TeamException { 63 return synchronizer.members(resource); 64 } 65 private ThreeWaySynchronizer getSynchronizer() { 66 return synchronizer; 67 } 68 } 69 70 76 public ThreeWayRemoteTree(ThreeWaySubscriber subscriber) { 77 super(new RemoteResourceVariantByteStore(subscriber.getSynchronizer())); 78 this.subscriber = subscriber; 79 } 80 81 84 public IResource[] roots() { 85 return getSubscriber().roots(); 86 } 87 88 91 public IResourceVariant getResourceVariant(IResource resource) throws TeamException { 92 return getSubscriber().getResourceVariant(resource, getByteStore().getBytes(resource)); 93 } 94 95 99 protected ThreeWaySubscriber getSubscriber() { 100 return subscriber; 101 } 102 103 106 protected IResource[] collectChanges(final IResource local, 107 final IResourceVariant remote, final int depth, IProgressMonitor monitor) 108 throws TeamException { 109 final IResource[][] resources = new IResource[][] { null }; 110 getSubscriber().getSynchronizer().run(local, new IWorkspaceRunnable() { 111 public void run(IProgressMonitor monitor) throws CoreException { 112 resources[0] = ThreeWayRemoteTree.super.collectChanges(local, remote, depth, monitor); 113 } 114 }, monitor); 115 return resources[0]; 116 } 117 } 118 | Popular Tags |