Search in sources :

Example 1 with IExecutionDelegate

use of org.eclipse.wst.sse.core.internal.IExecutionDelegate in project webtools.sourceediting by eclipse.

the class JobSafeStructuredDocument method replace.

/*
	 * @see org.eclipse.jface.text.IDocumentExtension4.replace(int, int, String, long)
	 */
public void replace(final int offset, final int length, final String text, final long modificationStamp) throws BadLocationException {
    IExecutionDelegate delegate = getExecutionDelegate();
    if (delegate == null) {
        super.replace(offset, length, text, modificationStamp);
    } else {
        JobSafeRunnable runnable = new JobSafeRunnable() {

            public void run() throws Exception {
                JobSafeStructuredDocument.super.replace(offset, length, text, modificationStamp);
            }
        };
        delegate.execute(runnable);
    }
}
Also used : IExecutionDelegate(org.eclipse.wst.sse.core.internal.IExecutionDelegate)

Example 2 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, boolean)
	 */
public StructuredDocumentEvent replaceText(final Object requester, final int start, final int replacementLength, final String changes, final boolean ignoreReadOnlySettings) {
    StructuredDocumentEvent event = null;
    IExecutionDelegate delegate = getExecutionDelegate();
    if (delegate == null) {
        event = super.replaceText(requester, start, replacementLength, changes, ignoreReadOnlySettings);
    } 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, ignoreReadOnlySettings);
            }

            public void handleException(Throwable exception) {
                resultSlot[0] = new NoChangeEvent(JobSafeStructuredDocument.this, requester, changes, start, replacementLength);
                super.handleException(exception);
            }
        };
        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) NoChangeEvent(org.eclipse.wst.sse.core.internal.provisional.events.NoChangeEvent)

Example 3 with IExecutionDelegate

use of org.eclipse.wst.sse.core.internal.IExecutionDelegate in project webtools.sourceediting by eclipse.

the class JobSafeStructuredDocument method setText.

public StructuredDocumentEvent setText(final Object requester, final String theString) {
    StructuredDocumentEvent event = null;
    IExecutionDelegate executionDelegate = getExecutionDelegate();
    if (executionDelegate == null) {
        event = super.setText(requester, theString);
    } else {
        final Object[] resultSlot = new Object[1];
        JobSafeRunnable runnable = new JobSafeRunnable() {

            public void run() throws Exception {
                resultSlot[0] = JobSafeStructuredDocument.super.setText(requester, theString);
            }

            public void handleException(Throwable exception) {
                resultSlot[0] = new NoChangeEvent(JobSafeStructuredDocument.this, requester, theString, 0, 0);
                super.handleException(exception);
            }
        };
        executionDelegate.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) NoChangeEvent(org.eclipse.wst.sse.core.internal.provisional.events.NoChangeEvent)

Example 4 with IExecutionDelegate

use of org.eclipse.wst.sse.core.internal.IExecutionDelegate in project webtools.sourceediting by eclipse.

the class JobSafeStructuredDocument method stopRewriteSession.

public void stopRewriteSession(DocumentRewriteSession session) {
    IExecutionDelegate executionDelegate = getExecutionDelegate();
    if (executionDelegate == null) {
        internalStopRewriteSession(session);
    } else {
        final DocumentRewriteSession finalSession = session;
        JobSafeRunnable runnable = new JobSafeRunnable() {

            public void run() throws Exception {
                internalStopRewriteSession(finalSession);
            }
        };
        executionDelegate.execute(runnable);
    }
}
Also used : IExecutionDelegate(org.eclipse.wst.sse.core.internal.IExecutionDelegate) DocumentRewriteSession(org.eclipse.jface.text.DocumentRewriteSession)

Example 5 with IExecutionDelegate

use of org.eclipse.wst.sse.core.internal.IExecutionDelegate in project webtools.sourceediting by eclipse.

the class JobSafeStructuredDocument method replace.

/*
	 * @see org.eclipse.jface.text.IDocument.replace(int, int, String)
	 */
public void replace(final int offset, final int length, final String text) throws BadLocationException {
    IExecutionDelegate delegate = getExecutionDelegate();
    if (delegate == null) {
        super.replace(offset, length, text);
    } else {
        JobSafeRunnable runnable = new JobSafeRunnable() {

            public void run() throws Exception {
                JobSafeStructuredDocument.super.replace(offset, length, text);
            }
        };
        delegate.execute(runnable);
    }
}
Also used : 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