本文整理汇总了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];
}
示例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];
}
示例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];
}
示例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];
}
}