ca.odell.glazedlists.impl.swt.SWTThreadProxyEventList Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of glazedlists_java15 Show documentation
Show all versions of glazedlists_java15 Show documentation
Event-driven lists for dynamically filtered and sorted tables
/* Glazed Lists (c) 2003-2006 */
/* http://publicobject.com/glazedlists/ publicboject.com,*/
/* O'Dell Engineering Ltd.*/
package ca.odell.glazedlists.impl.swt;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.impl.gui.ThreadProxyEventList;
import org.eclipse.swt.widgets.Display;
/**
* Proxies events from all threads to the SWT event dispatch thread. This allows
* any thread to write a source {@link EventList} that will be updated on the
* SWT thread.
*
* @author Jesse Wilson
*/
public class SWTThreadProxyEventList extends ThreadProxyEventList {
/** the display which owns the user interface thread */
private final Display display;
/**
* Create a {@link SWTThreadProxyEventList} that mirrors the specified
* source {@link EventList} for access on the SWT thread.
*/
public SWTThreadProxyEventList(EventList source, Display display) {
super(source);
this.display = display;
}
/**
* Schedule the specified runnable to be run on the proxied thread.
*/
@Override
protected void schedule(Runnable runnable) {
if(display.getThread() == Thread.currentThread()) {
runnable.run();
} else {
display.asyncExec(runnable);
}
}
}