summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorBalazs Grill2013-07-16 11:10:19 (EDT)
committer Abel Hegedus2013-11-21 04:39:51 (EST)
commitb74145033c5d17484d03139cedb991b11705e994 (patch)
tree34c340bf74236dc3dbb3acc4dcbf160cb473c060
parentc872675f8afde3b099c7b637453599aa5bc5107c (diff)
downloadorg.eclipse.incquery-b74145033c5d17484d03139cedb991b11705e994.zip
org.eclipse.incquery-b74145033c5d17484d03139cedb991b11705e994.tar.gz
org.eclipse.incquery-b74145033c5d17484d03139cedb991b11705e994.tar.bz2
[413076] Forcing data binding events to the thread of the realm
Signed-off-by: Balazs Grill <balage.g@gmail.com>
-rw-r--r--plugins/org.eclipse.incquery.databinding.runtime/src/org/eclipse/incquery/databinding/runtime/collection/ObservablePatternMatchList.java26
-rw-r--r--plugins/org.eclipse.incquery.databinding.runtime/src/org/eclipse/incquery/databinding/runtime/collection/ObservablePatternMatchSet.java26
2 files changed, 44 insertions, 8 deletions
diff --git a/plugins/org.eclipse.incquery.databinding.runtime/src/org/eclipse/incquery/databinding/runtime/collection/ObservablePatternMatchList.java b/plugins/org.eclipse.incquery.databinding.runtime/src/org/eclipse/incquery/databinding/runtime/collection/ObservablePatternMatchList.java
index 4f2f7f8..62cda66 100644
--- a/plugins/org.eclipse.incquery.databinding.runtime/src/org/eclipse/incquery/databinding/runtime/collection/ObservablePatternMatchList.java
+++ b/plugins/org.eclipse.incquery.databinding.runtime/src/org/eclipse/incquery/databinding/runtime/collection/ObservablePatternMatchList.java
@@ -15,9 +15,11 @@ import java.util.Collections;
import java.util.List;
import org.eclipse.core.databinding.observable.Diffs;
+import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.list.AbstractObservableList;
import org.eclipse.core.databinding.observable.list.ListDiff;
import org.eclipse.core.databinding.observable.list.ListDiffEntry;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.incquery.databinding.runtime.api.IncQueryObservables;
import org.eclipse.incquery.runtime.api.IPatternMatch;
import org.eclipse.incquery.runtime.api.IQuerySpecification;
@@ -170,8 +172,16 @@ public class ObservablePatternMatchList<Match extends IPatternMatch> extends Abs
public void addMatch(Match match) {
ListDiffEntry diffentry = Diffs.createListDiffEntry(cache.size(), true, match);
cache.add(match);
- ListDiff diff = Diffs.createListDiff(diffentry);
- fireListChange(diff);
+ final ListDiff diff = Diffs.createListDiff(diffentry);
+ Realm realm = getRealm();
+ Assert.isNotNull(realm, "Data binding Realm must not be null");
+ realm.exec(new Runnable() {
+
+ @Override
+ public void run() {
+ fireListChange(diff);
+ }
+ });
}
@Override
@@ -179,8 +189,16 @@ public class ObservablePatternMatchList<Match extends IPatternMatch> extends Abs
final int index = cache.indexOf(match);
ListDiffEntry diffentry = Diffs.createListDiffEntry(index, false, match);
cache.remove(match);
- ListDiff diff = Diffs.createListDiff(diffentry);
- fireListChange(diff);
+ final ListDiff diff = Diffs.createListDiff(diffentry);
+ Realm realm = getRealm();
+ Assert.isNotNull(realm, "Data binding Realm must not be null");
+ realm.exec(new Runnable() {
+
+ @Override
+ public void run() {
+ fireListChange(diff);
+ }
+ });
}
}
diff --git a/plugins/org.eclipse.incquery.databinding.runtime/src/org/eclipse/incquery/databinding/runtime/collection/ObservablePatternMatchSet.java b/plugins/org.eclipse.incquery.databinding.runtime/src/org/eclipse/incquery/databinding/runtime/collection/ObservablePatternMatchSet.java
index 18d16c0..95d6607 100644
--- a/plugins/org.eclipse.incquery.databinding.runtime/src/org/eclipse/incquery/databinding/runtime/collection/ObservablePatternMatchSet.java
+++ b/plugins/org.eclipse.incquery.databinding.runtime/src/org/eclipse/incquery/databinding/runtime/collection/ObservablePatternMatchSet.java
@@ -15,8 +15,10 @@ import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.databinding.observable.Diffs;
+import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.set.AbstractObservableSet;
import org.eclipse.core.databinding.observable.set.SetDiff;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.incquery.databinding.runtime.api.IncQueryObservables;
import org.eclipse.incquery.runtime.api.IPatternMatch;
import org.eclipse.incquery.runtime.api.IQuerySpecification;
@@ -165,16 +167,32 @@ public class ObservablePatternMatchSet<Match extends IPatternMatch> extends Abst
@Override
public void addMatch(Match match) {
cache.add(match);
- SetDiff diff = Diffs.createSetDiff(Sets.newHashSet(match), Collections.EMPTY_SET);
- fireSetChange(diff);
+ final SetDiff diff = Diffs.createSetDiff(Sets.newHashSet(match), Collections.EMPTY_SET);
+ Realm realm = getRealm();
+ Assert.isNotNull(realm, "Data binding Realm must not be null");
+ realm.exec(new Runnable() {
+
+ @Override
+ public void run() {
+ fireSetChange(diff);
+ }
+ });
}
@SuppressWarnings("unchecked")
@Override
public void removeMatch(Match match) {
cache.remove(match);
- SetDiff diff = Diffs.createSetDiff(Collections.EMPTY_SET, Sets.newHashSet(match));
- fireSetChange(diff);
+ final SetDiff diff = Diffs.createSetDiff(Collections.EMPTY_SET, Sets.newHashSet(match));
+ Realm realm = getRealm();
+ Assert.isNotNull(realm, "Data binding Realm must not be null");
+ realm.exec(new Runnable() {
+
+ @Override
+ public void run() {
+ fireSetChange(diff);
+ }
+ });
}
}