Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Scholz2016-05-11 22:23:47 +0000
committerSimon Scholz2016-05-11 22:23:47 +0000
commit4b5dc694f17a21124a619b566be2dbe9cf99a909 (patch)
tree1ddc62a7f8d91906b2d0a17884ab7b430f2c5d7b
parent6e0d761d8b018adcae1d3547826935bc3ab64c4b (diff)
downloadeclipse.platform.ui-4b5dc694f17a21124a619b566be2dbe9cf99a909.tar.gz
eclipse.platform.ui-4b5dc694f17a21124a619b566be2dbe9cf99a909.tar.xz
eclipse.platform.ui-4b5dc694f17a21124a619b566be2dbe9cf99a909.zip
Bug 478611 - [DataBinding] Create snippets for the SideEffect classI20160511-2000
Change-Id: If1a8ac154a890d2d51e8ee2a37ef7072c6a5719a Signed-off-by: Simon Scholz <simon.scholz@vogella.com>
-rw-r--r--examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/SnippetSideEffectTwoWayBinding.java20
1 files changed, 8 insertions, 12 deletions
diff --git a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/SnippetSideEffectTwoWayBinding.java b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/SnippetSideEffectTwoWayBinding.java
index fc1eb4749d3..eadb2ddd765 100644
--- a/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/SnippetSideEffectTwoWayBinding.java
+++ b/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/SnippetSideEffectTwoWayBinding.java
@@ -13,10 +13,12 @@ package org.eclipse.jface.examples.databinding.snippets;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.sideeffect.ISideEffect;
+import org.eclipse.core.databinding.observable.sideeffect.ISideEffectFactory;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.jface.databinding.swt.DisplayRealm;
-import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.databinding.swt.WidgetSideEffects;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
@@ -121,19 +123,13 @@ public class SnippetSideEffectTwoWayBinding {
private void bindData() {
- // create the observables, which should be bound by the SideEffect
- ISWTObservableValue textModifyObservable = WidgetProperties.text(SWT.Modify).observe(summaryText);
+ ISideEffectFactory sideEffectFactory = WidgetSideEffects.createFactory(summaryText);
- ISideEffect modelToTarget = ISideEffect.create(task::getSummary, summaryText::setText);
- ISideEffect targetToModel = ISideEffect.create(() -> (String) textModifyObservable.getValue(),
- task::setSummary);
+ // create the observables, which should be bound by the SideEffect
+ IObservableValue<String> textModifyObservable = WidgetProperties.text(SWT.Modify).observe(summaryText);
- // dispose the ISideEffect objects, when the widget of the
- // ISWTObservableValue is disposed
- textModifyObservable.getWidget().addDisposeListener(e -> {
- modelToTarget.dispose();
- targetToModel.dispose();
- });
+ sideEffectFactory.create(task::getSummary, summaryText::setText);
+ sideEffectFactory.create(textModifyObservable::getValue, task::setSummary);
}
}

Back to the top