Reverting changes from bug 232336.
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 4f11110..d83e78a 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 @@
/**
* 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 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 @@
};
}
+ private boolean isExecutingUIThread() {
+ return Display.getCurrent() != null;
+ }
+
/**
* Display#asyncExec(Runnable) seems to work OK;
* but using #syncExec(Runnable) can somtimes make things
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTListChangeListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTListChangeListenerWrapper.java
index 1cfcb99..2343c62 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTListChangeListenerWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTListChangeListenerWrapper.java
@@ -16,8 +16,6 @@
/**
* Wrap another list 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 SWTListChangeListenerWrapper
implements ListChangeListener
@@ -33,27 +31,51 @@
}
public void itemsAdded(ListChangeEvent event) {
- this.executeOnUIThread(this.buildItemsAddedRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.itemsAdded_(event);
+ } else {
+ this.executeOnUIThread(this.buildItemsAddedRunnable(event));
+ }
}
public void itemsRemoved(ListChangeEvent event) {
- this.executeOnUIThread(this.buildItemsRemovedRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.itemsRemoved_(event);
+ } else {
+ this.executeOnUIThread(this.buildItemsRemovedRunnable(event));
+ }
}
public void itemsMoved(ListChangeEvent event) {
- this.executeOnUIThread(this.buildItemsMovedRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.itemsMoved_(event);
+ } else {
+ this.executeOnUIThread(this.buildItemsMovedRunnable(event));
+ }
}
public void itemsReplaced(ListChangeEvent event) {
- this.executeOnUIThread(this.buildItemsReplacedRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.itemsReplaced_(event);
+ } else {
+ this.executeOnUIThread(this.buildItemsReplacedRunnable(event));
+ }
}
public void listCleared(ListChangeEvent event) {
- this.executeOnUIThread(this.buildCollectionClearedRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.listCleared_(event);
+ } else {
+ this.executeOnUIThread(this.buildCollectionClearedRunnable(event));
+ }
}
public void listChanged(ListChangeEvent event) {
- this.executeOnUIThread(this.buildCollectionChangedRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.listChanged_(event);
+ } else {
+ this.executeOnUIThread(this.buildCollectionChangedRunnable(event));
+ }
}
private Runnable buildItemsAddedRunnable(final ListChangeEvent event) {
@@ -128,6 +150,10 @@
};
}
+ private boolean isExecutingUIThread() {
+ return Display.getCurrent() != null;
+ }
+
/**
* Display#asyncExec(Runnable) seems to work OK;
* but using #syncExec(Runnable) can somtimes make things
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTPropertyChangeListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTPropertyChangeListenerWrapper.java
index 25fd34f..99f0a6f 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTPropertyChangeListenerWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTPropertyChangeListenerWrapper.java
@@ -16,8 +16,6 @@
/**
* Wrap another property 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 SWTPropertyChangeListenerWrapper
implements PropertyChangeListener
@@ -33,7 +31,11 @@
}
public void propertyChanged(PropertyChangeEvent event) {
- this.executeOnUIThread(this.buildRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.propertyChanged_(event);
+ } else {
+ this.executeOnUIThread(this.buildRunnable(event));
+ }
}
private Runnable buildRunnable(final PropertyChangeEvent event) {
@@ -44,6 +46,10 @@
};
}
+ private boolean isExecutingUIThread() {
+ return Display.getCurrent() != null;
+ }
+
/**
* Display#asyncExec(Runnable) seems to work OK;
* but using #syncExec(Runnable) can somtimes make things
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTStateChangeListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTStateChangeListenerWrapper.java
index 655226b..4a94133 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTStateChangeListenerWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTStateChangeListenerWrapper.java
@@ -16,8 +16,6 @@
/**
* Wrap another state 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 SWTStateChangeListenerWrapper
implements StateChangeListener
@@ -33,7 +31,11 @@
}
public void stateChanged(StateChangeEvent event) {
- this.executeOnUIThread(this.buildRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.stateChanged_(event);
+ } else {
+ this.executeOnUIThread(this.buildRunnable(event));
+ }
}
private Runnable buildRunnable(final StateChangeEvent event) {
@@ -44,6 +46,10 @@
};
}
+ private boolean isExecutingUIThread() {
+ return Display.getCurrent() != null;
+ }
+
/**
* Display#asyncExec(Runnable) seems to work OK;
* but using #syncExec(Runnable) can somtimes make things
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTTreeChangeListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTTreeChangeListenerWrapper.java
index 1b9a974..71e8cd0 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTTreeChangeListenerWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/listeners/SWTTreeChangeListenerWrapper.java
@@ -16,8 +16,6 @@
/**
* Wrap another tree 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 SWTTreeChangeListenerWrapper
implements TreeChangeListener
@@ -33,19 +31,35 @@
}
public void nodeAdded(TreeChangeEvent event) {
- this.executeOnUIThread(this.buildNodeAddedRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.nodeAdded_(event);
+ } else {
+ this.executeOnUIThread(this.buildNodeAddedRunnable(event));
+ }
}
public void nodeRemoved(TreeChangeEvent event) {
- this.executeOnUIThread(this.buildNodeRemovedRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.nodeRemoved_(event);
+ } else {
+ this.executeOnUIThread(this.buildNodeRemovedRunnable(event));
+ }
}
public void treeCleared(TreeChangeEvent event) {
- this.executeOnUIThread(this.buildTreeClearedRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.treeCleared_(event);
+ } else {
+ this.executeOnUIThread(this.buildTreeClearedRunnable(event));
+ }
}
public void treeChanged(TreeChangeEvent event) {
- this.executeOnUIThread(this.buildTreeChangedRunnable(event));
+ if (this.isExecutingUIThread()) {
+ this.treeChanged_(event);
+ } else {
+ this.executeOnUIThread(this.buildTreeChangedRunnable(event));
+ }
}
private Runnable buildNodeAddedRunnable(final TreeChangeEvent event) {
@@ -96,6 +110,10 @@
};
}
+ private boolean isExecutingUIThread() {
+ return Display.getCurrent() != null;
+ }
+
/**
* Display#asyncExec(Runnable) seems to work OK;
* but using #syncExec(Runnable) can somtimes make things
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTCollectionChangeListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTCollectionChangeListenerWrapper.java
index d8cc166..297654d 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTCollectionChangeListenerWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTCollectionChangeListenerWrapper.java
@@ -17,8 +17,6 @@
/**
* Wrap another collection change listener and forward events to it on the AWT
* event queue.
- * Forward *every* event asynchronously via the UI thread so the listener
- * receives in the same order they were generated.
*/
public class AWTCollectionChangeListenerWrapper
implements CollectionChangeListener
@@ -34,19 +32,35 @@
}
public void itemsAdded(CollectionChangeEvent event) {
- this.executeOnEventQueue(this.buildItemsAddedRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.itemsAdded_(event);
+ } else {
+ this.executeOnEventQueue(this.buildItemsAddedRunnable(event));
+ }
}
public void itemsRemoved(CollectionChangeEvent event) {
- this.executeOnEventQueue(this.buildItemsRemovedRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.itemsRemoved_(event);
+ } else {
+ this.executeOnEventQueue(this.buildItemsRemovedRunnable(event));
+ }
}
public void collectionCleared(CollectionChangeEvent event) {
- this.executeOnEventQueue(this.buildCollectionClearedRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.collectionCleared_(event);
+ } else {
+ this.executeOnEventQueue(this.buildCollectionClearedRunnable(event));
+ }
}
public void collectionChanged(CollectionChangeEvent event) {
- this.executeOnEventQueue(this.buildCollectionChangedRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.collectionChanged_(event);
+ } else {
+ this.executeOnEventQueue(this.buildCollectionChangedRunnable(event));
+ }
}
private Runnable buildItemsAddedRunnable(final CollectionChangeEvent event) {
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTListChangeListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTListChangeListenerWrapper.java
index ac28b92..8c63c63 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTListChangeListenerWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTListChangeListenerWrapper.java
@@ -17,8 +17,6 @@
/**
* Wrap another list change listener and forward events to it on the AWT
* event queue.
- * Forward *every* event asynchronously via the UI thread so the listener
- * receives in the same order they were generated.
*/
public class AWTListChangeListenerWrapper
implements ListChangeListener
@@ -34,27 +32,51 @@
}
public void itemsAdded(ListChangeEvent event) {
- this.executeOnEventQueue(this.buildItemsAddedRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.itemsAdded_(event);
+ } else {
+ this.executeOnEventQueue(this.buildItemsAddedRunnable(event));
+ }
}
public void itemsRemoved(ListChangeEvent event) {
- this.executeOnEventQueue(this.buildItemsRemovedRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.itemsRemoved_(event);
+ } else {
+ this.executeOnEventQueue(this.buildItemsRemovedRunnable(event));
+ }
}
public void itemsMoved(ListChangeEvent event) {
- this.executeOnEventQueue(this.buildItemsMovedRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.itemsMoved_(event);
+ } else {
+ this.executeOnEventQueue(this.buildItemsMovedRunnable(event));
+ }
}
public void itemsReplaced(ListChangeEvent event) {
- this.executeOnEventQueue(this.buildItemsReplacedRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.itemsReplaced_(event);
+ } else {
+ this.executeOnEventQueue(this.buildItemsReplacedRunnable(event));
+ }
}
public void listCleared(ListChangeEvent event) {
- this.executeOnEventQueue(this.buildListClearedRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.listCleared_(event);
+ } else {
+ this.executeOnEventQueue(this.buildListClearedRunnable(event));
+ }
}
public void listChanged(ListChangeEvent event) {
- this.executeOnEventQueue(this.buildListChangedRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.listChanged_(event);
+ } else {
+ this.executeOnEventQueue(this.buildListChangedRunnable(event));
+ }
}
private Runnable buildItemsAddedRunnable(final ListChangeEvent event) {
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTPropertyChangeListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTPropertyChangeListenerWrapper.java
index 7682773..171ac87 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTPropertyChangeListenerWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTPropertyChangeListenerWrapper.java
@@ -17,8 +17,6 @@
/**
* Wrap another property change listener and forward events to it on the AWT
* event queue.
- * Forward *every* event asynchronously via the UI thread so the listener
- * receives in the same order they were generated.
*/
public class AWTPropertyChangeListenerWrapper
implements PropertyChangeListener
@@ -35,7 +33,11 @@
}
public void propertyChanged(PropertyChangeEvent event) {
- this.executeOnEventQueue(this.buildRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.propertyChanged_(event);
+ } else {
+ this.executeOnEventQueue(this.buildRunnable(event));
+ }
}
private Runnable buildRunnable(final PropertyChangeEvent event) {
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTStateChangeListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTStateChangeListenerWrapper.java
index b59556d..bb042ae 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTStateChangeListenerWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTStateChangeListenerWrapper.java
@@ -17,8 +17,6 @@
/**
* Wrap another state change listener and forward events to it on the AWT
* event queue.
- * Forward *every* event asynchronously via the UI thread so the listener
- * receives in the same order they were generated.
*/
public class AWTStateChangeListenerWrapper
implements StateChangeListener
@@ -34,7 +32,11 @@
}
public void stateChanged(StateChangeEvent event) {
- this.executeOnEventQueue(this.buildRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.stateChanged_(event);
+ } else {
+ this.executeOnEventQueue(this.buildRunnable(event));
+ }
}
private Runnable buildRunnable(final StateChangeEvent event) {
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTTreeChangeListenerWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTTreeChangeListenerWrapper.java
index db0a0e3..0186d5d 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTTreeChangeListenerWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/listener/awt/AWTTreeChangeListenerWrapper.java
@@ -17,8 +17,6 @@
/**
* Wrap another tree change listener and forward events to it on the AWT
* event queue.
- * Forward *every* event asynchronously via the UI thread so the listener
- * receives in the same order they were generated.
*/
public class AWTTreeChangeListenerWrapper
implements TreeChangeListener
@@ -34,19 +32,35 @@
}
public void nodeAdded(TreeChangeEvent event) {
- this.executeOnEventQueue(this.buildNodeAddedRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.nodeAdded_(event);
+ } else {
+ this.executeOnEventQueue(this.buildNodeAddedRunnable(event));
+ }
}
public void nodeRemoved(TreeChangeEvent event) {
- this.executeOnEventQueue(this.buildNodeRemovedRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.nodeRemoved_(event);
+ } else {
+ this.executeOnEventQueue(this.buildNodeRemovedRunnable(event));
+ }
}
public void treeCleared(TreeChangeEvent event) {
- this.executeOnEventQueue(this.buildTreeClearedRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.treeCleared_(event);
+ } else {
+ this.executeOnEventQueue(this.buildTreeClearedRunnable(event));
+ }
}
public void treeChanged(TreeChangeEvent event) {
- this.executeOnEventQueue(this.buildTreeChangedRunnable(event));
+ if (EventQueue.isDispatchThread()) {
+ this.treeChanged_(event);
+ } else {
+ this.executeOnEventQueue(this.buildTreeChangedRunnable(event));
+ }
}
private Runnable buildNodeAddedRunnable(final TreeChangeEvent event) {