1 11 package org.eclipse.pde.internal.ui.refactoring; 12 13 import org.eclipse.core.filebuffers.FileBuffers; 14 import org.eclipse.core.filebuffers.ITextFileBuffer; 15 import org.eclipse.core.filebuffers.ITextFileBufferManager; 16 import org.eclipse.core.resources.IFile; 17 import org.eclipse.core.runtime.CoreException; 18 import org.eclipse.core.runtime.IPath; 19 import org.eclipse.core.runtime.IProgressMonitor; 20 import org.eclipse.core.runtime.NullProgressMonitor; 21 import org.eclipse.jface.text.IDocument; 22 import org.eclipse.ltk.core.refactoring.TextFileChange; 23 24 28 29 public class MovedTextFileChange extends TextFileChange { 30 31 private IFile fCurrentFile; 32 33 public MovedTextFileChange(String name, IFile newFile, IFile currentFile) { 34 super(name, newFile); 35 fCurrentFile = currentFile; 36 } 37 38 45 public IDocument getCurrentDocument(IProgressMonitor pm) 46 throws CoreException { 47 if (pm == null) 48 pm= new NullProgressMonitor(); 49 IDocument result= null; 50 pm.beginTask("", 2); ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager(); 52 try{ 53 IPath path= fCurrentFile.getFullPath(); 54 manager.connect(path, pm); 55 ITextFileBuffer buffer = manager.getTextFileBuffer(path); 56 result= buffer.getDocument(); 57 } finally { 58 if (result != null) 59 manager.disconnect(fCurrentFile.getFullPath(), pm); 60 } 61 pm.done(); 62 return result; 63 } 64 65 } 66 | Popular Tags |