Examples of ITextFileBuffer


Examples of org.eclipse.core.filebuffers.ITextFileBuffer

    public long getModificationStamp(IResource resource) {
        if (!(resource instanceof IFile))
            return resource.getModificationStamp();
        IFile file = (IFile) resource;
        ITextFileBuffer buffer = getBuffer(file);
        if (buffer == null) {
            return file.getModificationStamp();
        } else {
            IDocument document = buffer.getDocument();
            if (document instanceof IDocumentExtension4) {
                return ((IDocumentExtension4) document).getModificationStamp();
            } else {
                return file.getModificationStamp();
            }
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBuffer

  private boolean isTextFileBufferInWorkDir(Saveable saveable) {
    IDocument document = (IDocument) saveable.getAdapter(IDocument.class);
    if (document == null)
      return true; // be conservative and assume this needs to be saved
    ITextFileBuffer textFileBuffer = FileBuffers.getTextFileBufferManager()
        .getTextFileBuffer(document);
    if (textFileBuffer != null)
      return isInWorkDir(textFileBuffer.getLocation());
    return false;
  }
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBuffer

  }

  private void checkDirtyFile(RefactoringStatus result, IFile file) {
    if (file == null || !file.exists())
      return;
    ITextFileBuffer buffer = FileBuffers.getTextFileBufferManager()
        .getTextFileBuffer(file.getFullPath(), LocationKind.NORMALIZE);
    if (buffer != null && buffer.isDirty()) {
      if (buffer.isStateValidated() && buffer.isSynchronized()) {
        result.addWarning(Messages
            .format(RefactoringCoreMessages.ScriptDeleteProcessor_unsaved_changes,
                file.getFullPath().toString()));
      } else {
        result.addFatalError(Messages
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBuffer

    }
  }

  protected static void saveFileIfNeeded(IFile file, IProgressMonitor pm)
      throws CoreException {
    ITextFileBuffer buffer = FileBuffers.getTextFileBufferManager()
        .getTextFileBuffer(file.getFullPath(), LocationKind.NORMALIZE);
    if (buffer != null && buffer.isDirty() && buffer.isStateValidated()
        && buffer.isSynchronized()) {
      pm.beginTask("", 2); //$NON-NLS-1$
      buffer.commit(new SubProgressMonitor(pm, 1), false);
      file.refreshLocal(IResource.DEPTH_ONE,
          new SubProgressMonitor(pm, 1));
      pm.done();
    } else {
      pm.beginTask("", 1); //$NON-NLS-1$
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBuffer

    ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
    //IPath location = thefile.getFullPath();
    IPath location = new Path(thefile.getAbsolutePath());
    boolean connected = false;
    try {
      ITextFileBuffer buffer =
        manager.getTextFileBuffer(location, LocationKind.LOCATION);
      if (buffer == null) {
        //no existing file buffer..create one
        manager.connect(location, LocationKind.LOCATION, new NullProgressMonitor());
        connected = true;
        buffer = manager.getTextFileBuffer(location, LocationKind.LOCATION);
        if (buffer == null) {
          return null;
        }
      }
      return buffer.getDocument();
    } finally {
      if (connected) {
        try {
          manager.disconnect(
              location, LocationKind.LOCATION, new NullProgressMonitor());
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBuffer

        change.setEdit(new MultiTextEdit());

        ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
        manager.connect(file.getFullPath(), LocationKind.IFILE, null);
        try {
            ITextFileBuffer textFileBuffer = manager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
            if (textFileBuffer == null) {
                resultingStatus.addError(Messages.format(SearchMessages.ReplaceRefactoring_error_accessing_file_buffer,
                        file.getName()));
                return null;
            }
            IDocument document = textFileBuffer.getDocument();
            String lineDelimiter = TextUtilities.getDefaultLineDelimiter(document);

            for (Iterator iterator = matches.iterator(); iterator.hasNext();) {
                FileMatch match = (FileMatch) iterator.next();
                int offset = match.getOffset();
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBuffer

      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) {
      fileBuffer.requestSynchronizationContext();

      FileInfo info= createEmptyFileInfo();
      info.fTextFileBuffer= fileBuffer;
      info.fTextFileBufferLocationKind= locationKind;
      info.fCachedReadOnlyState= isSystemFileReadOnly(info);
View Full Code Here

Examples of org.eclipse.core.filebuffers.ITextFileBuffer

  protected void createFileFromDocument(IProgressMonitor monitor, IFile file, IDocument document) throws CoreException {
    try {
      monitor.beginTask(EditorMessages.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.ITextFileBuffer

  private void createFileStoreFromDocument(IProgressMonitor monitor, URI uri, IDocument document) throws CoreException {
    try {
      monitor.beginTask(EditorMessages.TextFileDocumentProvider_beginTask_saving, 2000);
      IFileStore fileStore= EFS.getStore(uri);
      FileBuffers.getTextFileBufferManager().connectFileStore(fileStore, monitor);
      ITextFileBuffer buffer= FileBuffers.getTextFileBufferManager().getFileStoreTextFileBuffer(fileStore);
      buffer.getDocument().set(document.get());
      buffer.commit(monitor, true);
      FileBuffers.getTextFileBufferManager().disconnectFileStore(fileStore, monitor);
    } finally {
      monitor.done();
    }
  }
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.