Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Getting info on databinding synchronization / maybe Extending DatabindingContext?(I am interested in practices concerning the notification of synchronizationEvents)
Getting info on databinding synchronization / maybe Extending DatabindingContext? [message #698929] Wed, 20 July 2011 13:52 Go to next message
Daniel iCanHasLastName is currently offline Daniel iCanHasLastName
Messages: 6
Registered: May 2011
Junior Member
Hello everyone,

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) ?

Example:

  1. 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.
  2. 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 Smile

Edit:

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 Wink )

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?

MTIA, Daniel

Edit 2:
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

Re: Getting info on databinding synchronization / maybe Extending DatabindingContext? [message #699750 is a reply to message #698929] Fri, 22 July 2011 08:53 Go to previous message
Christoph Keimel is currently offline Christoph Keimel
Messages: 368
Registered: December 2010
Location: Germany
Senior Member
Hi,

I am doing something similar. In my case I enable the "Finish" Button of a JFace Wizard only if all Validations have been OK. Otherwise I set an Error-Message in the Title of the Wizard. This is done in "checkPageStatus(status)". The Part of the Code you are interested in would be this:

validateStatus = new AggregateValidationStatus(bindingContext, AggregateValidationStatus.MAX_SEVERITY);
validateStatus.addChangeListener(new IChangeListener() {
	@Override
	public void handleChange(ChangeEvent event) {
		final IStatus status = (IStatus) validateStatus.getValue();
		Display.getCurrent().asyncExec(new Runnable() {
			@Override
			public void run() {
				if (!parent.isDisposed())
					checkPageStatus(status);
			}
		});
	}
});


Hope this helps,
Christoph
Previous Topic:Problem with showing ProgressMonitorDialog from another modal dialog
Next Topic:Customizing JFace Wizard Layout
Goto Forum:
  


Current Time: Thu Oct 23 11:55:14 GMT 2014

Powered by FUDForum. Page generated in 0.14589 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software