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

Bug 154132

Summary: [DataBinding] JFace data binding
Product: [Eclipse Project] Platform Reporter: John Arthorne <john.arthorne>
Component: UIAssignee: Boris Bokowski <bokowski>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P4 CC: abuehler, alexberns, bill, bpasero, bradleyjames, c.hauser, chris_42, cloudor, codex69, daved, dev, djo, eclipse, ed.burnette, elias, fct.java, francois, frydzewski, gunnar, hoatranduy, jin.phd, Konstantin.Scheglov, mail, markus.kell.r, mike.haller, mlists, mpcarl, noelgrandin, og, pombredanne, rangwei, rjlorimer, sletelie, stepper, s_potijk, tobias.roeser, villane, wayne, wmitsuda
Version: 3.3Keywords: plan
Target Milestone: 3.3 RC1   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 116920, 118429, 128142, 140644, 147515, 147530, 147563, 153630, 159768, 160000, 164653, 167450, 169637, 171616, 171906, 172193, 177256, 177463, 177770, 183052, 183890    
Bug Blocks:    
Attachments:
Description Flags
refactoring script: moving observables to API packages none

Description John Arthorne CLA 2006-08-16 14:19:42 EDT
In 3.2, we developed a data binding framework for JFace but did not make it generally available. We should continue to work towards providing a public API for this framework and investigate how it will be delivered and used within the SDK.     [UI]
Comment 1 Boris Bokowski CLA 2006-08-16 17:13:11 EDT
*** Bug 104570 has been marked as a duplicate of this bug. ***
Comment 2 Boris Bokowski CLA 2006-08-31 00:33:58 EDT
I have moved a subset of the internal.provisional "API" from org.eclipse.jface.internal.databinding.provisional to org.eclipse.jface.databinding.  Old code should continue to work since I kept all interfaces and classes in org.eclipse.jface.internal.databinding.provisional, but made them extend/implement the new API classes/interfaces. The old types are marked as deprecated.

For the observable.* packages, it does not make sense to keep two copies.  Instead, I will attach refactoring scripts to this bug.  Please shout if you think this is not a good idea.
Comment 3 Boris Bokowski CLA 2006-08-31 21:35:09 EDT
Created attachment 49235 [details]
refactoring script: moving observables to API packages 

Changes released to HEAD >20060831.
Comment 4 Jin CLA 2006-09-04 02:31:10 EDT
good news
Comment 5 Sirp Potijk CLA 2006-09-28 07:03:29 EDT
I've just looked at the latest changes to the JFace databinding framework 1.0.100 in eclipse 3.3M2 and I noticed the BindingFactory had disappeared

I thought this was strange, in my opinion the ability to create custom bindings was one of the strong points of this binding framework. 

At my current project we are evaluating the JFace databinding framework to bind custom user interface components to a set of remote back end objects.

The observable representing a remote attribute or operation should set or get its value asynchronously to make sure it does not block the user interface. 

Our custom 'remote value' binding would consider this by listening to stale events emitted by an observable.

Is the ability to create custom bindings gone for good ? - Or have i missed some other way to retain this behavior ? Is the default value binding going to be listening to stale events in the future ?
Comment 6 Dave Orme CLA 2006-09-28 11:31:46 EDT
(In reply to comment #5)
> I've just looked at the latest changes to the JFace databinding framework
> 1.0.100 in eclipse 3.3M2 and I noticed the BindingFactory had disappeared
> 
> I thought this was strange, in my opinion the ability to create custom bindings
> was one of the strong points of this binding framework. 
> 
> At my current project we are evaluating the JFace databinding framework to bind
> custom user interface components to a set of remote back end objects.
> 
> The observable representing a remote attribute or operation should set or get
> its value asynchronously to make sure it does not block the user interface. 
> 
> Our custom 'remote value' binding would consider this by listening to stale
> events emitted by an observable.
> 
> Is the ability to create custom bindings gone for good ? - Or have i missed
> some other way to retain this behavior ? Is the default value binding going to
> be listening to stale events in the future ?

The short answer:  Please see Bug 147563 for the background discussion behind this. :-)

The somewhat longer answer:  We can't ship an uber-factory as API because that factory needs to aggregate at least SWT, JFace, JavaBeans, and (eventually) EMF dependencies and we don't want to force all of those dependencies on folks.  Actually, since we would like data binding to work on Java Foundation, we're already broken because java.beans is not available on Foundation.

The solution has two parts:

1) Make DataBindingContext accept pairs of compatible Observable types.  ie (IObservableValue, IObservableValue), (IObservableList, IObservableList), and so on.  This eliminates some of the run-time checks we had before and allows Eclipse to provide better content assist when writing code.

2) Instead of having a single uber factory, have a single specialized factory for each dependency.  So we now have SWTObservables, BeanObservables, and so on.  You can write your own RemoteObservables or whatever you want to call it in order to support your own custom observables on remote objects.

If you want to, you are still free to create your own uber-factory for your own application.  I know that at my current client, we will do that (we actually already have; we'll just update it when we move to the new API), so while there might be more configuration and less convention, you can still do what you need to do.  The flip side of the convention over configuration debate is that when writing API, it is important to make sure that your conventions are exactly right because at Eclipse, we don't change APIs.  If we find a good way to do it, we can always add the uber-factory back later, but if we decide we hate it, we can't take it back once we've made it API.

Lastly, we haven't totally settled on the exact syntax the factories will use.  If you'd like to participate in the discussion, please join us at Bug 147563.
Comment 7 Boris Bokowski CLA 2006-09-28 13:41:47 EDT
(In reply to comment #5)
> I've just looked at the latest changes to the JFace databinding framework
> 1.0.100 in eclipse 3.3M2 and I noticed the BindingFactory had disappeared
> 
> I thought this was strange, in my opinion the ability to create custom bindings
> was one of the strong points of this binding framework. 

With the new API, you can create your own Binding subclass, instantiate it and add the binding instance to your context if you want this binding to be included when the context collects validation errors.
Comment 8 Sirp Potijk CLA 2006-09-29 03:33:44 EDT
It seems I've been too fast in posting my concerns and overlooked the new .addBinding function in the DataBindingContext. 

I should have known to look better as I already thought it was strange for the ability to create custom bindings to go missing.

Anyway, sorry to bother you and thanks for the great work !
Comment 9 Willem Verstraeten CLA 2006-10-04 06:21:29 EDT
The way I understand it, the update policy (ie. DataBindingContext.TIME_EARLY and DataBindingContext.TIME_LATE) currently is enforced by the IObservableValue. Eg. the SWTObservableFactory has a setter #setUpdateTime(int), that creates instances of IObservableValue according to the policy.

Wouldn't it be preferable to move this behaviour to the actual binding? This way the implementations of IObservableValue can remain very simple, as one does not have to take the several different policies into account.
Comment 10 Brad Reynolds CLA 2006-10-04 08:49:50 EDT
(In reply to comment #9)
> The way I understand it, the update policy (ie. DataBindingContext.TIME_EARLY
> and DataBindingContext.TIME_LATE) currently is enforced by the
> IObservableValue. Eg. the SWTObservableFactory has a setter
> #setUpdateTime(int), that creates instances of IObservableValue according to
> the policy.

In the latest version of Databinding this is no longer the case as SWTObservableFactory is deprecated.  For the replacement to this functionality see SWTObservables.getText(...). 
 
> Wouldn't it be preferable to move this behaviour to the actual binding? This
> way the implementations of IObservableValue can remain very simple, as one does
> not have to take the several different policies into account.

It needs to be at the observable level as this tells the observable when to fire change events.  In the case of Text this means the events need to be fired on Modify rather than FocusOut.

Comment 11 Willem Verstraeten CLA 2006-10-04 09:14:53 EDT
(In reply to comment #10)

My mistake, I confused the purpose of the TIME_* constants with that of the POLICY_* constants. The scenario I had in mind was the scenario where you have to push an "OK" button or sth similar, and looking at the code I mistakenly thought that it was the responsibilty of the IObservableValue to wait for that event to happen iso the Binding itself. I have since seen however that one can specify this behaviour in the BindSpec (through the #setModelUpdatePolicy(int) and #setTargetUpdatePolicy(int) methods), and that this behaviour is indeed part of the Binding.

> (In reply to comment #9)
> > The way I understand it, the update policy (ie. DataBindingContext.TIME_EARLY
> > and DataBindingContext.TIME_LATE) currently is enforced by the
> > IObservableValue. Eg. the SWTObservableFactory has a setter
> > #setUpdateTime(int), that creates instances of IObservableValue according to
> > the policy.
> 
> In the latest version of Databinding this is no longer the case as
> SWTObservableFactory is deprecated.  For the replacement to this functionality
> see SWTObservables.getText(...). 
> 
> > Wouldn't it be preferable to move this behaviour to the actual binding? This
> > way the implementations of IObservableValue can remain very simple, as one does
> > not have to take the several different policies into account.
> 
> It needs to be at the observable level as this tells the observable when to
> fire change events.  In the case of Text this means the events need to be fired
> on Modify rather than FocusOut.
> 

Comment 12 Willem Verstraeten CLA 2006-10-04 09:55:43 EDT
Is it possible that the behaviour described above (about waiting for an OK button) is not yet implemented in the current code ?
Comment 13 Brad Reynolds CLA 2006-10-04 11:46:43 EDT
A couple of bugs off the top of my head that I'd like to see resolved before the official release.

bug 140644 - [DataBinding] Binding to ValidationError of DataBindingContext is broken
bug 147563 - [DataBinding] Need a standard factory for data binding contexts
bug 128142 - [DataBinding] IDomainValidator needs to provide partial validation / be merged with IValidator

The javadoc for IDomainValidator states "FIXME: This is wrong.".


Comment 14 Boris Bokowski CLA 2006-10-04 12:55:02 EDT
agree.
Comment 15 Boris Bokowski CLA 2006-10-04 13:53:28 EDT
(In reply to comment #12)
> Is it possible that the behaviour described above (about waiting for an OK
> button) is not yet implemented in the current code ?

You are right, it is not implemented yet.  I have filed bug 159768 for this.
Comment 16 Boris Bokowski CLA 2006-10-04 23:00:44 EDT
Here is another issue I would like to investigate (ideally solve) before finalizing the API: bug 116920 - [DataBinding] need to handle model change events which don't happen in the UI thread

Here is a question for cc list members: Does anyone know about the problems (or solutions) when tring to use the Observer pattern in a concurrent environment, with notifications that are incremental?  Responses on bug 116920 please.

Observer: I*ChangeListener
Subject: IObservable
concurrent environment: model change events on one thread, widgets can only be accessed on another thread
incremental notifications: This is not an issue for IObservableValue, but is important for IObservableList/IObservableSet
Comment 17 Brad Reynolds CLA 2006-10-06 08:47:56 EDT
Since we're planning...

bug 160000 - [DataBinding] Convert scenarios to official APIs
Comment 18 Boris Bokowski CLA 2006-11-04 14:30:46 EST
Just a heads up - as per discussion on bug 153630, the data binding plug-ins will be renamed as follows:

org.eclipse.core.databinding
  (core data binding framework, requires only org.eclipse.equinox.common,
   contains general-purpose observables, converters, validators, bindings)
org.eclipse.core.databinding.beans
  (beans observables)
org.eclipse.jface.databinding
  (SWT and JFace observables)

This will happen early in the 3.3 M4 development cycle.
Comment 19 Boris Bokowski CLA 2006-11-10 13:17:47 EST
The plug-ins have been renamed, and the changes for bug 116920 (concurrency) are in the new plug-ins in HEAD.

I have given up on keeping the old API functional (sorry for that - it was just too much work), so basically this will be a big bang kind of change for those of you who already used the old API.
Comment 20 Brad Reynolds CLA 2006-12-05 01:03:10 EST
We also need to add dependencies on:
* bug 118429
* bug 147530
* bug 164653
Comment 21 Brad Reynolds CLA 2007-01-18 23:50:27 EST
Adding bug 147515 - [DataBinding] separate run-time type information from IObservable
Comment 22 Boris Bokowski CLA 2007-05-15 23:09:42 EDT
Marking as fixed.
Comment 23 Boris Bokowski CLA 2007-05-18 10:29:35 EDT
Marking as verified.
Comment 24 Dave Orme CLA 2007-05-18 10:38:17 EDT
This is truly a milestone for Eclipse Data Binding.

I'd like to publicly thank everyone who made this possible, especially Boris Bokowski, Brad Reynolds and everyone who has submitted bug reports, feedback, and patches!


Dave Orme
Comment 25 Dave Orme CLA 2007-05-18 10:42:47 EDT
I shouldn't have forgotten to mention Gili Mendel and the whole former VE team for helping get this effort off the ground to begin with.  Without them, we couldn't be where we are today.

Thanks!
Comment 26 Chris Aniszczyk CLA 2007-05-18 18:21:39 EDT
congrats guys!