From f6aed7e562d9bb8668d087c939ff98b8036e3111 Mon Sep 17 00:00:00 2001 From: Simon Barner <barner@fortiss.org> Date: Thu, 4 Oct 2018 10:15:53 +0200 Subject: [PATCH] SWTObservables.observeText() -> DataBindingUtils.observeText() * SWTObservables is deprecated * Add drop-in replacement of observeText() in DataBindingUtils that uses the new API Issue-Ref: 3539 Issue-Url: https://af3-developer.fortiss.org/issues/3539 Signed-off-by: Simon Barner <barner@fortiss.org> --- .../META-INF/MANIFEST.MF | 3 ++- .../kernel/ui/internal/properties/.ratings | 4 ++-- .../properties/IdLabeledPropertySection.java | 5 +++-- .../NamedCommentedPropertySection.java | 9 ++++---- .../fortiss/tooling/kernel/ui/util/.ratings | 2 +- .../kernel/ui/util/DataBindingUtils.java | 21 +++++++++++++++++-- 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/org.fortiss.tooling.kernel.ui/META-INF/MANIFEST.MF b/org.fortiss.tooling.kernel.ui/META-INF/MANIFEST.MF index 5af477991..d893684a7 100644 --- a/org.fortiss.tooling.kernel.ui/META-INF/MANIFEST.MF +++ b/org.fortiss.tooling.kernel.ui/META-INF/MANIFEST.MF @@ -7,7 +7,8 @@ Bundle-Activator: org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator Require-Bundle: org.fortiss.tooling.common.ui;bundle-version="2.14.0";visibility:=reexport, org.fortiss.tooling.kernel;bundle-version="2.14.0";visibility:=reexport, org.eclipse.core.resources;visibility:=reexport, - org.eclipse.emf.databinding;visibility:=reexport + org.eclipse.emf.databinding;visibility:=reexport, + org.eclipse.core.databinding.property;visibility:=reexport Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-Vendor: fortiss GmbH diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/properties/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/properties/.ratings index 63a110c81..0a4a80307 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/properties/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/properties/.ratings @@ -1,3 +1,3 @@ -IdLabeledPropertySection.java 9a419c0aa35c0ab02b38ec769cbd69cea99e66ca RED -NamedCommentedPropertySection.java 0327480eb54090508758ce1d3a97da9fde93cf0f RED +IdLabeledPropertySection.java dcfb39d225391c87f47e29f6d1ba1cb22a3d3fe4 YELLOW +NamedCommentedPropertySection.java d15d490708e5c7362ebc4f30a04bccb0f6b64f39 YELLOW PropertiesAdapterFactory.java edcf34766a60f21c9ba22a1ba73aa487c3d9a946 YELLOW diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/properties/IdLabeledPropertySection.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/properties/IdLabeledPropertySection.java index 9a419c0aa..dcfb39d22 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/properties/IdLabeledPropertySection.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/properties/IdLabeledPropertySection.java @@ -15,8 +15,9 @@ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.ui.internal.properties; +import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.observeText; + import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.jface.databinding.swt.SWTObservables; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; @@ -61,6 +62,6 @@ public class IdLabeledPropertySection extends PropertySectionBase { IObservableValue<?> modelObservable = ObservableUtils.observeValue(idLabeled, FortissToolingKernelPackage.Literals.IID_LABELED__ID); - dbc.bindValue(SWTObservables.observeText(idText, SWT.None), modelObservable, null, null); + dbc.bindValue(observeText(idText, SWT.None), modelObservable, null, null); } } diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/properties/NamedCommentedPropertySection.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/properties/NamedCommentedPropertySection.java index 0327480eb..d15d49070 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/properties/NamedCommentedPropertySection.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/properties/NamedCommentedPropertySection.java @@ -15,9 +15,10 @@ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.ui.internal.properties; +import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.observeText; + import org.eclipse.core.databinding.observable.value.IObservableValue; import org.eclipse.emf.ecore.EObject; -import org.eclipse.jface.databinding.swt.SWTObservables; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; @@ -89,12 +90,10 @@ public class NamedCommentedPropertySection extends PropertySectionBase { IObservableValue<?> modelObservable = ObservableUtils.observeValue(namedCommented, FortissToolingKernelPackage.Literals.INAMED_ELEMENT__NAME); - dbc.bindValue(SWTObservables.observeText(nameText, SWT.Modify), modelObservable, null, - null); + dbc.bindValue(observeText(nameText, SWT.Modify), modelObservable, null, null); modelObservable = ObservableUtils.observeValue(namedCommented, FortissToolingKernelPackage.Literals.INAMED_COMMENTED_ELEMENT__COMMENT); - dbc.bindValue(SWTObservables.observeText(commentText, SWT.Modify), modelObservable, null, - null); + dbc.bindValue(observeText(commentText, SWT.Modify), modelObservable, null, null); // Set focus on "name" text editor and pre-select everything in case a RenameAction is in // progress. diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/util/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/util/.ratings index 0f4e43e66..2e07492f8 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/util/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/util/.ratings @@ -1,7 +1,7 @@ ActionUtils.java 4553e487264e3d1f86f4767da4a7400cce4b9a5d GREEN ConstraintsUIUtils.java 69d5e08bbf768baf2790380e36f1020ef826a33e GREEN CopyPasteUtils.java bbc5cf9c9dc03ebf8dc75d42c919fe6eb60b388e GREEN -DataBindingUtils.java 4c2fc0bab9e9ea739411aa42f4a4393f1393396e RED +DataBindingUtils.java 6ae66457694227b69c13c092ef62babdd4a2a137 YELLOW DragAndDropUtils.java 7aab91518aa12d76533a345bf6ed0be9ac7ff0e5 GREEN EObjectSelectionUtils.java 128cf8f96c6b9478171dff3deda662d5934f5f44 YELLOW KernelUIUtils.java 46d3279ef3523b104f89a6c526109f72d36f72f2 GREEN diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/util/DataBindingUtils.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/util/DataBindingUtils.java index 4c2fc0bab..6ae664576 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/util/DataBindingUtils.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/util/DataBindingUtils.java @@ -15,8 +15,6 @@ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.ui.util; -import static org.eclipse.jface.databinding.swt.SWTObservables.observeText; - import org.conqat.ide.commons.ui.databinding.JFaceObservables; import org.eclipse.core.databinding.Binding; import org.eclipse.core.databinding.DataBindingContext; @@ -26,6 +24,8 @@ import org.eclipse.core.databinding.observable.value.IObservableValue; import org.eclipse.core.databinding.validation.IValidator; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.jface.databinding.swt.ISWTObservableValue; +import org.eclipse.jface.databinding.swt.WidgetProperties; import org.eclipse.jface.fieldassist.ControlDecoration; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Control; @@ -203,6 +203,23 @@ public final class DataBindingUtils { return bindings; } + /** + * Returns an {@link ISWTObservableValue} observing this value property on + * the given {@link Control}. + * + * @param event + * the SWT event type to register for change events. May be + * {@link SWT#None}, {@link SWT#Modify}, {@link SWT#FocusOut} or + * {@link SWT#DefaultSelection}. + * @param control + * the source {@link Control} + * @return an observable value observing this value property on the given + * widget + */ + public static ISWTObservableValue observeText(Control control, final int event) { + return WidgetProperties.text(event).observe(control); + } + /** * Performs a complex binding of a cell editor control to a model element. The * validation is performed on modification (i.e. always), while model -- GitLab