当前位置: 首页>>代码示例>>Java>>正文


Java ITextFileBufferManager.execute方法代码示例

本文整理汇总了Java中org.eclipse.core.filebuffers.ITextFileBufferManager.execute方法的典型用法代码示例。如果您正苦于以下问题:Java ITextFileBufferManager.execute方法的具体用法?Java ITextFileBufferManager.execute怎么用?Java ITextFileBufferManager.execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.core.filebuffers.ITextFileBufferManager的用法示例。


在下文中一共展示了ITextFileBufferManager.execute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: performEdits

import org.eclipse.core.filebuffers.ITextFileBufferManager; //导入方法依赖的package包/类
private UndoEdit performEdits() throws BadLocationException, MalformedTreeException {
  ITextFileBufferManager fileBufferManager = FileBuffers.getTextFileBufferManager();

  ITextFileBuffer fileBuffer = fileBufferManager.getTextFileBuffer(fDocument);
  if (fileBuffer == null || !fileBuffer.isSynchronizationContextRequested()) {
    return fUndo.apply(fDocument, TextEdit.CREATE_UNDO);
  }

  /** The lock for waiting for computation in the UI thread to complete. */
  final Lock completionLock = new Lock();
  final UndoEdit[] result = new UndoEdit[1];
  final BadLocationException[] exception = new BadLocationException[1];
  Runnable runnable =
      new Runnable() {
        public void run() {
          synchronized (completionLock) {
            try {
              result[0] = fUndo.apply(fDocument, TextEdit.CREATE_UNDO);
            } catch (BadLocationException e) {
              exception[0] = e;
            } finally {
              completionLock.fDone = true;
              completionLock.notifyAll();
            }
          }
        }
      };

  synchronized (completionLock) {
    fileBufferManager.execute(runnable);
    while (!completionLock.fDone) {
      try {
        completionLock.wait(500);
      } catch (InterruptedException x) {
      }
    }
  }

  if (exception[0] != null) {
    throw exception[0];
  }

  return result[0];
}
 
开发者ID:eclipse,项目名称:che,代码行数:45,代码来源:UndoDocumentChange.java

示例2: performEdits

import org.eclipse.core.filebuffers.ITextFileBufferManager; //导入方法依赖的package包/类
protected UndoEdit performEdits(final IDocument document)
    throws BadLocationException, MalformedTreeException {
  ITextFileBufferManager fileBufferManager = FileBuffers.getTextFileBufferManager();

  ITextFileBuffer fileBuffer = fileBufferManager.getTextFileBuffer(document);
  if (fileBuffer == null || !fileBuffer.isSynchronizationContextRequested()) {
    return super.performEdits(document);
  }

  /** The lock for waiting for computation in the UI thread to complete. */
  final Lock completionLock = new Lock();
  final UndoEdit[] result = new UndoEdit[1];
  final BadLocationException[] exception = new BadLocationException[1];
  Runnable runnable =
      new Runnable() {
        public void run() {
          synchronized (completionLock) {
            try {
              result[0] = DocumentChange.super.performEdits(document);
            } catch (BadLocationException e) {
              exception[0] = e;
            } finally {
              completionLock.fDone = true;
              completionLock.notifyAll();
            }
          }
        }
      };

  synchronized (completionLock) {
    fileBufferManager.execute(runnable);
    while (!completionLock.fDone) {
      try {
        completionLock.wait(500);
      } catch (InterruptedException x) {
      }
    }
  }

  if (exception[0] != null) {
    throw exception[0];
  }

  return result[0];
}
 
开发者ID:eclipse,项目名称:che,代码行数:46,代码来源:DocumentChange.java

示例3: performEdits

import org.eclipse.core.filebuffers.ITextFileBufferManager; //导入方法依赖的package包/类
protected UndoEdit performEdits(final IDocument document)
    throws BadLocationException, MalformedTreeException {
  if (!fBuffer.isSynchronizationContextRequested()) {
    return super.performEdits(document);
  }

  ITextFileBufferManager fileBufferManager = FileBuffers.getTextFileBufferManager();

  /** The lock for waiting for computation in the UI thread to complete. */
  final Lock completionLock = new Lock();
  final UndoEdit[] result = new UndoEdit[1];
  final BadLocationException[] exception = new BadLocationException[1];
  Runnable runnable =
      new Runnable() {
        public void run() {
          synchronized (completionLock) {
            try {
              result[0] = TextFileChange.super.performEdits(document);
            } catch (BadLocationException e) {
              exception[0] = e;
            } finally {
              completionLock.fDone = true;
              completionLock.notifyAll();
            }
          }
        }
      };

  synchronized (completionLock) {
    fileBufferManager.execute(runnable);
    while (!completionLock.fDone) {
      try {
        completionLock.wait(500);
      } catch (InterruptedException x) {
      }
    }
  }

  if (exception[0] != null) {
    throw exception[0];
  }

  return result[0];
}
 
开发者ID:eclipse,项目名称:che,代码行数:45,代码来源:TextFileChange.java

示例4: performChanges

import org.eclipse.core.filebuffers.ITextFileBufferManager; //导入方法依赖的package包/类
/**
 * Performs the changes on the specified document.
 *
 * @param document the document to perform the changes on
 * @param undoList the undo list, or <code>null</code> to discard the undos
 * @param preview <code>true</code> if the changes are performed for preview, <code>false</code>
 *     otherwise
 * @throws BadLocationException if the edit tree could not be applied
 */
private void performChanges(
    final IDocument document, final LinkedList undoList, final boolean preview)
    throws BadLocationException {
  if (!fBuffer.isSynchronizationContextRequested()) {
    performChangesInSynchronizationContext(document, undoList, preview);
    return;
  }

  ITextFileBufferManager fileBufferManager = FileBuffers.getTextFileBufferManager();

  /** The lock for waiting for computation in the UI thread to complete. */
  final Lock completionLock = new Lock();
  final BadLocationException[] exception = new BadLocationException[1];
  Runnable runnable =
      new Runnable() {
        public void run() {
          synchronized (completionLock) {
            try {
              performChangesInSynchronizationContext(document, undoList, preview);
            } catch (BadLocationException e) {
              exception[0] = e;
            } finally {
              completionLock.fDone = true;
              completionLock.notifyAll();
            }
          }
        }
      };

  synchronized (completionLock) {
    fileBufferManager.execute(runnable);
    while (!completionLock.fDone) {
      try {
        completionLock.wait(500);
      } catch (InterruptedException x) {
      }
    }
  }

  if (exception[0] != null) {
    throw exception[0];
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:53,代码来源:MultiStateTextFileChange.java


注:本文中的org.eclipse.core.filebuffers.ITextFileBufferManager.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。