]> git.argeo.org Git - lgpl/argeo-commons.git/blob - AsyncUiEventListener.java
a54f63e69a9fdfc70442e755f454354610a7c6c1
[lgpl/argeo-commons.git] / AsyncUiEventListener.java
1 package org.argeo.eclipse.ui.jcr;
2
3 import javax.jcr.observation.EventIterator;
4 import javax.jcr.observation.EventListener;
5
6 import org.eclipse.ui.PlatformUI;
7
8 /** {@link EventListener} which simplifies running actions within the UI thread. */
9 public abstract class AsyncUiEventListener implements EventListener {
10 /** Called asynchronously in the UI thread. */
11 protected abstract void onEventInUiThread(EventIterator events);
12
13 public void onEvent(final EventIterator events) {
14 PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
15 public void run() {
16 onEventInUiThread(events);
17 }
18 });
19 }
20 }