Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTCollectionChangeListenerWrapper.java')
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTCollectionChangeListenerWrapper.java30
1 files changed, 24 insertions, 6 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTCollectionChangeListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTCollectionChangeListenerWrapper.java
index 6b9b1b1558..c17e6c6bf7 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTCollectionChangeListenerWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTCollectionChangeListenerWrapper.java
@@ -16,8 +16,6 @@ import org.eclipse.swt.widgets.Display;
/**
* Wrap another collection change listener and forward events to it on the SWT
* UI thread.
- * Forward *every* event asynchronously via the UI thread so the listener
- * receives in the same order they were generated.
*/
public class SWTCollectionChangeListenerWrapper
implements CollectionChangeListener
@@ -33,19 +31,35 @@ public class SWTCollectionChangeListenerWrapper
}
public void itemsAdded(CollectionChangeEvent event) {
- this.executeOnUIThread(this.buildItemsAddedRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.itemsAdded_(event);
+ } else {
+ this.executeOnUIThread(this.buildItemsAddedRunnable(event));
+ }
}
public void itemsRemoved(CollectionChangeEvent event) {
- this.executeOnUIThread(this.buildItemsRemovedRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.itemsRemoved_(event);
+ } else {
+ this.executeOnUIThread(this.buildItemsRemovedRunnable(event));
+ }
}
public void collectionCleared(CollectionChangeEvent event) {
- this.executeOnUIThread(this.buildCollectionClearedRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.collectionCleared_(event);
+ } else {
+ this.executeOnUIThread(this.buildCollectionClearedRunnable(event));
+ }
}
public void collectionChanged(CollectionChangeEvent event) {
- this.executeOnUIThread(this.buildCollectionChangedRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.collectionChanged_(event);
+ } else {
+ this.executeOnUIThread(this.buildCollectionChangedRunnable(event));
+ }
}
private Runnable buildItemsAddedRunnable(final CollectionChangeEvent event) {
@@ -96,6 +110,10 @@ public class SWTCollectionChangeListenerWrapper
};
}
+ private boolean isExecutingUIThread() {
+ return Display.getCurrent() != null;
+ }
+
/**
* Display#asyncExec(Runnable) seems to work OK;
* but using #syncExec(Runnable) can somtimes make things

Back to the top