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 ResourceVariantTree extends AbstractResourceVariantTree { 29 30 private ResourceVariantByteStore store; 31 32 37 protected ResourceVariantTree(ResourceVariantByteStore store) { 38 this.store = store; 39 } 40 41 44 public IResource[] members(IResource resource) throws TeamException { 45 return getByteStore().members(resource); 46 } 47 48 51 public boolean hasResourceVariant(IResource resource) throws TeamException { 52 return getByteStore().getBytes(resource) != null; 53 } 54 55 58 public void flushVariants(IResource resource, int depth) throws TeamException { 59 getByteStore().flushBytes(resource, depth); 60 } 61 62 65 protected boolean setVariant(IResource local, IResourceVariant remote) throws TeamException { 66 ResourceVariantByteStore cache = getByteStore(); 67 byte[] newRemoteBytes = getBytes(local, remote); 68 boolean changed; 69 if (newRemoteBytes == null) { 70 changed = cache.deleteBytes(local); 71 } else { 72 changed = cache.setBytes(local, newRemoteBytes); 73 } 74 return changed; 75 } 76 77 86 protected ResourceVariantByteStore getByteStore() { 87 return store; 88 } 89 90 98 protected byte[] getBytes(IResource local, IResourceVariant remote) throws TeamException { 99 if (remote == null) return null; 100 return remote.asBytes(); 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 getByteStore().run(local, new IWorkspaceRunnable() { 111 public void run(IProgressMonitor monitor) throws CoreException { 112 resources[0] = ResourceVariantTree.super.collectChanges(local, remote, depth, monitor); 113 } 114 }, monitor); 115 return resources[0]; 116 } 117 } 118 | Popular Tags |