use of org.eclipse.wst.sse.core.internal.IExecutionDelegate in project webtools.sourceediting by eclipse.
the class JobSafeStructuredDocument method startRewriteSession.
public DocumentRewriteSession startRewriteSession(DocumentRewriteSessionType sessionType) throws IllegalStateException {
DocumentRewriteSession session = null;
IExecutionDelegate executionDelegate = getExecutionDelegate();
if (executionDelegate == null) {
session = internalStartRewriteSession(sessionType);
} else {
final Object[] resultSlot = new Object[1];
final DocumentRewriteSessionType finalSessionType = sessionType;
JobSafeRunnable runnable = new JobSafeRunnable() {
public void run() throws Exception {
resultSlot[0] = internalStartRewriteSession(finalSessionType);
}
};
executionDelegate.execute(runnable);
if (resultSlot[0] instanceof Throwable) {
throw new RuntimeException((Throwable) resultSlot[0]);
} else {
session = (DocumentRewriteSession) resultSlot[0];
}
}
return session;
}
use of org.eclipse.wst.sse.core.internal.IExecutionDelegate in project webtools.sourceediting by eclipse.
the class JobSafeStructuredDocument method replaceText.
/* (non-Javadoc)
* @see org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument#replaceText(java.lang.Object, int, int, java.lang.String)
*/
public StructuredDocumentEvent replaceText(final Object requester, final int start, final int replacementLength, final String changes) {
StructuredDocumentEvent event = null;
IExecutionDelegate delegate = getExecutionDelegate();
if (delegate == null) {
event = super.replaceText(requester, start, replacementLength, changes);
} else {
final Object[] resultSlot = new Object[1];
JobSafeRunnable runnable = new JobSafeRunnable() {
public void run() throws Exception {
resultSlot[0] = JobSafeStructuredDocument.super.replaceText(requester, start, replacementLength, changes);
}
};
delegate.execute(runnable);
event = (StructuredDocumentEvent) resultSlot[0];
}
return event;
}
Aggregations