Examples of ITextFileBufferManager


Examples of org.eclipse.core.filebuffers.ITextFileBufferManager

        PerlEditor editor = openEditor("EPICTest/test_FindReplace.pl");

        IPath fileLocation =
            ((IFileEditorInput) editor.getEditorInput()).getFile().getLocation();
       
        ITextFileBufferManager bm = FileBuffers.getTextFileBufferManager();
        bm.connect(fileLocation, new NullProgressMonitor());
       
        try
        {
            IDocument doc = editor.getViewer().getDocument();
            doc.replace(0, 0, "abc");
           
            String bufText = bm.getTextFileBuffer(fileLocation).getDocument().get();          
            assertEquals(doc.get(), bufText);
        }
        finally
        {
            bm.disconnect(fileLocation, new NullProgressMonitor());
            closeEditor(editor);
        }
    }
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBufferManager

  @Override
  public Change createChange(IProgressMonitor pm) throws CoreException,
      OperationCanceledException {

    ITextFileBufferManager bufferManager = FileBuffers
        .getTextFileBufferManager();
    IPath path = fSourceModule.getPath();
    bufferManager.connect(path, LocationKind.IFILE, null);
    ITextFileBuffer textFileBuffer = bufferManager.getTextFileBuffer(path,
        LocationKind.IFILE);
   
    IDocument document = textFileBuffer.getDocument();
   
    DocumentChange anotherChange = new DocumentChange(RefactoringMessages.ExtractMethodPreviewPage_TextChangeName, document);
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBufferManager

  private static void releaseDocument(ICompilationUnit cu, IDocument document, IProgressMonitor monitor) throws CoreException {
    if (cu.getOwner() == null) {
      IFile file = (IFile) cu.getResource();
      if (file.exists()) {
        ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
        bufferManager.disconnect(file.getFullPath(), LocationKind.IFILE, monitor);
        return;
      }
    }
    cu.getBuffer().setContents(document.get());
    monitor.done();
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBufferManager

  private static IDocument aquireDocument(ICompilationUnit cu, IProgressMonitor monitor) throws CoreException {
    if (cu.getOwner() == null) {
      IFile file = (IFile) cu.getResource();
      if (file.exists()) {
        ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
        IPath path = cu.getPath();
        bufferManager.connect(path, LocationKind.IFILE, monitor);
        return bufferManager.getTextFileBuffer(path, LocationKind.IFILE).getDocument();
      }
    }
    monitor.done();
    return new Document(cu.getSource());
  }
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBufferManager

        IStatus status = makeCommittable(new IResource[] { file }, null);
        if (!status.isOK()) {
          throw new CoreException(status);
        }
        new RewriteSessionEditProcessor(document, edit, TextEdit.UPDATE_REGIONS).performEdits(); // apply
        ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
        bufferManager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE).commit(monitor, true);
        return;
      }
    }
    new RewriteSessionEditProcessor(document, edit, TextEdit.UPDATE_REGIONS).performEdits();
  }
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBufferManager

    return new IRegion[] { new Region(0, document.getLength()) };
  }

  private ITextFileBuffer textFileBuffer(IProgressMonitor monitor, IFileEditorInput editorInput) throws CoreException {
    IPath location = editorInput.getFile().getFullPath();
    ITextFileBufferManager textFileBufferManager = getTextFileBufferManager();
    textFileBufferManager.connect(location, NORMALIZE, monitor);
    try {
      return textFileBufferManager.getTextFileBuffer(location, IFILE);
    } finally {
      textFileBufferManager.disconnect(location, NORMALIZE, monitor);
    }
  }
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBufferManager

        }

        @Override public void run() throws Exception {
          monitor.beginTask(calculatingChangedRegions, 20);
          IFileStore fileStore = buffer.getFileStore();
          ITextFileBufferManager fileBufferManager = createTextFileBufferManager();
          fileBufferManager.connectFileStore(fileStore, getSubProgressMonitor(monitor, 15));
          try {
            IDocument old = ((ITextFileBuffer) fileBufferManager.getFileStoreFileBuffer(fileStore)).getDocument();
            result.set(getChangedLineRegions(old));
          } finally {
            fileBufferManager.disconnectFileStore(fileStore, getSubProgressMonitor(monitor, 5));
            monitor.done();
          }
        }

        /*
 
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBufferManager

    if (!(element instanceof IAdaptable))
      return null;
    IAdaptable adaptable= (IAdaptable) element;
   
    IFile file= null;
    ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
    ITextFileBuffer fileBuffer= null;
    LocationKind locationKind= null;
   
    file= (IFile)adaptable.getAdapter(IFile.class);
    if (file != null) {
      IPath location= file.getFullPath();
      locationKind= LocationKind.IFILE;
      manager.connect(location, locationKind,getProgressMonitor());
      fileBuffer= manager.getTextFileBuffer(location, locationKind);
    } else {
      ILocationProvider provider= (ILocationProvider) adaptable.getAdapter(ILocationProvider.class);
      if (provider instanceof ILocationProviderExtension) {
        URI uri= ((ILocationProviderExtension)provider).getURI(element);
        if (ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(uri).length == 0) {
          IFileStore fileStore= EFS.getStore(uri);
          manager.connectFileStore(fileStore, getProgressMonitor());
          fileBuffer= manager.getFileStoreTextFileBuffer(fileStore);
        }
      }
      if (fileBuffer == null && provider != null) {
        IPath location= provider.getPath(element);
        if (location == null)
          return null;
        locationKind= LocationKind.NORMALIZE;
        manager.connect(location, locationKind, getProgressMonitor());
        fileBuffer= manager.getTextFileBuffer(location, locationKind);
        file= FileBuffers.getWorkspaceFileAtLocation(location);
      }
    }

    if (fileBuffer != null) {
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBufferManager

   * @throws CoreException if the creation of the file fails
   */
  protected void createFileFromDocument(IProgressMonitor monitor, IFile file, IDocument document) throws CoreException {
    try {
      monitor.beginTask(TextEditorMessages.TextFileDocumentProvider_beginTask_saving, 2000);
      ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
      manager.connect(file.getFullPath(), LocationKind.IFILE, monitor);
      ITextFileBuffer buffer= ITextFileBufferManager.DEFAULT.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
      buffer.getDocument().set(document.get());
      buffer.commit(monitor, true);
      manager.disconnect(file.getFullPath(), LocationKind.IFILE, monitor);
    } finally {
      monitor.done();
    }
  }
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBufferManager

  /*
   * @see org.eclipse.ui.editors.text.FileBufferOperationHandler#isAcceptableLocation(org.eclipse.core.runtime.IPath)
   */
  protected boolean isAcceptableLocation(IPath location) {
    ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
    return location != null && manager.isTextFileLocation(location, true);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.