1 11 package org.eclipse.team.internal.ccvs.ui; 12 13 import java.io.IOException ; 14 import java.io.InputStream ; 15 16 import org.eclipse.core.resources.IEncodedStorage; 17 import org.eclipse.core.resources.IResourceStatus; 18 import org.eclipse.core.runtime.*; 19 import org.eclipse.osgi.util.NLS; 20 import org.eclipse.team.core.TeamException; 21 import org.eclipse.team.internal.ccvs.core.*; 22 import org.eclipse.team.internal.core.TeamPlugin; 23 24 public class RemoteAnnotationStorage extends PlatformObject implements IEncodedStorage { 25 26 private InputStream contents; 27 private ICVSRemoteFile file; 28 29 public RemoteAnnotationStorage(ICVSRemoteFile file, InputStream contents) { 30 this.file = file; 31 this.contents = contents; 32 } 33 34 public InputStream getContents() throws CoreException { 35 try { 36 contents.reset(); 38 } catch (IOException e) { 39 CVSUIPlugin.log(CVSException.wrapException(e)); 40 } 41 return contents; 42 } 43 44 public String getCharset() throws CoreException { 45 InputStream contents = getContents(); 46 try { 47 String charSet = TeamPlugin.getCharset(getName(), contents); 48 return charSet; 49 } catch (IOException e) { 50 throw new CVSException(new Status(IStatus.ERROR, CVSUIPlugin.ID, IResourceStatus.FAILED_DESCRIBING_CONTENTS, NLS.bind(CVSUIMessages.RemoteAnnotationStorage_1, (new String [] { getFullPath().toString() })), e)); 51 } finally { 52 try { 53 contents.close(); 54 } catch (IOException e1) { 55 } 57 } 58 } 59 60 public IPath getFullPath() { 61 ICVSRepositoryLocation location = file.getRepository(); 62 IPath path = new Path(null, location.getRootDirectory()); 63 path = path.setDevice(location.getHost() + IPath.DEVICE_SEPARATOR); 64 String revision = ""; try { 67 revision = ' ' + file.getRevision(); 68 } catch (TeamException e) { 69 } 71 path = path.append(file.getRepositoryRelativePath() + revision); 72 return path; 73 } 74 public String getName() { 75 return file.getName(); 76 } 77 public boolean isReadOnly() { 78 return true; 79 } 80 } 81 | Popular Tags |