use of org.eclipse.ltk.internal.core.refactoring.Lock in project che by eclipse.
the class TextFileChange method performEdits.
/*
* @see org.eclipse.ltk.core.refactoring.TextChange#performEdits(org.eclipse.jface.text.IDocument)
* @since 3.5
*/
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];
}
use of org.eclipse.ltk.internal.core.refactoring.Lock in project che by eclipse.
the class UndoTextFileChange method performEdits.
private UndoEdit performEdits(ITextFileBuffer buffer, final IDocument document, final boolean[] setContentStampSuccess) throws MalformedTreeException, BadLocationException, CoreException {
if (!buffer.isSynchronizationContextRequested()) {
return doPerformEdits(document, setContentStampSuccess);
}
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[] badLocationException = new BadLocationException[1];
final MalformedTreeException[] malformedTreeException = new MalformedTreeException[1];
final CoreException[] coreException = new CoreException[1];
Runnable runnable = new Runnable() {
public void run() {
synchronized (completionLock) {
try {
result[0] = doPerformEdits(document, setContentStampSuccess);
} catch (BadLocationException e) {
badLocationException[0] = e;
} catch (MalformedTreeException e) {
malformedTreeException[0] = e;
} catch (CoreException e) {
coreException[0] = e;
} finally {
completionLock.fDone = true;
completionLock.notifyAll();
}
}
}
};
synchronized (completionLock) {
fileBufferManager.execute(runnable);
while (!completionLock.fDone) {
try {
completionLock.wait(500);
} catch (InterruptedException x) {
}
}
}
if (badLocationException[0] != null) {
throw badLocationException[0];
} else if (malformedTreeException[0] != null) {
throw malformedTreeException[0];
} else if (coreException[0] != null) {
throw coreException[0];
}
return result[0];
}
use of org.eclipse.ltk.internal.core.refactoring.Lock in project che by eclipse.
the class DocumentChange method performEdits.
/*
* @see org.eclipse.ltk.core.refactoring.TextChange#performEdits(org.eclipse.jface.text.IDocument)
* @since 3.6
*/
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];
}
use of org.eclipse.ltk.internal.core.refactoring.Lock in project che by eclipse.
the class MultiStateTextFileChange method performChanges.
/**
* 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];
}
}
Aggregations