Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 234496

Summary: [DataBinding] ObservableValueEditingSupport: option to use IObservableFactory instead of subclassing
Product: [Eclipse Project] Platform Reporter: Matthew Hall <qualidafial>
Component: UIAssignee: Matthew Hall <qualidafial>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: bokowski, nacor, tom.schindl
Version: 3.4   
Target Milestone: 3.5 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Add static method ObservableValueEditingSupport.create()
none
CellEditorObservables
none
Patch
none
Patch
none
mylyn/context/zip
none
snippet (as patch) none

Description Matthew Hall CLA 2008-05-28 17:09:41 EDT
Will attach patch
Comment 1 Matthew Hall CLA 2008-05-28 17:12:27 EDT
Created attachment 102521 [details]
Add static method ObservableValueEditingSupport.create()
Comment 2 Matthew Hall CLA 2008-05-28 17:28:22 EDT
Created attachment 102527 [details]
CellEditorObservables
Comment 3 Matthew Hall CLA 2008-05-28 17:32:18 EDT
Boris, with this patch you can set up EditingSupport with databinding as follows:

viewerColumn.setEditingSupport(
   ObservableValueEditingSupport.create(
       viewer, dbc, cellEditor,
       CellEditorObservables.valueFactory(),
       BeansObservables.valueFactory(realm, propertyName) ) );
Comment 4 Matthew Hall CLA 2009-02-10 15:37:21 EST
We should implement this as CellEditorProperties, and add static methods to ObservableValueEditingSupport to accept IObservableFactories.

Thus the following:

viewerColumn.setEditingSupport(new ObservableValueEditingSupport(viewer, dbc) {
		protected IObservableValue doCreateCellEditorObservable(CellEditor cellEditor) {
			return SWTObservables.observeText(cellEditor.getControl(), SWT.Modify);
		}

		protected IObservableValue doCreateElementObservable(Object element, ViewerCell cell) {
			return BeansObservables.observeValue(element, "name");
		}
	} );

could be simply:

viewerColumn.setEditingSupport(ObservableValueEditingSupport.create(
	viewer, dbc, WidgetProperties.text(SWT.Modify).valueFactory(), BeanProperties.value("name").valueFactory() );
	
We could also introduce ValuePropertyEditingSupport as a convenience class:

viewerColumn.setEditingSupport(ValuePropertyEditingSupport.create(
	viewer, dbc, WidgetProperties.text(SWT.Modify), BeanProperties.value("name") );
Comment 5 Matthew Hall CLA 2009-03-08 11:47:29 EDT
Created attachment 127953 [details]
Patch
Comment 6 Matthew Hall CLA 2009-03-09 18:51:27 EDT
Created attachment 128120 [details]
Patch
Comment 7 Matthew Hall CLA 2009-03-09 18:51:29 EDT
Created attachment 128121 [details]
mylyn/context/zip
Comment 8 Matthew Hall CLA 2009-03-09 18:52:03 EDT
Boris, any chance of squeezing this one in?
Comment 9 Boris Bokowski CLA 2009-03-09 22:17:06 EDT
Created attachment 128130 [details]
snippet (as patch)

This is a simplified version of the snippet contributed by Heiko Ahrens on bug 267712.
Comment 10 Boris Bokowski CLA 2009-03-09 22:19:41 EDT
Heiko, I simplified your snippet a bit based on this last little bit of data binding API for 3.5.
Comment 11 Matthew Hall CLA 2009-03-09 23:29:41 EDT
Released > 20090309