1 11 package org.eclipse.core.internal.filebuffers; 12 13 import org.eclipse.core.filesystem.IFileInfo; 14 import org.eclipse.core.filesystem.IFileStore; 15 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.core.runtime.IPath; 18 import org.eclipse.core.runtime.IProgressMonitor; 19 20 import org.eclipse.core.filebuffers.FileBuffers; 21 import org.eclipse.core.filebuffers.IFileBuffer; 22 import org.eclipse.core.filebuffers.IStateValidationSupport; 23 import org.eclipse.core.filebuffers.ITextFileBufferManager; 24 25 import org.eclipse.jface.text.IDocumentExtension4; 26 27 30 public abstract class AbstractFileBuffer implements IFileBuffer, IStateValidationSupport { 31 32 36 protected IFileStore fFileStore; 37 38 39 public abstract void create(IPath location, IProgressMonitor monitor) throws CoreException; 40 41 public abstract void connect(); 42 43 public abstract void disconnect() throws CoreException; 44 45 51 protected abstract boolean isDisconnected(); 52 53 62 protected void dispose() { 63 } 64 65 68 public void validationStateAboutToBeChanged() { 69 ITextFileBufferManager fileBufferManager= FileBuffers.getTextFileBufferManager(); 70 if (fileBufferManager instanceof TextFileBufferManager) { 71 TextFileBufferManager manager= (TextFileBufferManager) fileBufferManager; 72 manager.fireStateChanging(this); 73 } 74 } 75 76 79 public void validationStateChangeFailed() { 80 ITextFileBufferManager fileBufferManager= FileBuffers.getTextFileBufferManager(); 81 if (fileBufferManager instanceof TextFileBufferManager) { 82 TextFileBufferManager manager= (TextFileBufferManager) fileBufferManager; 83 manager.fireStateChangeFailed(this); 84 } 85 } 86 87 90 public long getModificationStamp() { 91 IFileInfo info= fFileStore.fetchInfo(); 92 return info.exists() ? info.getLastModified() : IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP; 93 } 94 95 99 public IFileStore getFileStore() { 100 return fFileStore; 101 } 102 103 } 104 | Popular Tags |