1 11 package org.eclipse.team.internal.ccvs.core.resources; 12 13 14 import org.eclipse.core.resources.IResource; 15 import org.eclipse.core.runtime.*; 16 import org.eclipse.team.core.TeamException; 17 import org.eclipse.team.core.variants.CachedResourceVariant; 18 import org.eclipse.team.internal.ccvs.core.*; 19 import org.eclipse.team.internal.ccvs.core.client.Update; 20 import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; 21 import org.eclipse.team.internal.ccvs.core.util.Util; 22 23 29 public abstract class RemoteResource extends CachedResourceVariant implements ICVSRemoteResource { 30 31 protected RemoteFolder parent; 32 protected String name; 33 34 private int workspaceSyncState = Update.STATE_NONE; 37 38 41 public RemoteResource(RemoteFolder parent, String name) { 42 this.parent = parent; 43 this.name = name; 44 } 45 46 49 public String getName() { 50 return name; 51 } 52 53 56 public String getRelativePath(ICVSFolder ancestor) throws CVSException { 57 return Util.appendPath(parent.getRelativePath(ancestor), getName()); 58 } 59 60 63 public ICVSRemoteResource getRemoteParent() { 64 return parent; 65 } 66 67 public abstract String getRepositoryRelativePath(); 68 69 public abstract ICVSRepositoryLocation getRepository(); 70 71 public int getWorkspaceSyncState() { 72 return workspaceSyncState; 73 } 74 75 public void setWorkspaceSyncState(int workspaceSyncState) { 76 this.workspaceSyncState = workspaceSyncState; 77 } 78 79 82 public void delete() { 83 } 85 86 94 public boolean exists() { 95 return true; 96 } 97 98 101 public boolean exists(IProgressMonitor monitor) throws TeamException { 102 return parent.exists(this, monitor); 103 } 104 105 108 public ICVSFolder getParent() { 109 return parent; 110 } 111 112 115 public boolean isIgnored() { 116 return false; 117 } 118 119 122 public boolean isManaged() { 123 return parent != null; 124 } 125 126 public boolean isModified(IProgressMonitor monitor) throws CVSException { 127 return true; 130 } 131 132 135 public void unmanage(IProgressMonitor monitor) throws CVSException { 136 } 138 139 142 public abstract ResourceSyncInfo getSyncInfo(); 143 144 public boolean equals(Object target) { 145 if (this == target) 146 return true; 147 if (!(target instanceof RemoteResource)) 148 return false; 149 RemoteResource remote = (RemoteResource) target; 150 return remote.isContainer() == isContainer() 151 && remote.getRepository().equals(getRepository()) 152 && remote.getRepositoryRelativePath().equals(getRepositoryRelativePath()); 153 } 154 155 158 public void setIgnoredAs(String pattern) throws CVSException { 159 Assert.isTrue(false); 161 } 162 163 166 public IResource getIResource() { 167 return null; 168 } 169 170 178 public abstract ICVSRemoteResource forTag(ICVSRemoteFolder parent, CVSTag tagName); 179 180 183 public int hashCode() { 184 return getRepositoryRelativePath().hashCode(); 185 } 186 187 198 abstract public byte[] getSyncBytes(); 199 200 public String toString() { 201 return "Remote " + (isContainer() ? "Folder: " : "File: ") + getName(); } 203 204 207 public String getCachePath() { 208 ICVSRepositoryLocation location = getRepository(); 209 IPath path = new Path(null, location.getHost()); 210 path = path.append(location.getRootDirectory()); 211 path = path.append(parent.getRepositoryRelativePath()); 212 path = path.append(getName() + ' ' + getContentIdentifier()); 213 return path.toString(); 214 } 215 216 219 protected String getCacheId() { 220 return CVSProviderPlugin.ID; 221 } 222 223 226 public byte[] asBytes() { 227 return getSyncBytes(); 228 } 229 } 230 | Popular Tags |