Bug 539001: Update databinding code to current standards
Change-Id: I3c4a962353c87dda32ace71e4d95624b46e79c95
diff --git a/eclient/org.eclipse.statet.rj.eclient.graphics/src/org/eclipse/statet/rj/eclient/graphics/RGraphicsPreferencePage.java b/eclient/org.eclipse.statet.rj.eclient.graphics/src/org/eclipse/statet/rj/eclient/graphics/RGraphicsPreferencePage.java
index d09542c..0ab1735 100644
--- a/eclient/org.eclipse.statet.rj.eclient.graphics/src/org/eclipse/statet/rj/eclient/graphics/RGraphicsPreferencePage.java
+++ b/eclient/org.eclipse.statet.rj.eclient.graphics/src/org/eclipse/statet/rj/eclient/graphics/RGraphicsPreferencePage.java
@@ -23,7 +23,7 @@
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.observable.Realm;
-import org.eclipse.core.databinding.observable.value.IValueChangeListener;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.runtime.IStatus;
@@ -32,7 +32,7 @@
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.databinding.swt.SWTObservables;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.ArrayContentProvider;
@@ -184,8 +184,8 @@
private Text customVDpiControl;
private boolean customEnabled;
- private WritableValue customHDpiVisibleValue;
- private WritableValue customVDpiVisibleValue;
+ private IObservableValue<Double> customHDpiVisibleValue;
+ private IObservableValue<Double> customVDpiVisibleValue;
private double customHDpiUserValue;
private double customVDpiUserValue;
@@ -392,44 +392,42 @@
addBindings(this.dbc, realm);
final AggregateValidationStatus validationStatus= new AggregateValidationStatus(this.dbc, AggregateValidationStatus.MAX_SEVERITY);
- validationStatus.addValueChangeListener(new IValueChangeListener() {
- @Override
- public void handleValueChange(final ValueChangeEvent event) {
- final IStatus currentStatus= (IStatus) event.diff.getNewValue();
- updateStatus(currentStatus);
- }
- });
+ validationStatus.addValueChangeListener(
+ (final ValueChangeEvent<? extends IStatus> event) -> {
+ final IStatus currentStatus= event.diff.getNewValue();
+ updateStatus(currentStatus);
+ } );
}
protected void addBindings(final DataBindingContext dbc, final Realm realm) {
- this.customHDpiVisibleValue= new WritableValue(realm, 96.0, Double.class);
- this.customVDpiVisibleValue= new WritableValue(realm, 96.0, Double.class);
+ this.customHDpiVisibleValue= new WritableValue<>(realm, 96.0, Double.class);
+ this.customVDpiVisibleValue= new WritableValue<>(realm, 96.0, Double.class);
- dbc.bindValue(SWTObservables.observeText(this.customHDpiControl, SWT.Modify),
+ dbc.bindValue(
+ WidgetProperties.text(SWT.Modify).observe(this.customHDpiControl),
this.customHDpiVisibleValue,
new UpdateValueStrategy().setAfterGetValidator(new DecimalValidator(10.0, 10000.0,
- "The value for Horizontal (x) DPI is invalid (10-10000)." )), null);
- dbc.bindValue(SWTObservables.observeText(this.customVDpiControl, SWT.Modify),
+ "The value for Horizontal (x) DPI is invalid (10-10000)." )),
+ null );
+ dbc.bindValue(
+ WidgetProperties.text(SWT.Modify).observe(this.customVDpiControl),
this.customVDpiVisibleValue,
new UpdateValueStrategy().setAfterGetValidator(new DecimalValidator(10.0, 10000.0,
- "The value for Vertical (x) DPI is invalid (10-10000)." )), null);
+ "The value for Vertical (x) DPI is invalid (10-10000)." )),
+ null );
- this.customHDpiVisibleValue.addValueChangeListener(new IValueChangeListener() {
- @Override
- public void handleValueChange(final ValueChangeEvent event) {
- if (RGraphicsPreferencePage.this.customEnabled) {
- RGraphicsPreferencePage.this.customHDpiUserValue= (Double) RGraphicsPreferencePage.this.customHDpiVisibleValue.getValue();
- }
- }
- });
- this.customVDpiVisibleValue.addValueChangeListener(new IValueChangeListener() {
- @Override
- public void handleValueChange(final ValueChangeEvent event) {
- if (RGraphicsPreferencePage.this.customEnabled) {
- RGraphicsPreferencePage.this.customVDpiUserValue= (Double) RGraphicsPreferencePage.this.customVDpiVisibleValue.getValue();
- }
- }
- });
+ this.customHDpiVisibleValue.addValueChangeListener(
+ (final ValueChangeEvent<? extends Double> event) -> {
+ if (RGraphicsPreferencePage.this.customEnabled) {
+ RGraphicsPreferencePage.this.customHDpiUserValue= RGraphicsPreferencePage.this.customHDpiVisibleValue.getValue();
+ }
+ } );
+ this.customVDpiVisibleValue.addValueChangeListener(
+ (final ValueChangeEvent<? extends Double> event) -> {
+ if (RGraphicsPreferencePage.this.customEnabled) {
+ RGraphicsPreferencePage.this.customVDpiUserValue= RGraphicsPreferencePage.this.customVDpiVisibleValue.getValue();
+ }
+ } );
}
protected void updateStatus(final IStatus status) {