From c44f8d77f42cbcc17a0da3daabbb16bcd8745a86 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Thu, 8 Sep 2022 11:10:56 +0200 Subject: [PATCH] Deletion of databinding api marked for deletion The following databinding classes will be removed. They have been obsolete since the databinding framework was transitioned to work with property classes in 2014. They are replaced by corresponding property factory classes. See bug 546820. org.eclipse.jface.databinding.viewers.ViewersObservables org.eclipse.jface.databinding.swt.SWTObservables org.eclipse.core.databinding.beans.BeansObservables org.eclipse.core.databinding.beans.PojoObservables org.eclipse.ui.databinding.WorkbenchObservables The following classes in the databinding bundles will be removed. They are replaced by typed factory classes with the same name, but in a sub-package that is called "typed". See bug 546822. org.eclipse.ui.databinding.WorkbenchProperties org.eclipse.core.databinding.beans.BeanProperties org.eclipse.core.databinding.beans.PojoProperties org.eclipse.jface.databinding.viewers.ViewerProperties org.eclipse.jface.databinding.swt.WidgetProperties Includes API filter for the affected plug-ins as we do not increase major version due to API deletion. --- .../.settings/.api_filters | 46 + .../databinding/beans/BeanProperties.java | 410 ------- .../databinding/beans/BeansObservables.java | 1018 ----------------- .../databinding/beans/PojoObservables.java | 889 -------------- .../databinding/beans/PojoProperties.java | 416 ------- .../.settings/.api_filters | 46 + .../jface/databinding/swt/SWTObservables.java | 604 ---------- .../databinding/swt/WidgetProperties.java | 332 ------ .../databinding/viewers/ViewerProperties.java | 131 --- .../viewers/ViewersObservables.java | 344 ------ .../.settings/.api_filters | 34 + .../ui/databinding/WorkbenchObservables.java | 177 --- .../ui/databinding/WorkbenchProperties.java | 125 -- .../org/eclipse/ui/databinding/package.html | 17 - .../META-INF/MANIFEST.MF | 1 - bundles/org.eclipse.ui/.settings/.api_filters | 19 + 16 files changed, 145 insertions(+), 4464 deletions(-) delete mode 100644 bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/BeanProperties.java delete mode 100644 bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/BeansObservables.java delete mode 100644 bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/PojoObservables.java delete mode 100644 bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/PojoProperties.java delete mode 100644 bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/swt/SWTObservables.java delete mode 100644 bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/swt/WidgetProperties.java delete mode 100644 bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/viewers/ViewerProperties.java delete mode 100644 bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/viewers/ViewersObservables.java create mode 100644 bundles/org.eclipse.ui.workbench/.settings/.api_filters delete mode 100644 bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/databinding/WorkbenchObservables.java delete mode 100644 bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/databinding/WorkbenchProperties.java delete mode 100644 bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/databinding/package.html create mode 100644 bundles/org.eclipse.ui/.settings/.api_filters diff --git a/bundles/org.eclipse.core.databinding.beans/.settings/.api_filters b/bundles/org.eclipse.core.databinding.beans/.settings/.api_filters index a0654db314b..d8141c4e01b 100644 --- a/bundles/org.eclipse.core.databinding.beans/.settings/.api_filters +++ b/bundles/org.eclipse.core.databinding.beans/.settings/.api_filters @@ -1,5 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/BeanProperties.java b/bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/BeanProperties.java deleted file mode 100644 index 601661b0863..00000000000 --- a/bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/BeanProperties.java +++ /dev/null @@ -1,410 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2016 Matthew Hall and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Matthew Hall - initial API and implementation (bug 194734) - * Matthew Hall - bug 195222, 247997, 261843, 264307 - * Lars Vogel - Bug 488364 - ******************************************************************************/ - -package org.eclipse.core.databinding.beans; - -import java.beans.PropertyDescriptor; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.databinding.property.list.IListProperty; -import org.eclipse.core.databinding.property.map.IMapProperty; -import org.eclipse.core.databinding.property.set.ISetProperty; -import org.eclipse.core.databinding.property.value.IValueProperty; -import org.eclipse.core.internal.databinding.beans.AnonymousBeanListProperty; -import org.eclipse.core.internal.databinding.beans.AnonymousBeanMapProperty; -import org.eclipse.core.internal.databinding.beans.AnonymousBeanSetProperty; -import org.eclipse.core.internal.databinding.beans.AnonymousBeanValueProperty; -import org.eclipse.core.internal.databinding.beans.BeanListProperty; -import org.eclipse.core.internal.databinding.beans.BeanListPropertyDecorator; -import org.eclipse.core.internal.databinding.beans.BeanMapProperty; -import org.eclipse.core.internal.databinding.beans.BeanMapPropertyDecorator; -import org.eclipse.core.internal.databinding.beans.BeanPropertyHelper; -import org.eclipse.core.internal.databinding.beans.BeanSetProperty; -import org.eclipse.core.internal.databinding.beans.BeanSetPropertyDecorator; -import org.eclipse.core.internal.databinding.beans.BeanValueProperty; -import org.eclipse.core.internal.databinding.beans.BeanValuePropertyDecorator; - -/** - * A factory for creating properties for Java objects that conform to the - * JavaBean - * specification for bound properties. - * - * @noreference - * @deprecated This class will be removed in a future release. See - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=546822 for more - * information. It has been replaced by the class - * {@link org.eclipse.core.databinding.beans.typed.BeanProperties}. - * That class creates typed property objects, while this class - * creates raw property objects. - * - * @since 1.2 - */ -@Deprecated -@SuppressWarnings({ "rawtypes", "unchecked" }) -public class BeanProperties { - /** - * Returns a value property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains null. - * - * @param propertyName - * the property name. May be nested e.g. "parent.name" - * @return a value property for the given property name of an arbitrary bean - * class. - */ - public static IBeanValueProperty value(String propertyName) { - return value(null, propertyName, null); - } - - /** - * Returns a value property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains null. - * - * @param propertyName - * the property name. May be nested e.g. "parent.name" - * @param valueType - * the value type of the returned value property - * @return a value property for the given property name of an arbitrary bean - * class. - */ - public static IBeanValueProperty value(String propertyName, Class valueType) { - return value(null, propertyName, valueType); - } - - /** - * Returns a value property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name. May be nested e.g. "parent.name" - * @return a value property for the given property name of the given bean - * class. - */ - public static IBeanValueProperty value(Class beanClass, String propertyName) { - return value(beanClass, propertyName, null); - } - - /** - * Returns a value property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name. May be nested e.g. "parent.name" - * @param valueType - * the value type of the returned value property - * @return a value property for the given property name of the given bean - * class. - */ - public static IBeanValueProperty value(Class beanClass, String propertyName, Class valueType) { - String[] propertyNames = split(propertyName); - if (propertyNames.length > 1) - valueType = null; - - PropertyDescriptor propertyDescriptor; - IValueProperty property; - if (beanClass == null) { - propertyDescriptor = null; - property = new AnonymousBeanValueProperty(propertyNames[0], - valueType); - } else { - propertyDescriptor = BeanPropertyHelper.getPropertyDescriptor( - beanClass, propertyNames[0]); - property = new BeanValueProperty(propertyDescriptor, valueType); - } - - IBeanValueProperty beanProperty = new BeanValuePropertyDecorator( - property, propertyDescriptor); - for (int i = 1; i < propertyNames.length; i++) { - beanProperty = beanProperty.value(propertyNames[i]); - } - return beanProperty; - } - - private static String[] split(String propertyName) { - if (propertyName.indexOf('.') == -1) - return new String[] { propertyName }; - List propertyNames = new ArrayList(); - int index; - while ((index = propertyName.indexOf('.')) != -1) { - propertyNames.add(propertyName.substring(0, index)); - propertyName = propertyName.substring(index + 1); - } - propertyNames.add(propertyName); - return (String[]) propertyNames - .toArray(new String[propertyNames.size()]); - } - - /** - * Returns a value property array for the given property names of the given - * bean class. - * - * @param beanClass - * the bean class - * @param propertyNames - * defines the property names. May be nested e.g. "parent.name" - * @return a value property array for the given property names of the given - * bean class. - */ - public static IBeanValueProperty[] values(Class beanClass, String... propertyNames) { - IBeanValueProperty[] properties = new IBeanValueProperty[propertyNames.length]; - for (int i = 0; i < properties.length; i++) - properties[i] = value(beanClass, propertyNames[i], null); - return properties; - } - - /** - * Returns a value property array for the given property names of an - * arbitrary bean class. - * - * @param propertyNames - * defines the property names. May be nested e.g. "parent.name" - * @return a value property array for the given property names of the given - * bean class. - */ - public static IBeanValueProperty[] values(String... propertyNames) { - return values(null, propertyNames); - } - - /** - * Returns a set property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains an empty set. - * - * @param propertyName - * the property name - * @return a set property for the given property name of an arbitrary bean - * class. - */ - public static IBeanSetProperty set(String propertyName) { - return set(null, propertyName, null); - } - - /** - * Returns a set property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains an empty set. - * - * @param propertyName - * the property name - * @param elementType - * the element type of the returned set property - * @return a set property for the given property name of an arbitrary bean - * class. - */ - public static IBeanSetProperty set(String propertyName, Class elementType) { - return set(null, propertyName, elementType); - } - - /** - * Returns a set property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name - * @return a set property for the given property name of the given bean - * class. - */ - public static IBeanSetProperty set(Class beanClass, String propertyName) { - return set(beanClass, propertyName, null); - } - - /** - * Returns a set property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name - * @param elementType - * the element type of the returned set property - * @return a set property for the given property name of the given bean - * class. - */ - public static IBeanSetProperty set(Class beanClass, String propertyName, - Class elementType) { - PropertyDescriptor propertyDescriptor; - ISetProperty property; - if (beanClass == null) { - propertyDescriptor = null; - property = new AnonymousBeanSetProperty(propertyName, elementType); - } else { - propertyDescriptor = BeanPropertyHelper.getPropertyDescriptor( - beanClass, propertyName); - property = new BeanSetProperty(propertyDescriptor, elementType); - } - return new BeanSetPropertyDecorator(property, propertyDescriptor); - } - - /** - * Returns a list property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains an empty list. - * - * @param propertyName - * the property name - * @return a list property for the given property name of an arbitrary bean - * class. - */ - public static IBeanListProperty list(String propertyName) { - return list(null, propertyName, null); - } - - /** - * Returns a list property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains an empty list. - * - * @param propertyName - * the property name - * @param elementType - * the element type of the returned list property - * @return a list property for the given property name of the given bean - * class. - */ - public static IBeanListProperty list(String propertyName, Class elementType) { - return list(null, propertyName, elementType); - } - - /** - * Returns a list property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name - * @return a list property for the given property name of the given bean - * class. - */ - public static IBeanListProperty list(Class beanClass, String propertyName) { - return list(beanClass, propertyName, null); - } - - /** - * Returns a list property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name - * @param elementType - * the element type of the returned list property - * @return a list property for the given property name of the given bean - * class. - */ - public static IBeanListProperty list(Class beanClass, String propertyName, - Class elementType) { - PropertyDescriptor propertyDescriptor; - IListProperty property; - if (beanClass == null) { - propertyDescriptor = null; - property = new AnonymousBeanListProperty(propertyName, elementType); - } else { - propertyDescriptor = BeanPropertyHelper.getPropertyDescriptor( - beanClass, propertyName); - property = new BeanListProperty(propertyDescriptor, elementType); - } - return new BeanListPropertyDecorator(property, propertyDescriptor); - } - - /** - * Returns a map property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains an empty map. - * - * @param propertyName - * the property name - * @return a map property for the given property name of an arbitrary bean - * class. - */ - public static IBeanMapProperty map(String propertyName) { - return map(null, propertyName, null, null); - } - - /** - * Returns a map property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains an empty map. - * - * @param propertyName - * the property name - * @param keyType - * the key type for the returned map property - * @param valueType - * the value type for the returned map property - * @return a map property for the given property name of an arbitrary bean - * class. - */ - public static IBeanMapProperty map(String propertyName, Class keyType, Class valueType) { - return map(null, propertyName, keyType, valueType); - } - - /** - * Returns a map property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name - * @return a map property for the given property name of the given bean - * class. - */ - public static IBeanMapProperty map(Class beanClass, String propertyName) { - return map(beanClass, propertyName, null, null); - } - - /** - * Returns a map property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name - * @param keyType - * the key type for the returned map property - * @param valueType - * the value type for the returned map property - * @return a map property for the given property name of the given bean - * class. - */ - public static IBeanMapProperty map(Class beanClass, String propertyName, Class keyType, Class valueType) { - PropertyDescriptor propertyDescriptor; - IMapProperty property; - if (beanClass == null) { - propertyDescriptor = null; - property = new AnonymousBeanMapProperty(propertyName, keyType, - valueType); - } else { - propertyDescriptor = BeanPropertyHelper.getPropertyDescriptor( - beanClass, propertyName); - property = new BeanMapProperty(propertyDescriptor, keyType, - valueType); - } - return new BeanMapPropertyDecorator(property, propertyDescriptor); - } -} diff --git a/bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/BeansObservables.java b/bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/BeansObservables.java deleted file mode 100644 index 4d3b4a61007..00000000000 --- a/bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/BeansObservables.java +++ /dev/null @@ -1,1018 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2017 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Brad Reynolds - bugs 164268, 171616, 147515 - * Matthew Hall - bug 221704, 234686, 246625, 226289, 246782, 194734, - * 195222, 247997 - * Thomas Kratz - bug 213787 - * Lars Vogel - Bug 443399 - *******************************************************************************/ -package org.eclipse.core.databinding.beans; - -import java.beans.PropertyDescriptor; - -import org.eclipse.core.databinding.beans.typed.BeanProperties; -import org.eclipse.core.databinding.observable.Realm; -import org.eclipse.core.databinding.observable.list.IObservableList; -import org.eclipse.core.databinding.observable.map.IObservableMap; -import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory; -import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables; -import org.eclipse.core.databinding.observable.set.IObservableSet; -import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.core.databinding.util.Policy; -import org.eclipse.core.internal.databinding.beans.BeanObservableListDecorator; -import org.eclipse.core.internal.databinding.beans.BeanObservableMapDecorator; -import org.eclipse.core.internal.databinding.beans.BeanObservableSetDecorator; -import org.eclipse.core.internal.databinding.beans.BeanObservableValueDecorator; -import org.eclipse.core.internal.databinding.beans.BeanPropertyHelper; -import org.eclipse.core.internal.databinding.beans.Util; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -/** - * A factory for creating observable objects of Java objects that conform to the - * JavaBean - * specification for bound properties. - * - * @since 1.1 - * - * @noreference - * @deprecated This class will be removed in a future release. See - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=546820 for more - * information. Use BeanProperties instead. - */ -@Deprecated -@SuppressWarnings({ "rawtypes", "unchecked" }) -final public class BeansObservables { - - /** - * - */ - public static final boolean DEBUG = true; - - /** - * Returns an observable value in the default realm tracking the current - * value of the named property of the given bean. - * - * @param bean - * the object - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @return an observable value tracking the current value of the named - * property of the given bean - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableValue observeValue(Object bean, String propertyName) { - return observeValue(Realm.getDefault(), bean, propertyName); - } - - /** - * Returns an observable value in the given realm tracking the current value - * of the named property of the given bean. - * - * @param realm - * the realm - * @param bean - * the object - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @return an observable value tracking the current value of the named - * property of the given bean - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableValue observeValue(Realm realm, Object bean, - String propertyName) { - return BeanProperties.value((Class) bean.getClass(), propertyName).observe(realm, bean); - } - - /** - * Returns an observable map in the given observable set's realm tracking - * the current values of the named property for the beans in the given set. - * Elements in the set which do not have the named property will have null - * values, and attempts to {@link IObservableMap#put(Object, Object) put} - * values to these elements will be ignored. - * - * @param domain - * the set of bean objects - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @return an observable map tracking the current values of the named - * property for the beans in the given domain set - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableMap observeMap(IObservableSet domain, - String propertyName) { - return BeanProperties.value(propertyName).observeDetail(domain); - } - - /** - * Returns an observable map in the given observable set's realm tracking - * the current values of the named property for the beans in the given set. - * - * @param domain - * the set of bean objects - * @param beanClass - * the common base type of bean objects that may be in the set - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @return an observable map tracking the current values of the named - * property for the beans in the given domain set - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableMap observeMap(IObservableSet domain, - Class beanClass, String propertyName) { - return BeanProperties.value(beanClass, propertyName).observeDetail( - domain); - } - - /** - * Returns an observable map in the given realm tracking the map-typed named - * property of the given bean object. - * - * @param realm - * the realm - * @param bean - * the bean object - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @return an observable map tracking the map-typed named property of the - * given bean object - * @since 1.1 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableMap observeMap(Realm realm, Object bean, - String propertyName) { - return observeMap(realm, bean, propertyName, null, null); - } - - /** - * Returns an observable map in the given realm tracking the map-typed named - * property of the given bean object. - * - * @param realm - * the realm - * @param bean - * the bean object - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @param keyType - * the element type of the observable map's key set, or - * null if untyped - * @param valueType - * the element type of the observable map's values collection, or - * null if untyped - * @return an observable map tracking the map-typed named property of the - * given bean object - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableMap observeMap(Realm realm, Object bean, - String propertyName, Class keyType, Class valueType) { - return BeanProperties.map(bean.getClass(), propertyName, keyType, - valueType).observe(realm, bean); - } - - /** - * Returns an observable map in the default realm tracking the map-typed - * named property of the given bean object. - * - * @param bean - * the bean object - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @return an observable map tracking the map-typed named property of the - * given bean object - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableMap observeMap(Object bean, String propertyName) { - return observeMap(Realm.getDefault(), bean, propertyName, null, null); - } - - /** - * Returns an observable map in the default realm tracking the map-typed - * named property of the given bean object. - * - * @param bean - * the bean object - * @param propertyName - * the name of the property - * @param keyType - * the element type of the observable map's key set, or - * null if untyped - * @param valueType - * the element type of the observable map's values collection, or - * null if untyped - * @return an observable map tracking the map-typed named property of the - * given bean object - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableMap observeMap(Object bean, String propertyName, - Class keyType, Class valueType) { - return observeMap(Realm.getDefault(), bean, propertyName, keyType, - valueType); - } - - /** - * Returns an array of observable maps in the given observable set's realm - * tracking the current values of the named properties for the beans in the - * given set. Elements in the set which do not have the named property will - * have null values, and attempts to - * {@link IObservableMap#put(Object, Object) put} values to these elements - * will be ignored. - * - * @param domain - * the set of objects - * @param propertyNames - * the array of property names. May be nested e.g. "parent.name" - * @return an array of observable maps tracking the current values of the - * named propertys for the beans in the given domain set - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableMap[] observeMaps(IObservableSet domain, - String[] propertyNames) { - IObservableMap[] result = new IObservableMap[propertyNames.length]; - for (int i = 0; i < propertyNames.length; i++) { - result[i] = observeMap(domain, propertyNames[i]); - } - return result; - } - - /** - * Returns an array of observable maps in the given observable set's realm - * tracking the current values of the named properties for the beans in the - * given set. - * - * @param domain - * the set of objects - * @param beanClass - * the common base type of objects that may be in the set - * @param propertyNames - * the array of property names. May be nested e.g. "parent.name" - * @return an array of observable maps tracking the current values of the - * named propertys for the beans in the given domain set - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableMap[] observeMaps(IObservableSet domain, - Class beanClass, String[] propertyNames) { - IObservableMap[] result = new IObservableMap[propertyNames.length]; - for (int i = 0; i < propertyNames.length; i++) { - result[i] = observeMap(domain, beanClass, propertyNames[i]); - } - return result; - } - - /** - * Returns an observable list in the given realm tracking the - * collection-typed named property of the given bean object. The returned - * list is mutable. - * - * @param realm - * the realm - * @param bean - * the object - * @param propertyName - * the name of the collection-typed property - * @return an observable list tracking the collection-typed named property - * of the given bean object - * @see #observeList(Realm, Object, String, Class) - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableList observeList(Realm realm, Object bean, - String propertyName) { - return observeList(realm, bean, propertyName, null); - } - - /** - * Returns an observable list in the default realm tracking the - * collection-typed named property of the given bean object. The returned - * list is mutable. - * - * @param bean - * the object - * @param propertyName - * the name of the collection-typed property - * @return an observable list tracking the collection-typed named property - * of the given bean object - * @see #observeList(Realm, Object, String, Class) - * @since 1.2 - */ - public static IObservableList observeList(Object bean, String propertyName) { - return observeList(Realm.getDefault(), bean, propertyName); - } - - /** - * Returns an observable list in the given realm tracking the - * collection-typed named property of the given bean object. The returned - * list is mutable. When an item is added or removed the setter is invoked - * for the list on the parent bean to provide notification to other - * listeners via PropertyChangeEvents. This is done to provide - * the same behavior as is expected from arrays as specified in the bean - * spec in section 7.2. - * - * @param realm - * the realm - * @param bean - * the bean object - * @param propertyName - * the name of the property - * @param elementType - * type of the elements in the list. If null and the - * property is an array the type will be inferred. If - * null and the property type cannot be inferred - * element type will be null. - * @return an observable list tracking the collection-typed named property - * of the given bean object - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableList observeList(Realm realm, Object bean, - String propertyName, Class elementType) { - return BeanProperties.list(bean.getClass(), propertyName, elementType) - .observe(realm, bean); - } - - /** - * Returns an observable list in the default realm tracking the - * collection-typed named property of the given bean object. The returned - * list is mutable. When an item is added or removed the setter is invoked - * for the list on the parent bean to provide notification to other - * listeners via PropertyChangeEvents. This is done to provide - * the same behavior as is expected from arrays as specified in the bean - * spec in section 7.2. - * - * @param bean - * the bean object - * @param propertyName - * the name of the property - * @param elementType - * type of the elements in the list. If null and the - * property is an array the type will be inferred. If - * null and the property type cannot be inferred - * element type will be null. - * @return an observable list tracking the collection-typed named property - * of the given bean object - * @since 1.2 - */ - public static IObservableList observeList(Object bean, String propertyName, - Class elementType) { - return observeList(Realm.getDefault(), bean, propertyName, elementType); - } - - /** - * Returns an observable set in the given realm tracking the - * collection-typed named property of the given bean object - * - * @param realm - * the realm - * @param bean - * the bean object - * @param propertyName - * the name of the property - * @return an observable set tracking the collection-typed named property of - * the given bean object - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableSet observeSet(Realm realm, Object bean, - String propertyName) { - return observeSet(realm, bean, propertyName, null); - } - - /** - * Returns an observable set in the default realm tracking the - * collection-typed named property of the given bean object - * - * @param bean - * the bean object - * @param propertyName - * the name of the property - * @return an observable set tracking the collection-typed named property of - * the given bean object - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableSet observeSet(Object bean, String propertyName) { - return observeSet(Realm.getDefault(), bean, propertyName); - } - - /** - * Returns a factory for creating observable values in the given realm, - * tracking the given property of a particular bean object - * - * @param realm - * the realm to use - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @return an observable value factory - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableFactory valueFactory(final Realm realm, - final String propertyName) { - return BeanProperties.value(propertyName).valueFactory(realm); - } - - /** - * Returns a factory for creating observable values in the current default - * realm, tracking the given property of a particular bean object - * - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @return an observable value factory - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableFactory valueFactory(String propertyName) { - return valueFactory(Realm.getDefault(), propertyName); - } - - /** - * Returns a factory for creating observable lists in the given realm, - * tracking the given property of a particular bean object - * - * @param realm - * the realm to use - * @param propertyName - * the name of the property - * @param elementType the element type of the returned list property - * @return an observable list factory - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableFactory listFactory(final Realm realm, - final String propertyName, final Class elementType) { - return BeanProperties.list(propertyName, elementType) - .listFactory(realm); - } - - /** - * Returns a factory for creating observable lists in the current default - * realm, tracking the given property of a particular bean object - * - * @param propertyName - * the name of the property - * @param elementType the element type of the returned list property - * @return an observable list factory - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableFactory listFactory(String propertyName, - Class elementType) { - return listFactory(Realm.getDefault(), propertyName, elementType); - } - - /** - * Returns a factory for creating observable sets in the given realm, - * tracking the given property of a particular bean object - * - * @param realm - * the realm to use - * @param propertyName - * the name of the property - * @return an observable set factory - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableFactory setFactory(final Realm realm, - final String propertyName) { - return BeanProperties.set(propertyName).setFactory(realm); - } - - /** - * Returns a factory for creating observable sets in the current default - * realm, tracking the given property of a particular bean object - * - * @param propertyName - * the name of the property - * @return an observable set factory - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableFactory setFactory(String propertyName) { - return setFactory(Realm.getDefault(), propertyName); - } - - /** - * Helper method for - * MasterDetailObservables.detailValue(master, valueFactory(realm, - propertyName), propertyType) - * - * @param realm the realm - * @param master the observable value to track - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @param propertyType - * can be null - * @return an observable value that tracks the current value of the named - * property for the current value of the master observable value - * - * @see MasterDetailObservables - * - * @deprecated Use - * {@link #observeDetailValue(IObservableValue, String, Class)} - * instead - */ - @Deprecated - public static IObservableValue observeDetailValue(Realm realm, - IObservableValue master, String propertyName, Class propertyType) { - warnIfDifferentRealms(realm, master.getRealm()); - - IObservableValue value = MasterDetailObservables.detailValue( - master, - BeanProperties.value(propertyName, propertyType).valueFactory( - realm), propertyType); - return new BeanObservableValueDecorator(value, - BeanPropertyHelper.getValueTypePropertyDescriptor(master, - propertyName)); - } - - /* package */static void warnIfDifferentRealms(Realm detailRealm, - Realm masterRealm) { - if (!Util.equals(detailRealm, masterRealm)) { - Throwable throwable = new Throwable(); - throwable.fillInStackTrace(); - String message = "Detail realm (" + detailRealm //$NON-NLS-1$ - + ") not equal to master realm (" //$NON-NLS-1$ - + masterRealm + ")"; //$NON-NLS-1$ - Policy.getLog().log( - new Status(IStatus.WARNING, Policy.JFACE_DATABINDING, - message, throwable)); - } - } - - /** - * Helper method for - * MasterDetailObservables.detailValue(master, valueFactory(master.getRealm(), propertyName), propertyType) - * - * @param master the master observable value - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @param propertyType - * can be null - * @return an observable value that tracks the current value of the named - * property for the current value of the master observable value - * - * @see MasterDetailObservables - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableValue observeDetailValue(IObservableValue master, - String propertyName, Class propertyType) { - Class beanClass = null; - if (master.getValueType() instanceof Class) - beanClass = (Class) master.getValueType(); - return observeDetailValue(master, beanClass, propertyName, propertyType); - } - - /** - * Helper method for - * MasterDetailObservables.detailValue(master, valueFactory(realm, - * propertyName), propertyType). This method returns an - * {@link IBeanObservable} with a {@link PropertyDescriptor} based on the - * given master type and property name. - * - * @param realm - * the realm - * @param master - * the master observable value, for example tracking the - * selection in a list - * @param masterType - * the type of the master observable value - * @param propertyName - * the property name. May be nested e.g. "parent.name" - * @param propertyType - * can be null - * @return an observable value that tracks the current value of the named - * property for the current value of the master observable value - * - * @see MasterDetailObservables - * @since 1.1 - * @deprecated Use - * {@link #observeDetailValue(IObservableValue, Class, String, Class)} - * instead. - */ - @Deprecated - public static IObservableValue observeDetailValue(Realm realm, - IObservableValue master, Class masterType, String propertyName, - Class propertyType) { - warnIfDifferentRealms(realm, master.getRealm()); - Assert.isNotNull(masterType, "masterType cannot be null"); //$NON-NLS-1$ - IObservableValue value = MasterDetailObservables.detailValue(master, - BeanProperties.value(masterType, propertyName, propertyType) - .valueFactory(realm), propertyType); - return new BeanObservableValueDecorator(value, - BeanPropertyHelper.getPropertyDescriptor(masterType, - propertyName)); - } - - /** - * Helper method for - * MasterDetailObservables.detailValue(master, valueFactory(master.getRealm(), propertyName), propertyType) - * . This method returns an {@link IBeanObservable} with a - * {@link PropertyDescriptor} based on the given master type and property - * name. - * - * @param master - * the master observable value, for example tracking the - * selection in a list - * @param masterType - * the type of the master observable value - * @param propertyName - * the property name. May be nested e.g. "parent.name" - * @param propertyType - * can be null - * @return an observable value that tracks the current value of the named - * property for the current value of the master observable value - * - * @see MasterDetailObservables - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableValue observeDetailValue(IObservableValue master, - Class masterType, String propertyName, Class propertyType) { - return BeanProperties.value(masterType, propertyName, propertyType) - .observeDetail(master); - } - - /** - * Helper method for - * MasterDetailObservables.detailList(master, listFactory(realm, - propertyName, propertyType), propertyType) - * - * @param realm the realm - * @param master the observable value to track - * @param propertyName the property name - * @param propertyType - * can be null - * @return an observable list that tracks the named property for the current - * value of the master observable value - * - * @see MasterDetailObservables - * @deprecated Use - * {@link #observeDetailList(IObservableValue, String, Class)} - * instead - */ - @Deprecated - public static IObservableList observeDetailList(Realm realm, - IObservableValue master, String propertyName, Class propertyType) { - warnIfDifferentRealms(realm, master.getRealm()); - IObservableList observableList = MasterDetailObservables.detailList( - master, BeanProperties.list(propertyName, propertyType) - .listFactory(realm), propertyType); - return new BeanObservableListDecorator(observableList, - BeanPropertyHelper.getValueTypePropertyDescriptor(master, - propertyName)); - } - - /** - * Helper method for - * MasterDetailObservables.detailList(master, listFactory(master.getRealm(), propertyName, propertyType), propertyType) - * - * @param master the master observable value - * @param propertyName the property name - * @param propertyType - * can be null - * @return an observable list that tracks the named property for the current - * value of the master observable value - * - * @see MasterDetailObservables - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableList observeDetailList(IObservableValue master, - String propertyName, Class propertyType) { - Class beanClass = null; - if (master.getValueType() instanceof Class) - beanClass = (Class) master.getValueType(); - return BeanProperties.list(beanClass, propertyName, propertyType) - .observeDetail(master); - } - - /** - * Helper method for - * MasterDetailObservables.detailSet(master, setFactory(realm, - propertyName), propertyType) - * - * @param realm the realm - * @param master the observable value - * @param propertyName the property name - * @param propertyType - * can be null - * @return an observable set that tracks the named property for the current - * value of the master observable value - * - * @see MasterDetailObservables - * @deprecated Use - * {@link #observeDetailSet(IObservableValue, String, Class)} - * instead. - */ - @Deprecated - public static IObservableSet observeDetailSet(Realm realm, - IObservableValue master, String propertyName, Class propertyType) { - warnIfDifferentRealms(realm, master.getRealm()); - - IObservableSet observableSet = MasterDetailObservables.detailSet( - master, BeanProperties.set(propertyName, propertyType) - .setFactory(realm), propertyType); - return new BeanObservableSetDecorator(observableSet, - BeanPropertyHelper.getValueTypePropertyDescriptor(master, - propertyName)); - } - - /** - * Helper method for - * MasterDetailObservables.detailSet(master, setFactory(master.getRealm(), propertyName), propertyType) - * - * @param master the observable value - * @param propertyName the property name - * @param propertyType - * can be null - * @return an observable set that tracks the named property for the current - * value of the master observable value - * - * @see MasterDetailObservables - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableSet observeDetailSet(IObservableValue master, - String propertyName, Class propertyType) { - Class beanClass = null; - if (master.getValueType() instanceof Class) - beanClass = (Class) master.getValueType(); - return BeanProperties.set(beanClass, propertyName, propertyType) - .observeDetail(master); - } - - /** - * Helper method for - * MasterDetailObservables.detailMap(master, mapFactory(realm, propertyName)) - * - * @param realm - * the realm - * @param master the observable value - * @param propertyName name of the property - * @return an observable map that tracks the map-type named property for the - * current value of the master observable value. - * @since 1.1 - * @deprecated Use {@link #observeDetailMap(IObservableValue, String)} - * instead - */ - @Deprecated - public static IObservableMap observeDetailMap(Realm realm, - IObservableValue master, String propertyName) { - warnIfDifferentRealms(realm, master.getRealm()); - IObservableMap observableMap = MasterDetailObservables.detailMap( - master, BeanProperties.map(propertyName).mapFactory(realm)); - return new BeanObservableMapDecorator(observableMap, - BeanPropertyHelper.getValueTypePropertyDescriptor(master, - propertyName)); - } - - /** - * Helper method for - * MasterDetailObservables.detailMap(master, mapFactory(master.getRealm(), propertyName)) - * - * @param master the observable value - * @param propertyName the property name - * @return an observable map that tracks the map-type named property for the - * current value of the master observable value. - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableMap observeDetailMap(IObservableValue master, - String propertyName) { - Class beanClass = null; - if (master.getValueType() instanceof Class) - beanClass = (Class) master.getValueType(); - return BeanProperties.map(beanClass, propertyName) - .observeDetail(master); - } - - /** - * Returns an observable set in the given realm tracking the - * collection-typed named property of the given bean object. The returned - * set is mutable. When an item is added or removed the setter is invoked - * for the set on the parent bean to provide notification to other listeners - * via PropertyChangeEvents. This is done to provide the same - * behavior as is expected from arrays as specified in the bean spec in - * section 7.2. - * - * @param realm - * the realm - * @param bean - * the bean object - * @param propertyName - * the name of the property - * @param elementType - * type of the elements in the set. If null and the - * property is an array the type will be inferred. If - * null and the property type cannot be inferred - * element type will be null. - * @return an observable set tracking the collection-typed named property of - * the given bean object - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableSet observeSet(Realm realm, Object bean, - String propertyName, Class elementType) { - return BeanProperties.set(bean.getClass(), propertyName, elementType) - .observe(realm, bean); - } - - /** - * Returns an observable set in the current default realm tracking the - * collection-typed named property of the given bean object. The returned - * set is mutable. When an item is added or removed the setter is invoked - * for the set on the parent bean to provide notification to other listeners - * via PropertyChangeEvents. This is done to provide the same - * behavior as is expected from arrays as specified in the bean spec in - * section 7.2. - * - * @param bean - * the bean object - * @param propertyName - * the name of the property - * @param elementType - * type of the elements in the set. If null and the - * property is an array the type will be inferred. If - * null and the property type cannot be inferred - * element type will be null. - * @return an observable set tracking the collection-typed named property of - * the given bean object - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableSet observeSet(Object bean, String propertyName, - Class elementType) { - return observeSet(Realm.getDefault(), bean, propertyName, elementType); - } - - /** - * Returns a factory for creating observable sets in the given realm, - * tracking the given property of a particular bean object - * - * @param realm - * the realm to use - * @param propertyName - * the name of the property - * @param elementType - * type of the elements in the set. If null and the - * property is an array the type will be inferred. If - * null and the property type cannot be inferred - * element type will be null. - * @return a factory for creating observable sets in the given realm, - * tracking the given property of a particular bean object - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableFactory setFactory(final Realm realm, - final String propertyName, final Class elementType) { - return BeanProperties.set(propertyName, elementType).setFactory(realm); - } - - /** - * Returns a factory for creating observable sets in the current default - * realm, tracking the given property of a particular bean object - * - * @param propertyName - * the name of the property - * @param elementType - * type of the elements in the set. If null and the - * property is an array the type will be inferred. If - * null and the property type cannot be inferred - * element type will be null. - * @return a factory for creating observable sets in the given realm, - * tracking the given property of a particular bean object - * @since 1.2 - */ - public static IObservableFactory setFactory(String propertyName, - Class elementType) { - return setFactory(Realm.getDefault(), propertyName, elementType); - } - - /** - * Returns a factory for creating an observable map. The factory, when - * provided with an {@link IObservableSet}, will create an - * {@link IObservableMap} in the same realm as the underlying set that - * tracks the current values of the named property for the beans in the - * given set. - * - * @param beanClass - * the common base type of bean objects that may be in the set - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @return a factory for creating {@link IObservableMap} objects - * - * @since 1.1 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableFactory setToMapFactory(final Class beanClass, - final String propertyName) { - return target -> observeMap((IObservableSet) target, beanClass, propertyName); - } - - /** - * Returns a factory for creating an observable map. The factory, when - * provided with a bean object, will create an {@link IObservableMap} in the - * given realm that tracks the map-typed named property for the specified - * bean. - * - * @param realm - * the realm assigned to observables created by the returned - * factory. - * @param propertyName - * the name of the property - * @return a factory for creating {@link IObservableMap} objects. - * @since 1.1 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableFactory mapPropertyFactory(final Realm realm, - final String propertyName) { - return BeanProperties.map(propertyName).mapFactory(realm); - } - - /** - * Returns a factory for creating an observable map. The factory, when - * provided with a bean object, will create an {@link IObservableMap} in the - * current default realm that tracks the map-typed named property for the - * specified bean. - * - * @param propertyName - * the name of the property - * @return a factory for creating {@link IObservableMap} objects. - * @since 1.2 - * - * @deprecated use BeanProperties instead - */ - @Deprecated - public static IObservableFactory mapPropertyFactory(String propertyName) { - return mapPropertyFactory(Realm.getDefault(), propertyName); - } -} diff --git a/bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/PojoObservables.java b/bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/PojoObservables.java deleted file mode 100644 index b1216d32893..00000000000 --- a/bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/PojoObservables.java +++ /dev/null @@ -1,889 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Matthew Hall - bugs 221704, 234686, 246625, 226289, 246782, 194734, - * 195222, 247997 - *******************************************************************************/ - -package org.eclipse.core.databinding.beans; - -import java.beans.PropertyChangeEvent; - -import org.eclipse.core.databinding.beans.typed.PojoProperties; -import org.eclipse.core.databinding.observable.Realm; -import org.eclipse.core.databinding.observable.list.IObservableList; -import org.eclipse.core.databinding.observable.map.IObservableMap; -import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory; -import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables; -import org.eclipse.core.databinding.observable.set.IObservableSet; -import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.core.internal.databinding.beans.BeanObservableListDecorator; -import org.eclipse.core.internal.databinding.beans.BeanObservableMapDecorator; -import org.eclipse.core.internal.databinding.beans.BeanObservableSetDecorator; -import org.eclipse.core.internal.databinding.beans.BeanObservableValueDecorator; -import org.eclipse.core.internal.databinding.beans.BeanPropertyHelper; - -/** - * A factory for creating observable objects for POJOs (plain old java objects) - * that conform to idea of an object with getters and setters but does not - * provide {@link PropertyChangeEvent property change events} on change. This - * factory is identical to {@link BeansObservables} except for this fact. - * - * @since 1.1 - * - * @noreference - * @deprecated This class will be removed in a future release. See - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=546820 for more - * information. Use PojoProperties instead. - */ -@Deprecated -@SuppressWarnings({ "rawtypes", "unchecked" }) -final public class PojoObservables { - - /** - * Returns an observable value in the default realm tracking the current - * value of the named property of the given pojo. - * - * @param pojo - * the object - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @return an observable value tracking the current value of the named - * property of the given pojo - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableValue observeValue(Object pojo, String propertyName) { - return observeValue(Realm.getDefault(), pojo, propertyName); - } - - /** - * Returns an observable value in the given realm tracking the current value - * of the named property of the given pojo. - * - * @param realm - * the realm - * @param pojo - * the object - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @return an observable value tracking the current value of the named - * property of the given pojo - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableValue observeValue(Realm realm, Object pojo, String propertyName) { - return PojoProperties.value((Class) pojo.getClass(), propertyName).observe(realm, pojo); - } - - /** - * Returns an observable map in the given observable set's realm tracking - * the current values of the named property for the beans in the given set. - * Elements in the set which do not have the named property will have null - * values, and attempts to {@link IObservableMap#put(Object, Object) put} - * values to these elements will be ignored. - * - * @param domain - * the set of bean objects - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @return an observable map tracking the current values of the named - * property for the beans in the given domain set - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableMap observeMap(IObservableSet domain, - String propertyName) { - return PojoProperties.value(propertyName).observeDetail(domain); - } - - /** - * Returns an observable map in the given observable set's realm tracking - * the current values of the named property for the pojos in the given set. - * - * @param domain - * the set of pojo objects - * @param pojoClass - * the common base type of pojo objects that may be in the set - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @return an observable map tracking the current values of the named - * property for the pojos in the given domain set - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableMap observeMap(IObservableSet domain, - Class pojoClass, String propertyName) { - return PojoProperties.value(pojoClass, propertyName).observeDetail( - domain); - } - - /** - * Returns an array of observable maps in the given observable set's realm - * tracking the current values of the named properties for the beans in the - * given set. Elements in the set which do not have the named property will - * have null values, and attempts to - * {@link IObservableMap#put(Object, Object) put} values to these elements - * will be ignored. - * - * @param domain - * the set of objects - * @param propertyNames - * the array of property names. May be nested e.g. "parent.name" - * @return an array of observable maps tracking the current values of the - * named propertys for the beans in the given domain set - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableMap[] observeMaps(IObservableSet domain, - String[] propertyNames) { - IObservableMap[] result = new IObservableMap[propertyNames.length]; - for (int i = 0; i < propertyNames.length; i++) { - result[i] = observeMap(domain, propertyNames[i]); - } - return result; - } - - /** - * Returns an array of observable maps in the given observable set's realm - * tracking the current values of the named propertys for the pojos in the - * given set. - * - * @param domain - * the set of objects - * @param pojoClass - * the common base type of objects that may be in the set - * @param propertyNames - * the array of property names. May be nested e.g. "parent.name" - * @return an array of observable maps tracking the current values of the - * named propertys for the pojos in the given domain set - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableMap[] observeMaps(IObservableSet domain, - Class pojoClass, String[] propertyNames) { - IObservableMap[] result = new IObservableMap[propertyNames.length]; - for (int i = 0; i < propertyNames.length; i++) { - result[i] = observeMap(domain, pojoClass, propertyNames[i]); - } - return result; - } - - /** - * Returns an observable map in the given realm tracking the map-typed named - * property of the given pojo object. - * - * @param realm - * the realm - * @param pojo - * the pojo object - * @param propertyName - * the name of the property - * @return an observable map tracking the map-typed named property of the - * given pojo object - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableMap observeMap(Realm realm, Object pojo, - String propertyName) { - return observeMap(realm, pojo, propertyName, null, null); - } - - /** - * Returns an observable map in the given realm tracking the map-typed named - * property of the given pojo object. - * - * @param realm - * the realm - * @param pojo - * the pojo object - * @param propertyName - * the name of the property - * @param keyType - * the element type of the observable map's key set, or - * null if untyped - * @param valueType - * the element type of the observable map's values collection, or - * null if untyped - * @return an observable map tracking the map-typed named property of the - * given pojo object - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableMap observeMap(Realm realm, Object pojo, - String propertyName, Class keyType, Class valueType) { - return PojoProperties.map(pojo.getClass(), propertyName, keyType, - valueType).observe(realm, pojo); - } - - /** - * Returns an observable map in the default realm tracking the map-typed - * named property of the given pojo object. - * - * @param pojo - * the pojo object - * @param propertyName - * the name of the property - * @return an observable map tracking the map-typed named property of the - * given pojo object - * @since 1.2 - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableMap observeMap(Object pojo, String propertyName) { - return observeMap(Realm.getDefault(), pojo, propertyName, null, null); - } - - /** - * Returns an observable map in the default realm tracking the map-typed - * named property of the given pojo object. - * - * @param pojo - * the pojo object - * @param propertyName - * the name of the property - * @param keyType - * the element type of the observable map's key set, or - * null if untyped - * @param valueType - * the element type of the observable map's values collection, or - * null if untyped - * @return an observable map tracking the map-typed named property of the - * given pojo object - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableMap observeMap(Object pojo, String propertyName, - Class keyType, Class valueType) { - return observeMap(Realm.getDefault(), pojo, propertyName, keyType, - valueType); - } - - /** - * Returns an observable list in the given realm tracking the - * collection-typed named property of the given pojo object. The returned - * list is mutable. - * - * @param realm - * the realm - * @param pojo - * the object - * @param propertyName - * the name of the collection-typed property - * @return an observable list tracking the collection-typed named property - * of the given pojo object - * @see #observeList(Realm, Object, String, Class) - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableList observeList(Realm realm, Object pojo, - String propertyName) { - return observeList(realm, pojo, propertyName, null); - } - - /** - * Returns an observable list in the default realm tracking the - * collection-typed named property of the given pojo object. The returned - * list is mutable. - * - * @param pojo - * the object - * @param propertyName - * the name of the collection-typed property - * @return an observable list tracking the collection-typed named property - * of the given pojo object - * @see #observeList(Realm, Object, String, Class) - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableList observeList(Object pojo, String propertyName) { - return observeList(Realm.getDefault(), pojo, propertyName); - } - - /** - * Returns an observable list in the given realm tracking the - * collection-typed named property of the given bean object. The returned - * list is mutable. When an item is added or removed the setter is invoked - * for the list on the parent bean to provide notification to other - * listeners via PropertyChangeEvents. This is done to provide - * the same behavior as is expected from arrays as specified in the bean - * spec in section 7.2. - * - * @param realm - * the realm - * @param pojo - * the bean object - * @param propertyName - * the name of the property - * @param elementType - * type of the elements in the list. If null and the - * property is an array the type will be inferred. If - * null and the property type cannot be inferred - * element type will be null. - * @return an observable list tracking the collection-typed named property - * of the given bean object - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableList observeList(Realm realm, Object pojo, - String propertyName, Class elementType) { - return PojoProperties.list(pojo.getClass(), propertyName, elementType) - .observe(realm, pojo); - } - - /** - * Returns an observable list in the default realm tracking the - * collection-typed named property of the given bean object. The returned - * list is mutable. When an item is added or removed the setter is invoked - * for the list on the parent bean to provide notification to other - * listeners via PropertyChangeEvents. This is done to provide - * the same behavior as is expected from arrays as specified in the bean - * spec in section 7.2. - * - * @param pojo - * the bean object - * @param propertyName - * the name of the property - * @param elementType - * type of the elements in the list. If null and the - * property is an array the type will be inferred. If - * null and the property type cannot be inferred - * element type will be null. - * @return an observable list tracking the collection-typed named property - * of the given bean object - * @since 1.2 - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableList observeList(Object pojo, String propertyName, - Class elementType) { - return observeList(Realm.getDefault(), pojo, propertyName, elementType); - } - - /** - * Returns an observable set in the given realm tracking the - * collection-typed named property of the given pojo object. - * - * @param realm - * the realm - * @param pojo - * the pojo object - * @param propertyName - * the name of the property - * @return an observable set tracking the collection-typed named property of - * the given pojo object - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableSet observeSet(Realm realm, Object pojo, - String propertyName) { - return observeSet(realm, pojo, propertyName, null); - } - - /** - * Returns an observable set in the default realm tracking the - * collection-typed named property of the given pojo object. - * - * @param pojo - * the pojo object - * @param propertyName - * the name of the property - * @return an observable set tracking the collection-typed named property of - * the given pojo object - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableSet observeSet(Object pojo, String propertyName) { - return observeSet(Realm.getDefault(), pojo, propertyName); - } - - /** - * Returns an observable set in the given realm tracking the - * collection-typed named property of the given pojo object. - * - * @param realm - * the realm - * @param pojo - * the pojo object - * @param propertyName - * the name of the property - * @param elementType - * type of the elements in the set. If null and the - * property is an array the type will be inferred. If - * null and the property type cannot be inferred - * element type will be null. - * @return an observable set that tracks the current value of the named - * property for given pojo object - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableSet observeSet(Realm realm, Object pojo, - String propertyName, Class elementType) { - return PojoProperties.set(pojo.getClass(), propertyName, elementType) - .observe(realm, pojo); - } - - /** - * Returns an observable set in the default realm, tracking the - * collection-typed named property of the given pojo object. - * - * @param pojo - * the pojo object - * @param propertyName - * the name of the property - * @param elementType - * type of the elements in the set. If null and the - * property is an array the type will be inferred. If - * null and the property type cannot be inferred - * element type will be null. - * @return an observable set that tracks the current value of the named - * property for given pojo object - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableSet observeSet(Object pojo, String propertyName, - Class elementType) { - return observeSet(Realm.getDefault(), pojo, propertyName, elementType); - } - - /** - * Returns a factory for creating observable values in the given realm, - * tracking the given property of a particular pojo object - * - * @param realm - * the realm to use - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @return an observable value factory - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableFactory valueFactory(final Realm realm, - final String propertyName) { - return PojoProperties.value(propertyName).valueFactory(realm); - } - - /** - * Returns a factory for creating observable values in the current default - * realm, tracking the given property of a particular pojo object - * - * @param propertyName - * the name of the property. May be nested e.g. "parent.name" - * @return an observable value factory - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableFactory valueFactory(String propertyName) { - return valueFactory(Realm.getDefault(), propertyName); - } - - /** - * Returns a factory for creating observable lists in the given realm, - * tracking the given property of a particular pojo object - * - * @param realm - * the realm to use - * @param propertyName - * the name of the property - * @param elementType the element type of the returned list property - * @return an observable list factory - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableFactory listFactory(final Realm realm, - final String propertyName, final Class elementType) { - return PojoProperties.list(propertyName, elementType) - .listFactory(realm); - } - - /** - * Returns a factory for creating observable lists in the current default - * realm, tracking the given property of a particular pojo object - * - * @param propertyName - * the name of the property - * @param elementType the element type of the returned list property - * @return an observable list factory - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableFactory listFactory(String propertyName, - Class elementType) { - return listFactory(Realm.getDefault(), propertyName, elementType); - } - - /** - * Returns a factory for creating observable sets in the given realm, - * tracking the given property of a particular pojo object - * - * @param realm - * the realm to use - * @param propertyName - * the name of the property - * @return an observable set factory - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableFactory setFactory(final Realm realm, - final String propertyName) { - return PojoProperties.set(propertyName).setFactory(realm); - } - - /** - * Returns a factory for creating observable sets in the current default - * realm, tracking the given property of a particular pojo object - * - * @param propertyName - * the name of the property - * @return an observable set factory - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableFactory setFactory(String propertyName) { - return setFactory(Realm.getDefault(), propertyName); - } - - /** - * Returns a factory for creating observable set in the given realm, - * tracking the given property of a particular pojo object - * - * @param realm - * the realm to use - * @param propertyName - * the name of the property - * @param elementType - * type of the elements in the set. If null and the - * property is an array the type will be inferred. If - * null and the property type cannot be inferred - * element type will be null. - * @return an observable set factory for creating observable sets - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableFactory setFactory(final Realm realm, - final String propertyName, final Class elementType) { - return PojoProperties.set(propertyName, elementType).setFactory(realm); - } - - /** - * Returns a factory for creating observable set in the current default - * realm, tracking the given property of a particular pojo object - * - * @param propertyName - * the name of the property - * @param elementType - * type of the elements in the set. If null and the - * property is an array the type will be inferred. If - * null and the property type cannot be inferred - * element type will be null. - * @return an observable set factory for creating observable sets - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableFactory setFactory(String propertyName, - Class elementType) { - return setFactory(Realm.getDefault(), propertyName, elementType); - } - - /** - * Returns a factory for creating an observable map. The factory, when - * provided with a pojo object, will create an {@link IObservableMap} in the - * given realm that tracks the map-typed named property for the specified - * pojo. - * - * @param realm - * the realm assigned to observables created by the returned - * factory. - * @param propertyName - * the name of the property - * @return a factory for creating {@link IObservableMap} objects. - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableFactory mapPropertyFactory(final Realm realm, - final String propertyName) { - return PojoProperties.map(propertyName).mapFactory(realm); - } - - /** - * Returns a factory for creating an observable map. The factory, when - * provided with a pojo object, will create an {@link IObservableMap} in the - * current default realm that tracks the map-typed named property for the - * specified pojo. - * - * @param propertyName - * the name of the property - * @return a factory for creating {@link IObservableMap} objects. - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableFactory mapPropertyFactory(String propertyName) { - return mapPropertyFactory(Realm.getDefault(), propertyName); - } - - /** - * Helper method for - * MasterDetailObservables.detailValue(master, valueFactory(realm, - propertyName), propertyType) - * - * @param realm the realm - * @param master the master observable value - * @param propertyName - * the property name. May be nested e.g. "parent.name" - * @param propertyType - * can be null - * @return an observable value that tracks the current value of the named - * property for the current value of the master observable value - * - * @see MasterDetailObservables - * @deprecated Use - * {@link #observeDetailValue(IObservableValue, String, Class)} - * instead - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableValue observeDetailValue(Realm realm, - IObservableValue master, String propertyName, Class propertyType) { - BeansObservables.warnIfDifferentRealms(realm, master.getRealm()); - - IObservableValue value = MasterDetailObservables.detailValue( - master, - PojoProperties.value(propertyName, propertyType).valueFactory( - realm), propertyType); - return new BeanObservableValueDecorator(value, - BeanPropertyHelper.getValueTypePropertyDescriptor(master, - propertyName)); - } - - /** - * Helper method for - * MasterDetailObservables.detailValue(master, valueFactory(master.getRealm, propertyName), propertyType) - * - * @param master the master observable value - * @param propertyName - * the property name. May be nested e.g. "parent.name" - * @param propertyType - * can be null - * @return an observable value that tracks the current value of the named - * property for the current value of the master observable value - * - * @see MasterDetailObservables - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableValue observeDetailValue(IObservableValue master, - String propertyName, Class propertyType) { - Class pojoClass = null; - if (master.getValueType() instanceof Class) - pojoClass = (Class) master.getValueType(); - return PojoProperties.value(pojoClass, propertyName, propertyType) - .observeDetail(master); - } - - /** - * Helper method for - * MasterDetailObservables.detailList(master, listFactory(realm, - propertyName, propertyType), propertyType) - * - * @param realm the realm - * @param master the observable value - * @param propertyName name of the property - * @param propertyType - * can be null - * @return an observable list that tracks the named property for the current - * value of the master observable value - * - * @see MasterDetailObservables - * @deprecated Use - * {@link #observeDetailList(IObservableValue, String, Class)} - * instead - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableList observeDetailList(Realm realm, - IObservableValue master, String propertyName, Class propertyType) { - BeansObservables.warnIfDifferentRealms(realm, master.getRealm()); - IObservableList observableList = MasterDetailObservables.detailList( - master, PojoProperties.list(propertyName, propertyType) - .listFactory(realm), propertyType); - return new BeanObservableListDecorator(observableList, - BeanPropertyHelper.getValueTypePropertyDescriptor(master, - propertyName)); - } - - /** - * Helper method for - * MasterDetailObservables.detailList(master, listFactory(master.getRealm(), propertyName, propertyType), propertyType) - * - * @param master the master observable value - * @param propertyName name of the property - * @param propertyType - * can be null - * @return an observable list that tracks the named property for the current - * value of the master observable value - * - * @see MasterDetailObservables - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableList observeDetailList(IObservableValue master, - String propertyName, Class propertyType) { - Class pojoClass = null; - if (master.getValueType() instanceof Class) - pojoClass = (Class) master.getValueType(); - return PojoProperties.list(pojoClass, propertyName).observeDetail( - master); - } - - /** - * Helper method for - * MasterDetailObservables.detailSet(master, setFactory(realm, - propertyName), propertyType) - * - * @param realm the realm - * @param master the master observable value - * @param propertyName the property name - * @param propertyType - * can be null - * @return an observable set that tracks the named property for the current - * value of the master observable value - * - * @see MasterDetailObservables - * @deprecated Use - * {@link #observeDetailSet(IObservableValue, String, Class)} - * instead. - */ - @Deprecated - public static IObservableSet observeDetailSet(Realm realm, - IObservableValue master, String propertyName, Class propertyType) { - BeansObservables.warnIfDifferentRealms(realm, master.getRealm()); - - IObservableSet observableSet = MasterDetailObservables.detailSet( - master, PojoProperties.set(propertyName, propertyType) - .setFactory(realm), propertyType); - return new BeanObservableSetDecorator(observableSet, - BeanPropertyHelper.getValueTypePropertyDescriptor(master, - propertyName)); - } - - /** - * Helper method for - * MasterDetailObservables.detailSet(master, setFactory(master.getRealm(), propertyName), propertyType) - * - * @param master the observable value - * @param propertyName the property name - * @param propertyType - * can be null - * @return an observable set that tracks the named property for the current - * value of the master observable value - * - * @see MasterDetailObservables - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableSet observeDetailSet(IObservableValue master, - String propertyName, Class propertyType) { - Class pojoClass = null; - if (master.getValueType() instanceof Class) - pojoClass = (Class) master.getValueType(); - return PojoProperties.set(pojoClass, propertyName, propertyType) - .observeDetail(master); - } - - /** - * Helper method for - * MasterDetailObservables.detailMap(master, mapFactory(realm, propertyName)) - * - * @param realm the realm - * @param master the observable value - * @param propertyName name of the property - * @return an observable map that tracks the map-type named property for the - * current value of the master observable value. - * @deprecated Use {@link #observeDetailMap(IObservableValue, String)} - * instead - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableMap observeDetailMap(Realm realm, - IObservableValue master, String propertyName) { - BeansObservables.warnIfDifferentRealms(realm, master.getRealm()); - IObservableMap observableMap = MasterDetailObservables.detailMap( - master, PojoProperties.map(propertyName).mapFactory(realm)); - return new BeanObservableMapDecorator(observableMap, - BeanPropertyHelper.getValueTypePropertyDescriptor(master, - propertyName)); - } - - /** - * Helper method for - * MasterDetailObservables.detailMap(master, mapFactory(master.getRealm(), propertyName)) - * - * @param master the master observable value - * @param propertyName name of the property - * @return an observable map that tracks the map-type named property for the - * current value of the master observable value. - * @since 1.2 - * - * @deprecated use PojoProperties instead - */ - @Deprecated - public static IObservableMap observeDetailMap(IObservableValue master, - String propertyName) { - Class pojoClass = null; - if (master.getValueType() instanceof Class) - pojoClass = (Class) master.getValueType(); - return PojoProperties.map(pojoClass, propertyName) - .observeDetail(master); - } -} diff --git a/bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/PojoProperties.java b/bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/PojoProperties.java deleted file mode 100644 index 2fbaf0872f5..00000000000 --- a/bundles/org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/PojoProperties.java +++ /dev/null @@ -1,416 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2015 Matthew Hall and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Matthew Hall - initial API and implementation (bug 194734) - * Matthew Hall - bug 195222, 247997, 261843, 264307 - ******************************************************************************/ - -package org.eclipse.core.databinding.beans; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyDescriptor; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.databinding.property.list.IListProperty; -import org.eclipse.core.databinding.property.map.IMapProperty; -import org.eclipse.core.databinding.property.set.ISetProperty; -import org.eclipse.core.databinding.property.value.IValueProperty; -import org.eclipse.core.internal.databinding.beans.AnonymousPojoListProperty; -import org.eclipse.core.internal.databinding.beans.AnonymousPojoMapProperty; -import org.eclipse.core.internal.databinding.beans.AnonymousPojoSetProperty; -import org.eclipse.core.internal.databinding.beans.AnonymousPojoValueProperty; -import org.eclipse.core.internal.databinding.beans.BeanPropertyHelper; -import org.eclipse.core.internal.databinding.beans.PojoListProperty; -import org.eclipse.core.internal.databinding.beans.PojoListPropertyDecorator; -import org.eclipse.core.internal.databinding.beans.PojoMapProperty; -import org.eclipse.core.internal.databinding.beans.PojoMapPropertyDecorator; -import org.eclipse.core.internal.databinding.beans.PojoSetProperty; -import org.eclipse.core.internal.databinding.beans.PojoSetPropertyDecorator; -import org.eclipse.core.internal.databinding.beans.PojoValueProperty; -import org.eclipse.core.internal.databinding.beans.PojoValuePropertyDecorator; - -/** - * A factory for creating properties for POJOs (plain old java objects) that - * conform to idea of an object with getters and setters but does not provide - * {@link PropertyChangeEvent property change events} on change. This factory is - * identical to {@link BeanProperties} except for this fact. - * - * @noreference - * @deprecated This class will be removed in a future release. See - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=546822 for more - * information. It has been replaced by the class - * {@link org.eclipse.core.databinding.beans.typed.PojoProperties}. - * That class creates typed property objects, while this class - * creates raw property objects. - * - * @since 1.2 - */ -@Deprecated -@SuppressWarnings({ "rawtypes", "unchecked" }) -public class PojoProperties { - /** - * Returns a value property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains null. - * - * @param propertyName - * the property name. May be nested e.g. "parent.name" - * @return a value property for the given property name of an arbitrary bean - * class. - */ - public static IBeanValueProperty value(String propertyName) { - return value(null, propertyName, null); - } - - /** - * Returns a value property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains null. - * - * @param propertyName - * the property name. May be nested e.g. "parent.name" - * @param valueType - * the value type of the returned value property - * @return a value property for the given property name of an arbitrary bean - * class. - */ - public static IBeanValueProperty value(String propertyName, Class valueType) { - return value(null, propertyName, valueType); - } - - /** - * Returns a value property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name. May be nested e.g. "parent.name" - * @return a value property for the given property name of the given bean - * class. - */ - public static IBeanValueProperty value(Class beanClass, String propertyName) { - return value(beanClass, propertyName, null); - } - - /** - * Returns a value property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name. May be nested e.g. "parent.name" - * @param valueType - * the value type of the returned value property - * @return a value property for the given property name of the given bean - * class. - */ - public static IBeanValueProperty value(Class beanClass, - String propertyName, Class valueType) { - String[] propertyNames = split(propertyName); - if (propertyNames.length > 1) - valueType = null; - - IValueProperty property; - PropertyDescriptor propertyDescriptor; - if (beanClass == null) { - propertyDescriptor = null; - property = new PojoValuePropertyDecorator( - new AnonymousPojoValueProperty(propertyNames[0], valueType), - null); - } else { - propertyDescriptor = BeanPropertyHelper.getPropertyDescriptor( - beanClass, propertyNames[0]); - property = new PojoValueProperty(propertyDescriptor, valueType); - } - - IBeanValueProperty beanProperty = new PojoValuePropertyDecorator( - property, propertyDescriptor); - for (int i = 1; i < propertyNames.length; i++) { - beanProperty = beanProperty.value(propertyNames[i]); - } - return beanProperty; - } - - private static String[] split(String propertyName) { - if (propertyName.indexOf('.') == -1) - return new String[] { propertyName }; - List propertyNames = new ArrayList(); - int index; - while ((index = propertyName.indexOf('.')) != -1) { - propertyNames.add(propertyName.substring(0, index)); - propertyName = propertyName.substring(index + 1); - } - propertyNames.add(propertyName); - return (String[]) propertyNames - .toArray(new String[propertyNames.size()]); - } - - /** - * Returns a value property array for the given property names of the given - * bean class. - * - * @param beanClass - * the bean class - * @param propertyNames - * array of property names. May be nested e.g. "parent.name" - * @return a value property array for the given property names of the given - * bean class. - */ - public static IBeanValueProperty[] values(Class beanClass, - String[] propertyNames) { - IBeanValueProperty[] properties = new IBeanValueProperty[propertyNames.length]; - for (int i = 0; i < properties.length; i++) - properties[i] = value(beanClass, propertyNames[i], null); - return properties; - } - - /** - * Returns a value property array for the given property names of an - * arbitrary bean class. - * - * @param propertyNames - * array of property names. May be nested e.g. "parent.name" - * @return a value property array for the given property names of the given - * bean class. - */ - public static IBeanValueProperty[] values(String... propertyNames) { - return values(null, propertyNames); - } - - /** - * Returns a set property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains an empty set. - * - * @param propertyName - * the property name - * @return a set property for the given property name of an arbitrary bean - * class. - */ - public static IBeanSetProperty set(String propertyName) { - return set(null, propertyName, null); - } - - /** - * Returns a set property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains an empty set. - * - * @param propertyName - * the property name - * @param elementType - * the element type of the returned set property - * @return a set property for the given property name of an arbitrary bean - * class. - */ - public static IBeanSetProperty set(String propertyName, Class elementType) { - return set(null, propertyName, elementType); - } - - /** - * Returns a set property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name - * @return a set property for the given property name of the given bean - * class. - */ - public static IBeanSetProperty set(Class beanClass, String propertyName) { - return set(beanClass, propertyName, null); - } - - /** - * Returns a set property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name - * @param elementType - * the element type of the returned set property - * @return a set property for the given property name of the given bean - * class. - */ - public static IBeanSetProperty set(Class beanClass, String propertyName, - Class elementType) { - PropertyDescriptor propertyDescriptor; - ISetProperty property; - if (beanClass == null) { - propertyDescriptor = null; - property = new AnonymousPojoSetProperty(propertyName, elementType); - } else { - propertyDescriptor = BeanPropertyHelper.getPropertyDescriptor( - beanClass, propertyName); - property = new PojoSetProperty(propertyDescriptor, elementType); - } - return new PojoSetPropertyDecorator(property, propertyDescriptor); - } - - /** - * Returns a list property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains an empty list. - * - * @param propertyName - * the property name - * @return a list property for the given property name of an arbitrary bean - * class. - */ - public static IBeanListProperty list(String propertyName) { - return list(null, propertyName, null); - } - - /** - * Returns a list property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains an empty list. - * - * @param propertyName - * the property name - * @param elementType - * the element type of the returned list property - * @return a list property for the given property name of the given bean - * class. - */ - public static IBeanListProperty list(String propertyName, Class elementType) { - return list(null, propertyName, elementType); - } - - /** - * Returns a list property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name - * @return a list property for the given property name of the given bean - * class. - */ - public static IBeanListProperty list(Class beanClass, String propertyName) { - return list(beanClass, propertyName, null); - } - - /** - * Returns a list property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name - * @param elementType - * the element type of the returned list property - * @return a list property for the given property name of the given bean - * class. - */ - public static IBeanListProperty list(Class beanClass, String propertyName, - Class elementType) { - PropertyDescriptor propertyDescriptor; - IListProperty property; - if (beanClass == null) { - propertyDescriptor = null; - property = new AnonymousPojoListProperty(propertyName, elementType); - } else { - propertyDescriptor = BeanPropertyHelper.getPropertyDescriptor( - beanClass, propertyName); - property = new PojoListProperty(propertyDescriptor, elementType); - } - return new PojoListPropertyDecorator(property, propertyDescriptor); - } - - /** - * Returns a map property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains an empty map. - * - * @param propertyName - * the property name - * @return a map property for the given property name of an arbitrary bean - * class. - */ - public static IBeanMapProperty map(String propertyName) { - return map(null, propertyName, null, null); - } - - /** - * Returns a map property for the given property name of an arbitrary bean - * class. Objects lacking the named property are treated the same as if the - * property always contains an empty map. - * - * @param propertyName - * the property name - * @param keyType - * the key type for the returned map property - * @param valueType - * the value type for the returned map property - * @return a map property for the given property name of an arbitrary bean - * class. - */ - public static IBeanMapProperty map(String propertyName, Class keyType, - Class valueType) { - return map(null, propertyName, keyType, valueType); - } - - /** - * Returns a map property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name - * @return a map property for the given property name of the given bean - * class. - */ - public static IBeanMapProperty map(Class beanClass, String propertyName) { - return map(beanClass, propertyName, null, null); - } - - /** - * Returns a map property for the given property name of the given bean - * class. - * - * @param beanClass - * the bean class - * @param propertyName - * the property name - * @param keyType - * the key type of the returned map property - * @param valueType - * the value type of the returned map property - * @return a map property for the given property name of the given bean - * class. - */ - public static IBeanMapProperty map(Class beanClass, String propertyName, - Class keyType, Class valueType) { - PropertyDescriptor propertyDescriptor; - IMapProperty property; - if (beanClass == null) { - propertyDescriptor = null; - property = new AnonymousPojoMapProperty(propertyName, keyType, - valueType); - } else { - propertyDescriptor = BeanPropertyHelper.getPropertyDescriptor( - beanClass, propertyName); - property = new PojoMapProperty(propertyDescriptor, keyType, - valueType); - } - return new PojoMapPropertyDecorator(property, propertyDescriptor); - } -} diff --git a/bundles/org.eclipse.jface.databinding/.settings/.api_filters b/bundles/org.eclipse.jface.databinding/.settings/.api_filters index b52c3eab383..282dac6193c 100644 --- a/bundles/org.eclipse.jface.databinding/.settings/.api_filters +++ b/bundles/org.eclipse.jface.databinding/.settings/.api_filters @@ -1,5 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/swt/SWTObservables.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/swt/SWTObservables.java deleted file mode 100644 index 467b730cc5d..00000000000 --- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/swt/SWTObservables.java +++ /dev/null @@ -1,604 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Matt Carter - bug 170668 - * Brad Reynolds - bug 170848 - * Matthew Hall - bugs 180746, 207844, 245647, 248621, 232917, 194734, - * 195222, 256543, 213893, 262320, 264286, 266563, 306203 - * Michael Krauter - bug 180223 - * Boris Bokowski - bug 245647 - * Tom Schindl - bug 246462 - * Lars Vogel - Bug 327086 - * Jeanderson Candido - Bug 413611 - * Simon Scholz - Bug 449022 - * Eugen Neufeld - bug 461560 - *******************************************************************************/ -package org.eclipse.jface.databinding.swt; - -import org.eclipse.core.databinding.observable.Observables; -import org.eclipse.core.databinding.observable.Realm; -import org.eclipse.core.databinding.observable.list.IObservableList; -import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.core.databinding.observable.value.IVetoableValue; -import org.eclipse.core.databinding.observable.value.ValueChangingEvent; -import org.eclipse.jface.databinding.swt.typed.WidgetProperties; -import org.eclipse.jface.internal.databinding.swt.SWTDelayedObservableValueDecorator; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Widget; - -/** - * A factory for creating observables for SWT widgets - * - * @since 1.1 - * @noreference - * @deprecated This class will be removed in a future release. See - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=546820 for more - * information. Use WidgetProperties instead. - */ -@Deprecated -@SuppressWarnings("rawtypes") -public class SWTObservables { - - /** - * Returns the realm representing the UI thread for the given display. - * - * @param display the display to get realm for - * @return the realm representing the UI thread for the given display - * @deprecated please use {@link DisplayRealm#getRealm(Display)} instead. - */ - @Deprecated - public static Realm getRealm(final Display display) { - return DisplayRealm.getRealm(display); - } - - /** - * Returns an observable which delays notification of value change events - * from observable until delay milliseconds have - * elapsed since the last change event, or until a FocusOut event is - * received from the underlying widget (whichever happens first). This - * observable helps to boost performance in situations where an observable - * has computationally expensive listeners (e.g. changing filters in a - * viewer) or many dependencies (master fields with multiple detail fields). - * A common use of this observable is to delay validation of user input - * until the user stops typing in a UI field. - *

- * To notify about pending changes, the returned observable fires a stale - * event when the wrapped observable value fires a change event, and remains - * stale until the delay has elapsed and the value change is fired. A call - * to {@link IObservableValue#getValue() getValue()} while a value change is - * pending will fire the value change immediately, short-circuiting the - * delay. - *

- * Only updates resulting from the observed widget are delayed. Calls directly - * to {@link IObservableValue#setValue} are not, and they cancel pending delayed - * values. - *

- * Note that this observable will not forward {@link ValueChangingEvent} - * events from a wrapped {@link IVetoableValue}. - * - * @param delay - * the delay in milliseconds - * @param observable - * the observable being delayed - * @return an observable which delays notification of value change events - * from observable until delay - * milliseconds have elapsed since the last change event. - * - * @since 1.2 - * @deprecated use WidgetProperties instead - */ - @SuppressWarnings("unchecked") - @Deprecated - public static ISWTObservableValue observeDelayedValue(int delay, ISWTObservableValue observable) { - return new SWTDelayedObservableValueDecorator( - Observables.observeDelayedValue(delay, observable), - observable.getWidget()); - } - - /** - * Returns an observable value tracking the enabled state of the given - * widget. The supported types are: - *

    - *
  • org.eclipse.swt.widgets.Control
  • - *
  • org.eclipse.swt.widgets.Menu
  • - *
  • org.eclipse.swt.widgets.MenuItem
  • - *
  • org.eclipse.swt.widgets.ScrollBar
  • - *
  • org.eclipse.swt.widgets.ToolItem
  • - *
- * - * @param widget - * the widget to observe - * @return an observable value tracking the enabled state of the given - * widget. - * @since 1.5 - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeEnabled(Widget widget) { - return WidgetProperties.enabled().observe(widget); - } - - /** - * Returns an observable value tracking the enabled state of the given - * control - * - * @param control - * the control to observe - * @return an observable value tracking the enabled state of the given - * control - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeEnabled(Control control) { - return observeEnabled((Widget) control); - } - - /** - * Returns an observable value tracking the visible state of the given - * control - * - * @param control - * the control to observe - * @return an observable value tracking the visible state of the given - * control - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeVisible(Control control) { - return WidgetProperties.visible().observe(control); - } - - /** - * Returns an observable tracking the tooltip text of the given item. The - * supported types are: - *
    - *
  • org.eclipse.swt.widgets.Control
  • - *
  • org.eclipse.swt.custom.CTabItem
  • - *
  • org.eclipse.swt.widgets.TabItem
  • - *
  • org.eclipse.swt.widgets.TableColumn
  • - *
  • org.eclipse.swt.widgets.ToolItem
  • - *
  • org.eclipse.swt.widgets.TrayItem
  • - *
  • org.eclipse.swt.widgets.TreeColumn
  • - *
- * - * @param widget - * the widget to observe - * @return an observable value tracking the tooltip text of the given item - * - * @since 1.3 - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeTooltipText(Widget widget) { - return WidgetProperties.tooltipText().observe(widget); - } - - /** - * Returns an observable value tracking the tooltip text of the given - * control - * - * @param control - * the control to observe - * @return an observable value tracking the tooltip text of the given - * control - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeTooltipText(Control control) { - return observeTooltipText((Widget) control); - } - - /** - * Returns an observable observing the selection attribute of the provided - * control. The supported types are: - *
    - *
  • org.eclipse.swt.widgets.Spinner
  • - *
  • org.eclipse.swt.widgets.Button
  • - *
  • org.eclipse.swt.widgets.Combo
  • - *
  • org.eclipse.swt.custom.CCombo
  • - *
  • org.eclipse.swt.widgets.List
  • - *
  • org.eclipse.swt.widgets.MenuItem (since 1.5)
  • - *
  • org.eclipse.swt.widgets.Scale
  • - *
- * - * @param widget - * the widget to observe - * @return observable value - * @throws IllegalArgumentException - * if control type is unsupported - * @since 1.5 - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeSelection(Widget widget) { - return WidgetProperties.widgetSelection().observe(widget); - } - - /** - * Returns an observable observing the selection attribute of the provided - * control. The supported types are: - *
    - *
  • org.eclipse.swt.widgets.Button
  • - *
  • org.eclipse.swt.widgets.Combo
  • - *
  • org.eclipse.swt.custom.CCombo
  • - *
  • org.eclipse.swt.widgets.List
  • - *
  • org.eclipse.swt.widgets.Scale
  • - *
  • org.eclipse.swt.widgets.Slider (since 1.5)
  • - *
  • org.eclipse.swt.widgets.Spinner
  • - *
- * - * @param control - * the control to observe - * @return observable value - * @throws IllegalArgumentException - * if control type is unsupported - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeSelection(Control control) { - return observeSelection((Widget) control); - } - - /** - * Returns an observable observing the minimum attribute of the provided - * control. The supported types are: - *
    - *
  • org.eclipse.swt.widgets.Spinner
  • - *
  • org.eclipse.swt.widgets.Slider (since 1.5)
  • - *
  • org.eclipse.swt.widgets.Scale
  • - *
- * - * @param control - * the control to observe - * @return observable value - * @throws IllegalArgumentException - * if control type is unsupported - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeMin(Control control) { - return WidgetProperties.minimum().observe(control); - } - - /** - * Returns an observable observing the maximum attribute of the provided - * control. The supported types are: - *
    - *
  • org.eclipse.swt.widgets.Spinner
  • - *
  • org.eclipse.swt.widgets.Slider (since 1.5)
  • - *
  • org.eclipse.swt.widgets.Scale
  • - *
- * - * @param control - * the control to observe - * @return observable value - * @throws IllegalArgumentException - * if control type is unsupported - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeMax(Control control) { - return WidgetProperties.maximum().observe(control); - } - - /** - * Returns an observable observing the text attribute of the provided - * control. The supported types are: - *
    - *
  • org.eclipse.swt.widgets.Text
  • - *
  • org.eclipse.swt.custom.StyledText (as of 1.3)
  • - *
- * - * @param control - * the control to observe - * @param events - * array of SWT event types to register for change events. May - * include {@link SWT#None}, {@link SWT#Modify}, - * {@link SWT#FocusOut} or {@link SWT#DefaultSelection}. - * @return observable value - * @throws IllegalArgumentException - * if control type is unsupported - * @since 1.3 - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeText(Control control, int[] events) { - return WidgetProperties.text(events).observe(control); - } - - /** - * Returns an observable observing the text attribute of the provided - * control. The supported types are: - *
    - *
  • org.eclipse.swt.widgets.Text
  • - *
  • org.eclipse.swt.custom.StyledText (as of 1.3)
  • - *
- * - * @param control - * the control to observe - * @param event - * event type to register for change events - * @return observable value - * @throws IllegalArgumentException - * if control type is unsupported - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeText(Control control, int event) { - return WidgetProperties.text(event).observe(control); - } - - /** - * Returns an observable observing the text attribute of the provided - * widget. The supported types are: - *
    - *
  • org.eclipse.swt.widgets.Button (as of 1.3)
  • - *
  • org.eclipse.swt.custom.CCombo
  • - *
  • org.eclipse.swt.custom.CLabel
  • - *
  • org.eclipse.swt.widgets.Combo
  • - *
  • org.eclipse.swt.widgets.Group (as of 1.7)
  • - *
  • org.eclipse.swt.widgets.Item
  • - *
  • org.eclipse.swt.widgets.Label
  • - *
  • org.eclipse.swt.widgets.Link (as of 1.2)
  • - *
  • org.eclipse.swt.widgets.Shell
  • - *
  • org.eclipse.swt.widgets.StyledText (as of 1.3)
  • - *
  • org.eclipse.swt.widgets.Text (as of 1.3)
  • - *
- * - * @param widget - * the widget to observe - * @return observable value - * @throws IllegalArgumentException - * if the type of widget is unsupported - * - * @since 1.3 - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeText(Widget widget) { - return WidgetProperties.text().observe(widget); - } - - /** - * Returns an observable observing the text attribute of the provided - * control. The supported types are: - *
    - *
  • org.eclipse.swt.widgets.Button (as of 1.3)
  • - *
  • org.eclipse.swt.custom.CCombo
  • - *
  • org.eclipse.swt.custom.CLabel
  • - *
  • org.eclipse.swt.widgets.Combo
  • - *
  • org.eclipse.swt.widgets.Group (as of 1.7)
  • - *
  • org.eclipse.swt.widgets.Label
  • - *
  • org.eclipse.swt.widgets.Link (as of 1.2)
  • - *
  • org.eclipse.swt.widgets.Shell
  • - *
  • org.eclipse.swt.custom.StyledText (as of 1.3)
  • - *
  • org.eclipse.swt.widgets.Text (as of 1.3)
  • - *
- * - * @param control - * the control to observe - * @return observable value - * @throws IllegalArgumentException - * if control type is unsupported - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeText(Control control) { - return observeText((Widget) control); - } - - /** - * Returns an observable observing the message attribute of the provided - * widget. the supported types are: - *
    - *
  • org.eclipse.swt.widgets.Text
  • - *
  • org.eclipse.swt.widgets.ToolTip
  • - *
- * - * @param widget - * the widget to observe - * @return an observable observing the message attribute of the provided - * widget. - * @since 1.3 - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeMessage(Widget widget) { - return WidgetProperties.message().observe(widget); - } - - /** - * Returns an observable observing the image attribute of the provided - * widget. The supported types are: - *
    - *
  • org.eclipse.swt.widgets.Button
  • - *
  • org.eclipse.swt.custom.CLabel
  • - *
  • org.eclipse.swt.widgets.Item
  • - *
  • org.eclipse.swt.widgets.Label
  • - *
- * - * @param widget - * the widget to observe - * @return observable value - * @throws IllegalArgumentException - * if widget type is unsupported - * @since 1.3 - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeImage(Widget widget) { - return WidgetProperties.image().observe(widget); - } - - /** - * Returns an observable observing the items attribute of the provided - * control. The supported types are: - *
    - *
  • org.eclipse.swt.widgets.Combo
  • - *
  • org.eclipse.swt.custom.CCombo
  • - *
  • org.eclipse.swt.widgets.List
  • - *
- * - * @param control - * the control to observe - * @return observable list - * @throws IllegalArgumentException - * if control type is unsupported - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static IObservableList observeItems(Control control) { - return WidgetProperties.items().observe(control); - } - - /** - * Returns an observable observing the single selection index attribute of - * the provided control. The supported types are: - *
    - *
  • org.eclipse.swt.widgets.Table
  • - *
  • org.eclipse.swt.widgets.Combo
  • - *
  • org.eclipse.swt.custom.CCombo
  • - *
  • org.eclipse.swt.widgets.List
  • - *
- * - * @param control - * the control to observe - * @return observable value - * @throws IllegalArgumentException - * if control type is unsupported - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeSingleSelectionIndex(Control control) { - return WidgetProperties.singleSelectionIndex().observe(control); - } - - /** - * Returns an observable value tracking the foreground color of the given - * control - * - * @param control - * the control to observe - * @return an observable value tracking the foreground color of the given - * control - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeForeground(Control control) { - return WidgetProperties.foreground().observe(control); - } - - /** - * Returns an observable value tracking the background color of the given - * control - * - * @param control - * the control to observe - * @return an observable value tracking the background color of the given - * control - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeBackground(Control control) { - return WidgetProperties.background().observe(control); - } - - /** - * Returns an observable value tracking the font of the given control. - * - * @param control - * the control to observe - * @return an observable value tracking the font of the given control - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeFont(Control control) { - return WidgetProperties.font().observe(control); - } - - /** - * Returns an observable value tracking the size of the given control. - * - * @param control - * the control to observe - * @return an observable value tracking the size of the given control - * @since 1.3 - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeSize(Control control) { - return WidgetProperties.size().observe(control); - } - - /** - * Returns an observable value tracking the location of the given control. - * - * @param control - * the control to observe - * @return an observable value tracking the location of the given control - * @since 1.3 - */ - public static ISWTObservableValue observeLocation(Control control) { - return WidgetProperties.location().observe(control); - } - - /** - * Returns an observable value tracking the focus of the given control. - * - * @param control - * the control to observe - * @return an observable value tracking the focus of the given control - * @since 1.3 - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeFocus(Control control) { - return WidgetProperties.focused().observe(control); - } - - /** - * Returns an observable value tracking the bounds of the given control. - * - * @param control - * the control to observe - * @return an observable value tracking the bounds of the given control - * @since 1.3 - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeBounds(Control control) { - return WidgetProperties.bounds().observe(control); - } - - /** - * Returns an observable observing the editable attribute of the provided - * control. The supported types are: - *
    - *
  • org.eclipse.swt.custom.CCombo (since 1.6)
  • - *
  • org.eclipse.swt.custom.StyledText (since 1.6)
  • - *
  • org.eclipse.swt.widgets.Text
  • - *
- * - * @param control - * the control to observe - * @return observable value - * @throws IllegalArgumentException - * if control type is unsupported - * @deprecated use WidgetProperties instead - */ - @Deprecated - public static ISWTObservableValue observeEditable(Control control) { - return WidgetProperties.editable().observe(control); - } -} diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/swt/WidgetProperties.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/swt/WidgetProperties.java deleted file mode 100644 index 2bca286c562..00000000000 --- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/swt/WidgetProperties.java +++ /dev/null @@ -1,332 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2015 Matthew Hall and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Matthew Hall - initial API and implementation (bug 194734) - * Matthew Hall - bugs 256543, 213893, 262320, 262946, 264286, 266563, 169876, 306203 - * Eugen Neufeld - bug 461560 - * Lars Vogel - Bug 482486 - ******************************************************************************/ - -package org.eclipse.jface.databinding.swt; - -import org.eclipse.jface.internal.databinding.swt.ControlBackgroundProperty; -import org.eclipse.jface.internal.databinding.swt.ControlBoundsProperty; -import org.eclipse.jface.internal.databinding.swt.ControlFocusedProperty; -import org.eclipse.jface.internal.databinding.swt.ControlFontProperty; -import org.eclipse.jface.internal.databinding.swt.ControlForegroundProperty; -import org.eclipse.jface.internal.databinding.swt.ControlLocationProperty; -import org.eclipse.jface.internal.databinding.swt.ControlSizeProperty; -import org.eclipse.jface.internal.databinding.swt.ControlVisibleProperty; -import org.eclipse.jface.internal.databinding.swt.WidgetEditableProperty; -import org.eclipse.jface.internal.databinding.swt.WidgetEnabledProperty; -import org.eclipse.jface.internal.databinding.swt.WidgetImageProperty; -import org.eclipse.jface.internal.databinding.swt.WidgetItemsProperty; -import org.eclipse.jface.internal.databinding.swt.WidgetMaximumProperty; -import org.eclipse.jface.internal.databinding.swt.WidgetMessageProperty; -import org.eclipse.jface.internal.databinding.swt.WidgetMinimumProperty; -import org.eclipse.jface.internal.databinding.swt.WidgetSelectionProperty; -import org.eclipse.jface.internal.databinding.swt.WidgetSingleSelectionIndexProperty; -import org.eclipse.jface.internal.databinding.swt.WidgetTextProperty; -import org.eclipse.jface.internal.databinding.swt.WidgetTextWithEventsProperty; -import org.eclipse.jface.internal.databinding.swt.WidgetTooltipTextProperty; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.custom.CTabItem; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.DateTime; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Item; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.swt.widgets.Scale; -import org.eclipse.swt.widgets.ScrollBar; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Slider; -import org.eclipse.swt.widgets.Spinner; -import org.eclipse.swt.widgets.TabItem; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.ToolItem; -import org.eclipse.swt.widgets.ToolTip; -import org.eclipse.swt.widgets.TrayItem; -import org.eclipse.swt.widgets.TreeColumn; -import org.eclipse.swt.widgets.Widget; - -/** - * A factory for creating properties of SWT {@link Widget widgets}. - * - * @noreference - * @deprecated This class will be removed in a future release. See - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=546822 for more - * information. It has been replaced by the class - * {@link org.eclipse.jface.databinding.swt.typed.WidgetProperties}. - * That class creates typed property objects, while this class - * creates raw property objects. - * - * @since 1.3 - */ -@Deprecated -@SuppressWarnings({ "rawtypes" }) -public class WidgetProperties { - /** - * Returns a value property for observing the background color of a - * {@link Control}. - * - * @return a value property for observing the background color of a - * {@link Control}. - */ - public static IWidgetValueProperty background() { - return new ControlBackgroundProperty(); - } - - /** - * Returns a value property for observing the bounds of a {@link Control}. - * - * @return a value property for observing the bounds of a {@link Control}. - */ - public static IWidgetValueProperty bounds() { - return new ControlBoundsProperty(); - } - - /** - * Returns a value property for observing the editable state of a - * {@link CCombo} (since 1.6), {@link StyledText} (since 1.6), or - * {@link Text}. - * - * @return a value property for observing the editable state of a - * {@link CCombo}, {@link StyledText}, or {@link Text}. - */ - public static IWidgetValueProperty editable() { - return new WidgetEditableProperty(); - } - - /** - * Returns a value property for observing the enablement state of a - * {@link Control}, {@link Menu} (since 1.5), {@link MenuItem} (since 1.5), - * {@link ScrollBar} (since 1.5) or {@link ToolItem} (since 1.5). - * - * @return a value property for observing the enablement state of a - * {@link Control}, {@link Menu}, {@link MenuItem}, - * {@link ScrollBar} or {@link ToolItem}. - */ - public static IWidgetValueProperty enabled() { - return new WidgetEnabledProperty(); - } - - /** - * Returns a value property for observing the focus state of a - * {@link Control}. - * - * @return a value property for observing the focus state of a - * {@link Control}. - */ - public static IWidgetValueProperty focused() { - return new ControlFocusedProperty(); - } - - /** - * Returns a value property for observing the font of a {@link Control}. - * - * @return a value property for observing the font of a {@link Control}. - */ - public static IWidgetValueProperty font() { - return new ControlFontProperty(); - } - - /** - * Returns a value property for observing the foreground color of a - * {@link Control}. - * - * @return a value property for observing the foreground color of a - * {@link Control}. - */ - public static IWidgetValueProperty foreground() { - return new ControlForegroundProperty(); - } - - /** - * Returns a value property for observing the image of a {@link Button}, - * {@link CLabel}, {@link Item} or {@link Label}. - * - * @return a value property for observing the image of a {@link Button}, - * {@link CLabel}, {@link Item} or {@link Label}. - */ - public static IWidgetValueProperty image() { - return new WidgetImageProperty(); - } - - /** - * Returns a list property for observing the items of a {@link CCombo}, - * {@link Combo} or {@link List}. - * - * @return a list property for observing the items of a {@link CCombo}, - * {@link Combo} or {@link List}. - */ - public static IWidgetListProperty items() { - return new WidgetItemsProperty(); - } - - /** - * Returns a value property for observing the location of a {@link Control}. - * - * @return a value property for observing the location of a {@link Control}. - */ - public static IWidgetValueProperty location() { - return new ControlLocationProperty(); - } - - /** - * Returns a value property for observing the maximum value of a - * {@link Scale}, {@link Slider} (since 1.5) or {@link Spinner}. - * - * @return a value property for observing the maximum value of a - * {@link Scale}, {@link Slider} (since 1.5) or {@link Spinner}. - */ - public static IWidgetValueProperty maximum() { - return new WidgetMaximumProperty(); - } - - /** - * Returns a value property for observing the message of a {@link Text} or - * {@link ToolTip}. - * - * @return a value property for observing the message of a {@link Text} or - * {@link ToolTip}. - */ - public static IWidgetValueProperty message() { - return new WidgetMessageProperty(); - } - - /** - * Returns a value property for observing the minimum value of a - * {@link Scale}, {@link Slider} (since 1.5) or {@link Spinner}. - * - * @return a value property for observing the minimum value of a - * {@link Scale}, {@link Slider} (since 1.5) or {@link Spinner}. - */ - public static IWidgetValueProperty minimum() { - return new WidgetMinimumProperty(); - } - - /** - * Returns a value property for observing the selection state of a - * {@link Button}, {@link CCombo}, {@link Combo}, {@link DateTime}, - * {@link List}, {@link MenuItem} (since 1.5), {@link Scale}, {@link Slider} - * (since 1.5) or {@link Spinner}. - * - * @return a value property for observing the selection state of a - * {@link Button}, {@link CCombo}, {@link Combo}, {@link DateTime}, - * {@link List}, {@link MenuItem}, {@link Scale}, {@link Slider} or - * {@link Spinner}. - */ - public static IWidgetValueProperty selection() { - return new WidgetSelectionProperty(); - } - - /** - * Returns a value property for observing the single selection index of a - * {@link CCombo}, {@link Combo}, {@link List} or {@link Table}. - * - * @return a value property for the single selection index of a SWT Combo. - */ - public static IWidgetValueProperty singleSelectionIndex() { - return new WidgetSingleSelectionIndexProperty(); - } - - /** - * Returns a value property for observing the size of a {@link Control}. - * - * @return a value property for observing the size of a {@link Control}. - */ - public static IWidgetValueProperty size() { - return new ControlSizeProperty(); - } - - /** - * Returns a value property for observing the text of a {@link Button}, - * {@link CCombo}, {@link CLabel}, {@link Combo}, {@link Item}, - * {@link Label}, {@link Link}, {@link Shell}, {@link Group}, - * {@link StyledText} or {@link Text}. - * - * @return a value property for observing the text of a {@link Button}, - * {@link CCombo}, {@link CLabel}, {@link Combo}, {@link Group}, - * {@link Item}, {@link Label}, {@link Link}, {@link Shell}, link - * StyledText} or {@link Text}. - */ - public static IWidgetValueProperty text() { - return new WidgetTextProperty(); - } - - /** - * Returns a value property for observing the text of a {@link StyledText} - * or {@link Text}. - * - * @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}. - * - * @return a value property for observing the text of a {@link StyledText} - * or {@link Text}. - */ - public static IWidgetValueProperty text(final int event) { - return text(new int[] { event }); - } - - /** - * Returns a value property for observing the text of a {@link StyledText} - * or {@link Text}. - * - * @param events - * varags of SWT event types to register for change events. May - * include {@link SWT#None}, {@link SWT#Modify}, - * {@link SWT#FocusOut} or {@link SWT#DefaultSelection}. - * - * @return a value property for observing the text of a {@link StyledText} - * or {@link Text}. - */ - public static IWidgetValueProperty text(int... events) { - return new WidgetTextWithEventsProperty(events.clone()); - } - - /** - * Returns a value property for observing the tooltip text of a - * {@link CTabItem}, {@link Control}, {@link TabItem}, {@link TableColumn}, - * {@link ToolItem}, {@link TrayItem} or {@link TreeColumn}. - * - * @return a value property for observing the tooltip text of a - * {@link CTabItem}, {@link Control}, {@link TabItem}, - * {@link TableColumn}, {@link ToolItem}, {@link TrayItem} or - * {@link TreeColumn}. - */ - public static IWidgetValueProperty tooltipText() { - return new WidgetTooltipTextProperty(); - } - - /** - * Returns a value property for observing the visibility state of a - * {@link Control}. - * - * @return a value property for observing the visibility state of a - * {@link Control}. - */ - public static IWidgetValueProperty visible() { - return new ControlVisibleProperty(); - } -} diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/viewers/ViewerProperties.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/viewers/ViewerProperties.java deleted file mode 100644 index 84fc2379651..00000000000 --- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/viewers/ViewerProperties.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2015 Matthew Hall and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Matthew Hall - initial API and implementation (bug 194734) - * Matthew Hall - bug 264286 - * Ovidio Mallo - bug 270494 - ******************************************************************************/ - -package org.eclipse.jface.databinding.viewers; - -import org.eclipse.jface.internal.databinding.viewers.SelectionProviderMultipleSelectionProperty; -import org.eclipse.jface.internal.databinding.viewers.SelectionProviderSingleSelectionProperty; -import org.eclipse.jface.internal.databinding.viewers.StructuredViewerFiltersProperty; -import org.eclipse.jface.internal.databinding.viewers.ViewerCheckedElementsProperty; -import org.eclipse.jface.internal.databinding.viewers.ViewerInputProperty; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.CheckboxTreeViewer; -import org.eclipse.jface.viewers.ICheckable; -import org.eclipse.jface.viewers.IPostSelectionProvider; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; - -/** - * A factory for creating properties of JFace {@link Viewer viewers}. - * - * @noreference - * @deprecated This class will be removed in a future release. See - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=546822 for more - * information. It has been replaced by the class - * {@link org.eclipse.jface.databinding.viewers.typed.ViewerProperties}. - * That class creates typed property objects, while this class - * creates raw property objects. - * - * @since 1.3 - */ -@Deprecated -@SuppressWarnings({ "rawtypes" }) -public class ViewerProperties { - /** - * Returns a set property for observing the checked elements of a - * {@link CheckboxTableViewer}, {@link CheckboxTreeViewer} or - * {@link ICheckable}. - * - * @param elementType - * the element type of the returned property - * - * @return a set property for observing the checked elements of a - * {@link CheckboxTableViewer}, {@link CheckboxTreeViewer} or - * {@link ICheckable}. - */ - public static IViewerSetProperty checkedElements(Object elementType) { - return new ViewerCheckedElementsProperty(elementType); - } - - /** - * Returns a value property for observing the input of a - * {@link StructuredViewer}. - * - * @return a value property for observing the input of a - * {@link StructuredViewer}. - */ - public static IViewerSetProperty filters() { - return new StructuredViewerFiltersProperty(); - } - - /** - * Returns a value property for observing the input of a {@link Viewer}. - * - * @return a value property for observing the input of a {@link Viewer}. - */ - public static IViewerValueProperty input() { - return new ViewerInputProperty(); - } - - /** - * Returns a list property for observing the multiple selection of an - * {@link ISelectionProvider}. - * - * @return a list property for observing the multiple selection of an - * {@link ISelectionProvider}. - */ - public static IViewerListProperty multipleSelection() { - return new SelectionProviderMultipleSelectionProperty(false); - } - - /** - * Returns a list property for observing the multiple post selection - * of an {@link IPostSelectionProvider}. - * - * @return a list property for observing the multiple post selection - * of an {@link IPostSelectionProvider}. - * - * @since 1.4 - */ - public static IViewerListProperty multiplePostSelection() { - return new SelectionProviderMultipleSelectionProperty(true); - } - - /** - * Returns a value property for observing the single selection of a - * {@link ISelectionProvider}. - * - * @return a value property for observing the single selection of a - * {@link ISelectionProvider}. - */ - public static IViewerValueProperty singleSelection() { - return new SelectionProviderSingleSelectionProperty(false); - } - - /** - * Returns a value property for observing the single post selection - * of a {@link IPostSelectionProvider}. - * - * @return a value property for observing the single post selection - * of a {@link IPostSelectionProvider}. - * - * @since 1.4 - */ - public static IViewerValueProperty singlePostSelection() { - return new SelectionProviderSingleSelectionProperty(true); - } -} diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/viewers/ViewersObservables.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/viewers/ViewersObservables.java deleted file mode 100644 index eafcf622b50..00000000000 --- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/viewers/ViewersObservables.java +++ /dev/null @@ -1,344 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Matthew Hall - bugs 206839, 124684, 239302, 245647, 194734, 195222, - * 264286 - * Ovidio Mallo - bug 270494 - *******************************************************************************/ - -package org.eclipse.jface.databinding.viewers; - -import org.eclipse.core.databinding.observable.Observables; -import org.eclipse.core.databinding.observable.list.IObservableList; -import org.eclipse.core.databinding.observable.set.IObservableSet; -import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.jface.databinding.viewers.typed.ViewerProperties; -import org.eclipse.jface.internal.databinding.viewers.ViewerObservableValueDecorator; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.CheckboxTreeViewer; -import org.eclipse.jface.viewers.ICheckable; -import org.eclipse.jface.viewers.IPostSelectionProvider; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; - -/** - * Factory methods for creating observables for JFace viewers - * - * @since 1.1 - * @noreference - * @deprecated This class will be removed in a future release. See - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=546820 for more - * information. Use ViewerProperties instead. - */ -@Deprecated -@SuppressWarnings("rawtypes") -public class ViewersObservables { - private static void checkNull(Object obj) { - if (obj == null) - throw new IllegalArgumentException(); - } - - /** - * Returns an observable which delays notification of value change events - * from observable until delay milliseconds have - * passed since the last change event, or until a FocusOut event is received - * from the underlying viewer control (whichever happens earlier). This - * class helps to delay validation until the user stops changing the value - * (e.g. until a user stops changing a viewer selection). To notify about - * pending changes, the returned observable value will fire a stale event - * when the wrapped observable value fires a change event, but this change - * is being delayed. - * - * @param delay - * the delay in milliseconds - * @param observable - * the observable being delayed - * @return an observable which delays notification of value change events - * from observable until delay - * milliseconds have passed since the last change event. - * - * @since 1.3 - */ - public static IViewerObservableValue observeDelayedValue(int delay, IViewerObservableValue observable) { - return new ViewerObservableValueDecorator<>(Observables.observeDelayedValue(delay, observable), - observable.getViewer()); - } - - /** - * Returns an observable value that tracks the current selection of the - * given selection provider. If the selection provider provides selections - * of type {@link IStructuredSelection}, the observable value will be the - * first element of the structured selection as returned by - * {@link IStructuredSelection#getFirstElement()}. - * - * @param selectionProvider provider to get selection from; not null - * @return the observable value tracking the (single) selection of the given - * selection provider - */ - public static IObservableValue observeSingleSelection( - ISelectionProvider selectionProvider) { - checkNull(selectionProvider); - return ViewerProperties.singleSelection().observe(selectionProvider); - } - - /** - * Returns an observable value that tracks the current post selection - * of the given post selection provider. If the selection provider provides - * selections of type {@link IStructuredSelection}, the observable value - * will be the first element of the structured selection as returned by - * {@link IStructuredSelection#getFirstElement()}. - * - * @param selectionProvider - * The selection provider on which to track the post - * selection. - * @return the observable value tracking the (single) post selection - * of the given post selection provider - * - * @since 1.4 - */ - public static IObservableValue observeSinglePostSelection( - IPostSelectionProvider selectionProvider) { - checkNull(selectionProvider); - return ViewerProperties.singlePostSelection() - .observe(selectionProvider); - } - - /** - * Returns an observable list that tracks the current selection of the given - * selection provider. Assumes that the selection provider provides - * selections of type {@link IStructuredSelection}. Note that the observable - * list will not honor the full contract of java.util.List in - * that it may delete or reorder elements based on what the selection - * provider returns from {@link ISelectionProvider#getSelection()} after - * having called - * {@link ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)} - * based on the requested change to the observable list. The affected - * methods are add, addAll, and set. - * - * @param selectionProvider provider to get selection from; not null - * @return the observable value tracking the (multi) selection of the given - * selection provider - * - * @since 1.2 - */ - public static IObservableList observeMultiSelection( - ISelectionProvider selectionProvider) { - checkNull(selectionProvider); - return ViewerProperties.multipleSelection().observe(selectionProvider); - } - - /** - * Returns an observable list that tracks the current post selection - * of the given post selection provider. Assumes that the selection provider - * provides selections of type {@link IStructuredSelection}. Note that the - * observable list will not honor the full contract of - * java.util.List in that it may delete or reorder elements - * based on what the selection provider returns from - * {@link ISelectionProvider#getSelection()} after having called - * {@link ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)} - * based on the requested change to the observable list. The affected - * methods are add, addAll, and set. - * - * @param selectionProvider - * The selection provider on which to track the post - * selection. - * @return the observable value tracking the (multi) post selection - * of the given post selection provider - * - * @since 1.4 - */ - public static IObservableList observeMultiPostSelection( - IPostSelectionProvider selectionProvider) { - checkNull(selectionProvider); - return ViewerProperties.multiplePostSelection().observe( - selectionProvider); - } - - /** - * Returns an observable value that tracks the current selection of the - * given viewer. If the viewer provides selections of type - * {@link IStructuredSelection}, the observable value will be the first - * element of the structured selection as returned by - * {@link IStructuredSelection#getFirstElement()}. - * - * @param viewer - * the viewer - * @return the observable value tracking the (single) selection of the given - * viewer - * @since 1.2 - */ - public static IViewerObservableValue observeSingleSelection(Viewer viewer) { - checkNull(viewer); - return ViewerProperties.singleSelection().observe(viewer); - } - - /** - * Returns an observable value that tracks the current post selection - * of the given structured viewer. If the viewer provides selections of type - * {@link IStructuredSelection}, the observable value will be the first - * element of the structured selection as returned by - * {@link IStructuredSelection#getFirstElement()}. - * - * @param viewer - * The viewer on which to track the post selection. - * @return the observable value tracking the (single) post selection - * of the given structured viewer - * - * @since 1.4 - */ - public static IViewerObservableValue observeSinglePostSelection( - StructuredViewer viewer) { - checkNull(viewer); - return ViewerProperties.singlePostSelection().observe(viewer); - } - - /** - * Returns an observable list that tracks the current selection of the given - * viewer. Assumes that the viewer provides selections of type - * {@link IStructuredSelection}. Note that the observable list will not - * honor the full contract of java.util.List in that it may - * delete or reorder elements based on what the viewer returns from - * {@link ISelectionProvider#getSelection()} after having called - * {@link ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)} - * based on the requested change to the observable list. The affected - * methods are add, addAll, and set. - * - * @param viewer - * The viewer on which to track the selection. - * @return the observable value tracking the (multi) selection of the given - * selection provider - * - * @since 1.2 - */ - public static IViewerObservableList observeMultiSelection(Viewer viewer) { - checkNull(viewer); - return ViewerProperties.multipleSelection().observe(viewer); - } - - /** - * Returns an observable list that tracks the current post selection - * of the given structured viewer. Assumes that the viewer provides - * selections of type {@link IStructuredSelection}. Note that the observable - * list will not honor the full contract of java.util.List in - * that it may delete or reorder elements based on what the viewer returns - * from {@link ISelectionProvider#getSelection()} after having called - * {@link ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)} - * based on the requested change to the observable list. The affected - * methods are add, addAll, and set. - * - * @param viewer - * The viewer on which to track the post selection. - * @return the observable value tracking the (multi) post selection - * of the given structured viewer - * - * @since 1.4 - */ - public static IViewerObservableList observeMultiPostSelection( - StructuredViewer viewer) { - checkNull(viewer); - return ViewerProperties.multiplePostSelection().observe(viewer); - } - - /** - * Returns an observable value that tracks the input of the given viewer. - *

- * The returned observer is blind to changes in the viewer's input unless - * its {@link IObservableValue#setValue(Object)} method is called directly. - * - * @param viewer - * the viewer to observe - * @return an observable value tracking the input of the given viewer - * @since 1.2 - */ - public static IObservableValue observeInput(Viewer viewer) { - checkNull(viewer); - return ViewerProperties.input().observe(viewer); - } - - /** - * Returns an observable set that tracks the checked elements of the given - * ICheckable. - * - * @param checkable - * {@link ICheckable} containing the checked elements to track - * @param elementType - * element type of the returned set - * @return an observable set tracking the checked elements of the given - * checkable. - * @since 1.2 - */ - public static IObservableSet observeCheckedElements(ICheckable checkable, - Object elementType) { - checkNull(checkable); - return ViewerProperties.checkedElements(elementType).observe(checkable); - } - - /** - * Returns an observable set that tracks the checked elements of the given - * viewer. Assumes that the viewer implements {@link ICheckable}. - * - * @param viewer - * {@link CheckboxTableViewer} containing the checked elements to - * track. - * @param elementType - * element type of the returned set - * @return an observable set that tracks the checked elements of the given - * viewer. - * @since 1.2 - */ - public static IViewerObservableSet observeCheckedElements(CheckboxTableViewer viewer, Object elementType) { - checkNull(viewer); - return ViewerProperties.checkedElements(elementType).observe((Viewer) viewer); - } - - /** - * Returns an observable set that tracks the checked elements of the given - * viewer. Assumes that the viewer implements {@link ICheckable}. - * - * @param viewer - * {@link CheckboxTreeViewer} containing the checked elements to - * track. - * @param elementType - * element type of the returned set - * @return an observable set that tracks the checked elements of the given - * viewer. - * @since 1.2 - */ - public static IViewerObservableSet observeCheckedElements(CheckboxTreeViewer viewer, Object elementType) { - checkNull(viewer); - return ViewerProperties.checkedElements(elementType).observe((Viewer) viewer); - } - - /** - * Returns an observable set that tracks the filters of the given viewer. - * Note that the returned set will not track changes that are made using - * direct API on StructuredViewer (by calling - * {@link StructuredViewer#addFilter(org.eclipse.jface.viewers.ViewerFilter) - * addFilter()}, - * {@link StructuredViewer#removeFilter(org.eclipse.jface.viewers.ViewerFilter) - * removeFilter()}, or - * {@link StructuredViewer#setFilters(org.eclipse.jface.viewers.ViewerFilter[]) - * setFilters()}) -- it is assumed that filters are only changed through the - * returned set. - * - * @param viewer - * viewer containing the filters to be tracked - * @return an observable set that tracks the filters of the given viewer. - * @since 1.3 - */ - public static IViewerObservableSet observeFilters(StructuredViewer viewer) { - checkNull(viewer); - return ViewerProperties.filters().observe((Viewer) viewer); - } -} diff --git a/bundles/org.eclipse.ui.workbench/.settings/.api_filters b/bundles/org.eclipse.ui.workbench/.settings/.api_filters new file mode 100644 index 00000000000..b74c0541da7 --- /dev/null +++ b/bundles/org.eclipse.ui.workbench/.settings/.api_filters @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/databinding/WorkbenchObservables.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/databinding/WorkbenchObservables.java deleted file mode 100644 index 0bdff9b9efc..00000000000 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/databinding/WorkbenchObservables.java +++ /dev/null @@ -1,177 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2017 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Matthew Hall - initial API and implementation - * Lars Vogel - Bug 440810 - * Sergey Prigogin (Google) - *******************************************************************************/ -package org.eclipse.ui.databinding; - -import org.eclipse.core.databinding.observable.value.ComputedValue; -import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IAdapterManager; -import org.eclipse.core.runtime.Platform; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IPartService; -import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPartReference; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.databinding.typed.WorkbenchProperties; -import org.eclipse.ui.services.IServiceLocator; - -/** - * Factory methods for creating observables for Workbench objects - * - * @since 3.5 - * @noreference - * @deprecated This class will be removed in a future release. See - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=546820 for more - * information. Use WorkbenchProperties instead. - */ -@Deprecated -public class WorkbenchObservables { - /** - * Returns an observable with values of the given target type. If the wrapped - * observable's value is of the target type, or can be adapted to the target - * type, this is taken as the value of the returned observable, otherwise - * null. - * - * @param master the observable whose value should be adapted - * @param adapter the target type - * @return an observable with values of the given type, or null if - * the current value of the given observable does not adapt to the - * target type - */ - public static IObservableValue observeDetailAdaptedValue(IObservableValue master, Class adapter) { - return observeDetailAdaptedValue(master, adapter, Platform.getAdapterManager()); - } - - /** - * Returns an observable with values of the given target type. If the wrapped - * observable's value is of the target type, or can be adapted to the target - * type, this is taken as the value of the returned observable, otherwise - * null. - * - * @param master the observable whose value should be adapted - * @param adapter the target type - * @param adapterManager the adapter manager used to adapt the master value - * @return an observable with values of the given type, or null if - * the current value of the given observable does not adapt to the - * target type - */ - static IObservableValue observeDetailAdaptedValue(IObservableValue master, Class adapter, - IAdapterManager adapterManager) { - return WorkbenchProperties.adaptedValue(adapter, adapterManager).observeDetail(master); - } - - /** - * Returns an observable value that tracks the post selection of a selection - * service obtained through the given service locator, and adapts the first - * element of that selection to the given target type. - *

- * This method can be used by view or editor implementers to tie into the - * selection service, for example as follows: - *

- * - *
-	 * IObservableValue<IResource> selection = WorkbenchObservables.observeAdaptedSingleSelection(getSite(),
-	 * 		IResource.class);
-	 * 
- * - * - * @param locator a service locator with an available - * {@link ISelectionService} - * @param targetType the target type - * @return an observable value whose value type is the given target type - */ - public static IObservableValue observeAdaptedSingleSelection(IServiceLocator locator, Class targetType) { - ISelectionService selectionService = locator.getService(ISelectionService.class); - Assert.isNotNull(selectionService); - return WorkbenchProperties.singleSelection(null, true).value(WorkbenchProperties.adaptedValue(targetType)) - .observe(selectionService); - } - - /** - * Returns an observable value that tracks the active workbench window for the - * given workbench. - * - * @param workbench the workbench to get the observable for - * @return an observable value that tracks the active workbench window - * @since 3.110 - */ - public static IObservableValue observeActiveWorkbenchWindow(IWorkbench workbench) { - Assert.isNotNull(workbench); - return WorkbenchProperties.activeWindow().observe(workbench); - } - - /** - * Returns an observable value that tracks the active workbench page for the - * given workbench window. - * - * @param window the workbench window to get the observable for - * @return an observable value that tracks the active workbench page - * @since 3.110 - */ - public static IObservableValue observeActiveWorkbenchPage(IWorkbenchWindow window) { - Assert.isNotNull(window); - return WorkbenchProperties.activePage().observe(window); - } - - /** - * Returns an observable value that tracks the active workbench part for the - * given part service. - * - * @param partService the part service to get the observable for, e.g. a - * workbench page - * @return an observable value that tracks the active workbench part - * @since 3.110 - */ - public static IObservableValue observeActivePart(IPartService partService) { - Assert.isNotNull(partService); - return WorkbenchProperties.activePartReference().observe(partService); - } - - /** - * Returns an observable value that tracks the active editor for the given part - * service. - * - * @param partService the part service to get the observable for, e.g. a - * workbench page - * @return an observable value that tracks the active editor - * @since 3.110 - */ - public static IObservableValue observeActiveEditor(IPartService partService) { - final IObservableValue partObservable = observeActivePart(partService); - return ComputedValue.create(() -> { - IWorkbenchPartReference value = partObservable.getValue(); - return value instanceof IEditorReference ? (IEditorReference) value : null; - }); - } - - /** - * Returns an observable value that tracks the editor input for the given - * editor. - * - * @param editor the editor to get the observable for - * @return an observable value that tracks the editor input - * @since 3.110 - */ - public static IObservableValue observeEditorInput(IEditorPart editor) { - Assert.isNotNull(editor); - return WorkbenchProperties.editorInput().observe(editor); - } -} diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/databinding/WorkbenchProperties.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/databinding/WorkbenchProperties.java deleted file mode 100644 index 7c95cbbd61f..00000000000 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/databinding/WorkbenchProperties.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Matthew Hall - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.databinding; - -import org.eclipse.core.databinding.property.list.IListProperty; -import org.eclipse.core.databinding.property.value.IValueProperty; -import org.eclipse.core.runtime.IAdapterManager; -import org.eclipse.core.runtime.Platform; -import org.eclipse.ui.ISelectionService; - -/** - * Factory methods for creating properties for the Workbench. - * - *

- * Examples: - *

- * - *
- * WorkbenchProperties.singleSelection().observe(getSite().getService(ISelectionService.class))
- * 
- * - * @noreference - * @deprecated This class will be removed in a future release. See - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=546822 for more - * information. It has been replaced by the class - * {@link org.eclipse.ui.databinding.typed.WorkbenchProperties}. - * That class creates typed property objects, while this class - * creates raw property objects. - * - * @since 3.5 - */ -@Deprecated -@SuppressWarnings("rawtypes") -public class WorkbenchProperties { - /** - * Returns a value property which observes the source object as the adapted - * type, using the platform adapter manager. If the source is of the target - * type, or can be adapted to the target type, this is used as the value of - * property, otherwise null. - * - * @param adapter the adapter class - * @return a value property which observes the source object as the adapted - * type. - */ - public static IValueProperty adaptedValue(Class adapter) { - return adaptedValue(adapter, Platform.getAdapterManager()); - } - - /** - * Returns a value property which observes the source object as the adapted - * type. If the source object is of the target type, or can be adapted to the - * target type, this is used as the value of property, otherwise - * null. - * - * @param adapter the adapter class - * @param adapterManager the adapter manager used to adapt source objects - * @return a value property which observes the source object as the adapted - * type. - */ - static IValueProperty adaptedValue(final Class adapter, final IAdapterManager adapterManager) { - return org.eclipse.ui.databinding.typed.WorkbenchProperties.adaptedValue(adapter, adapterManager); - } - - /** - * Returns a property for observing the first element of a structured selection - * as exposed by {@link ISelectionService}. - * - * @return an observable value - */ - public static IValueProperty singleSelection() { - return singleSelection(null, false); - } - - /** - * Returns a property for observing the first element of a structured selection - * as exposed by {@link ISelectionService}. - * - * @param partId the part id, or null if the selection can - * be from any part - * @param postSelection true if the selection should be delayed for - * keyboard-triggered selections - * - * @return an observable value - */ - public static IValueProperty singleSelection(String partId, boolean postSelection) { - return org.eclipse.ui.databinding.typed.WorkbenchProperties.singleSelection(partId, postSelection); - } - - /** - * Returns a property for observing the elements of a structured selection as - * exposed by {@link ISelectionService}. - * - * @return an observable value - */ - public static IListProperty multipleSelection() { - return multipleSelection(null, false); - } - - /** - * Returns a property for observing the elements of a structured selection as - * exposed by {@link ISelectionService}. - * - * @param partId the part id, or null if the selection can - * be from any part - * @param postSelection true if the selection should be delayed for - * keyboard-triggered selections - * - * @return an observable value - */ - public static IListProperty multipleSelection(String partId, boolean postSelection) { - return org.eclipse.ui.databinding.typed.WorkbenchProperties.multipleSelection(partId, postSelection); - } -} diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/databinding/package.html b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/databinding/package.html deleted file mode 100644 index 8f650c18949..00000000000 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/databinding/package.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - -Package-level Javadoc - - - -APIs for Workbench properties and observables for use with data binding -

Package Specification

-This package provides APIs that provide access to properties of Workbench objects for -use with the data binding framework. - - - diff --git a/bundles/org.eclipse.ui.workbench/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.workbench/META-INF/MANIFEST.MF index 24448a50bd0..05077f05f48 100644 --- a/bundles/org.eclipse.ui.workbench/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.ui.workbench/META-INF/MANIFEST.MF @@ -18,7 +18,6 @@ Export-Package: org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;x-interna org.eclipse.ui.browser;ui.workbench=split;mandatory:="ui.workbench", org.eclipse.ui.commands, org.eclipse.ui.contexts, - org.eclipse.ui.databinding, org.eclipse.ui.databinding.typed, org.eclipse.ui.dialogs;ui.workbench=split;mandatory:="ui.workbench", org.eclipse.ui.dnd, diff --git a/bundles/org.eclipse.ui/.settings/.api_filters b/bundles/org.eclipse.ui/.settings/.api_filters new file mode 100644 index 00000000000..37e03b5f106 --- /dev/null +++ b/bundles/org.eclipse.ui/.settings/.api_filters @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + +