Search in sources :

Example 6 with IExecutionDelegate

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;
}
Also used : IExecutionDelegate(org.eclipse.wst.sse.core.internal.IExecutionDelegate) DocumentRewriteSession(org.eclipse.jface.text.DocumentRewriteSession) DocumentRewriteSessionType(org.eclipse.jface.text.DocumentRewriteSessionType)

Example 7 with IExecutionDelegate

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;
}
Also used : StructuredDocumentEvent(org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent) IExecutionDelegate(org.eclipse.wst.sse.core.internal.IExecutionDelegate)

Aggregations

IExecutionDelegate (org.eclipse.wst.sse.core.internal.IExecutionDelegate)7 StructuredDocumentEvent (org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent)3 DocumentRewriteSession (org.eclipse.jface.text.DocumentRewriteSession)2 NoChangeEvent (org.eclipse.wst.sse.core.internal.provisional.events.NoChangeEvent)2 DocumentRewriteSessionType (org.eclipse.jface.text.DocumentRewriteSessionType)1