Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » DataBinding with Image on Label: no Change Event?
DataBinding with Image on Label: no Change Event? [message #1781470] Wed, 07 February 2018 15:29 Go to next message
Christian Eugster is currently offline Christian EugsterFriend
Messages: 177
Registered: July 2009
Location: St. Gallen Switzerland
Senior Member
Hi all,
after searching the net without success I ask at this place:

in a (editor) part (e4, Oxygen) of my rcp I use data binding between model and widgets. One of those is a label, that is used to display an image. The user can select an image from local computer by clicking on a button and choosing an image with FileDialog.
When chosen, I use label.setImage(Image) to set the image. Though I added data binding to the label and the model nothing happens:

My code looks as follows:
ISWTObservableValue passwordValue = WidgetProperties.text(SWT.Modify).observe(this.password);
IObservableValue<String> passwordObservable = BeanProperties.value(SystemUser.FIELD_PASSWORD).observe(this.getEntity());
this.passwordBinding = this.dataBindingContext.bindValue(passwordValue, passwordObservable);

ISWTObservableValue imageValue = WidgetProperties.image().observe(this.systemUserImage);
IObservableValue<Image> imageObservable = BeanProperties.value(SystemUser.FIELD_IMAGE).observe(this.getEntity());
this.imageBinding = this.dataBindingContext.bindValue(imageValue, imageObservable);

The first example with text does it's job without complaining, but the second one with the image does not do anything.

Do you have a suggestion, what I am doing wrong? Thank you very much!
Re: DataBinding with Image on Label: no Change Event? [message #1781480 is a reply to message #1781470] Wed, 07 February 2018 17:31 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 870
Registered: January 2012
Senior Member

Unlike Text widgets, Label widgets don't send events on image or text changes. So unfortunately this won't work: you can't observe things that are not observable.

Since you're setting the image, I think you could trigger a change by using `imageObservable.setValue(newImage)`.

Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:Missing minimize, maximize buttons in Dialog on Linux
Next Topic:ErrorDialog.openError IStatus character limit
Goto Forum:

Current Time: Tue Jan 28 06:44:34 GMT 2020

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

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

Back to the top