|Getting info on databinding synchronization / maybe Extending DatabindingContext? [message #698929]
||Wed, 20 July 2011 13:52
| Daniel iCanHasLastName
Registered: May 2011
as i am struggling to dive into the matters of databinding i would like to ask following question:
Which would be an appreciated way to get informed of changes in the Binding-Target(Text-Widget) which are getting propagated to the Model (Property in Class) ?
- I have for example a Class containing 15 String-Properties and i use databinding to bind these String-Properties to Text-Widgets in a SWT-ViewPart.
- I also have a Save-Button on said SWT-ViewPart which should only get setEnabled(true) if any of these Textfields got changed via manual input.
Solutions which i was thinking of:
- attach a ModifyListener (or smth. like that) to all Textfields and call setEnabled() when one of the listeners get fired. (cannot be the "right" solution, can it?)
- Extend the DatabindingContext to get informed of any Binding-Synchonization happening? (But i have not found where i could listen on some event)
I really would like to gain insight into the "more right way" (tm) to handle this stuff, so if you cannot explicitly answer my question but have some URL which you could point me to, i would be happy to get that bit of help, too!
Thank you for reading so much Text and have a nice Day/Evening/Night/Spacetriptime/Whatever
As i am murking around in the various resources available (wiki, forum, tutorials, etc) i am thinking that the following might be of interest in my case.
wiki.eclipse.org/JFace_Data_Binding/TrackedGetter (i am not allowed to put an URL in here until i have spammed some posts )
I am currently finding out if i am able to put org.eclipse.jface.internal.databinding.provisional.swt.ControlUpdater to good use ...
Is there maybe anyone out there who might have tips or helpful advice concerning the use of ControlUpdater for me?
I have finally a solution which propably works for me ... but i am rather sure that there is a "more correct" way of handling this.
My "wanted behaviour" was to have a Save-Button that gets enabled when User changes Text in Data that was supplied to UI via Databinding.
I was able to get this behaviour via programmatically adding/removing a specific ChangeListener to all Binding.getTarget() that were returned from DataBindingContext.getBindings()
I am removing the Targets ChangeListeners before the model gets loaded from database (as this change is automatically and nothing which should enable a Save-Button), then i load the model from database and afterwards i iterate through the Bindings again and re-add the said ChangeListener.
Inside the Changelistener all that is happening currently is btnSave.setEnabled(true)
This currently "works for me" ... but if you out there have a better and "more correct" way ... i am very interested in hearing it! (as i deeply hope that this kind of stuff can be handled more clean in another way somehow)
[Updated on: Wed, 20 July 2011 17:24]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.03225 seconds