Project: Eclipse_Platform_UI
Bug 133896 [DataBinding] TableModelDescription Needs Enhancement
Reported: 2006-03-29 12:48:58 | Status: resolved fixed

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.

Files changed in fix:
bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/beans/BeanObservableFactory.java bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/description/TableModelDescription.java bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/viewers/ViewersBindingFactory.java