From: Mathieu Baudier Date: Tue, 19 Apr 2011 19:01:33 +0000 (+0000) Subject: Asynchornous UI thread event listener X-Git-Tag: argeo-commons-2.1.30~1278 X-Git-Url: https://git.argeo.org/?a=commitdiff_plain;h=d6379d95e2007f27762131de7b61d6fb530cb41e;p=lgpl%2Fargeo-commons.git Asynchornous UI thread event listener NEW - bug 17: Generalize agent management and registration beyond JMS https://bugzilla.argeo.org/show_bug.cgi?id=17 git-svn-id: https://svn.argeo.org/commons/trunk@4456 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/eclipse/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/AsyncUiEventListener.java b/eclipse/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/AsyncUiEventListener.java new file mode 100644 index 000000000..a54f63e69 --- /dev/null +++ b/eclipse/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/AsyncUiEventListener.java @@ -0,0 +1,20 @@ +package org.argeo.eclipse.ui.jcr; + +import javax.jcr.observation.EventIterator; +import javax.jcr.observation.EventListener; + +import org.eclipse.ui.PlatformUI; + +/** {@link EventListener} which simplifies running actions within the UI thread. */ +public abstract class AsyncUiEventListener implements EventListener { + /** Called asynchronously in the UI thread. */ + protected abstract void onEventInUiThread(EventIterator events); + + public void onEvent(final EventIterator events) { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + onEventInUiThread(events); + } + }); + } +}