Bug 133896 [DataBinding] TableModelDescription Needs Enhancement
In moving to latest JFace data binding code on HEAD, I found two issues with the refactored table and collection binding support. 1. TableModelDescription does not support binding to an existing IObservableList. The attached patch address this by adding an alterative contructor taking an IObservableList and a Array of Strings for columns. The patch also includes changes to the ViewersBindingFactory to use this supplied IObservableList instead of attempting to create one from the Property value on the TableModelDescription. 2. Binding a viewer to a collection of objects used to default to using each object's toString() method to determine the row label. The implementation on HEAD wants to bind a IObservableCollectionWithLabels (the observable for viewers) to a IObservableMultiMappingWithDomain. Attempting to bind to a IObservableList generates an exception. One solution is to wrap the IObservableList in a TableModelDescription which will then generate a IObservableMultiMappingWithDomain when createObservable() is called. This is more verbose than I think the solution should be. Attached is a patch which defaultly creates a JavaBeanObservableMultiMapping from the IObservableList and specifies one column based on the toString() method of its objects. This reimplements the previous behavior when binding collections to viewers with one column.
bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/beans/BeanObservableFactory.java
import org.eclipse.jface.internal.databinding.internal.beans.JavaBeanObservableMultiMapping;
import org.eclipse.jface.internal.databinding.internal.beans.JavaBeanObservableValue;
import org.eclipse.jface.internal.databinding.provisional.BindingException;
import org.eclipse.jface.internal.databinding.provisional.DataBindingContext;
import org.eclipse.jface.internal.databinding.provisional.description.Property;
import org.eclipse.jface.internal.databinding.provisional.description.TableModelDescription;
import org.eclipse.jface.internal.databinding.provisional.factories.IObservableFactory;
import org.eclipse.jface.internal.databinding.provisional.observable.IObservable;
import org.eclipse.jface.internal.databinding.provisional.observable.list.IObservableList;
/**
 * A factory for creating observable objects for properties of plain Java
 * objects with JavaBeans-style notification.
 * 
 * This factory supports the following description objects:
 * <ul>
 * <li>org.eclipse.jface.databinding.PropertyDescription:
 * <ul>
 * <li>Returns an observable value representing the specified value property of
 * the given object, if {@link Property#isCollectionProperty()} returns false</li>
 * <li>Returns an observable collection representing the specified collection
 * property of the given object, if {@link Property#isCollectionProperty()}
 * returns false</li>
 * </ul>
 * </li>
 * </ul>
 * 
 * @since 1.0
 * 
 */
final public class BeanObservableFactory implements IObservableFactory {