Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » DataBinding for a combobox which holds a Elist from a model
DataBinding for a combobox which holds a Elist from a model [message #658009] Fri, 04 March 2011 23:23 Go to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Hi to all,

I want to implement a master-detail (list and detaileditor) which contains a combobox.
There is shown a list of recipients in the list.
in the combobox there is shown a reference in the Recipient-class with the name master, which references another recipient from the list. This should be selected with the combobox.

Now I want to implement a databinding, but don't know how to do this. My code leads to an

java.lang.NoSuchMethodException: org.eclipse.aid.model.Aid.impl.RecipientImpl.addPropertyChan geListener(java.beans.PropertyChangeListener)
at java.lang.Class.getMethod(Class.java:1622)
at org.eclipse.core.internal.databinding.beans.BeanPropertyList enerSupport.processListener(BeanPropertyListenerSupport.java :96)
at org.eclipse.core.internal.databinding.beans.BeanPropertyList enerSupport.hookListener(BeanPropertyListenerSupport.java:44 )
at org.eclipse.core.internal.databinding.beans.BeanPropertyList ener.doAddTo(BeanPropertyListener.java:56)
at org.eclipse.core.databinding.property.NativePropertyListener .addTo(NativePropertyListener.java:41)
at org.eclipse.core.internal.databinding.property.value.SimpleP ropertyObservableValue$3.run(SimplePropertyObservableValue.j ava:83)
at org.eclipse.core.databinding.observable.Realm$1.run(Realm.ja va:148)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.databinding.observable.Realm.safeRun(Realm. java:152)
at org.eclipse.core.databinding.observable.Realm.exec(Realm.jav a:170)
at org.eclipse.core.internal.databinding.propert



This is my code: (tabViewerRec = Table of items, cmbMaster is combobox that should contain the selection

widgetValue = WidgetProperties.selection().observe(cmbMaster);
selection = ViewersObservables.observeSingleSelection(tabViewerRec);
modelValue = BeansObservables.observeDetailValue(selection, "master", Recipient.class);
bindingContext.bindValue(widgetValue, modelValue);


Would be nice, if you could help me

Best regards
Markus

[Updated on: Fri, 04 March 2011 23:23]

Report message to a moderator

Re: DataBinding for a combobox which holds a Elist from a model [message #658011 is a reply to message #658009] Sat, 05 March 2011 00:18 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Markus,

Shouldn't you be using the EMFObservables or EMFEditObservables rather
than the Bean one?


Markus Oley wrote:
> Hi to all,
> I want to implement a master-detail (list and detaileditor) which
> contains a combobox. There is shown a list of recipients in the list.
> in the combobox there is shown a reference in the Recipient-class
> with the name master, which references another recipient from the
> list. This should be selected with the combobox.
> Now I want to implement a databinding, but don't know how to do this.
> My code leads to an
> java.lang.NoSuchMethodException:
> org.eclipse.aid.model.Aid.impl.RecipientImpl.addPropertyChan
> geListener(java.beans.PropertyChangeListener)
> at java.lang.Class.getMethod(Class.java:1622)
> at org.eclipse.core.internal.databinding.beans.BeanPropertyList
> enerSupport.processListener(BeanPropertyListenerSupport.java :96)
> at org.eclipse.core.internal.databinding.beans.BeanPropertyList
> enerSupport.hookListener(BeanPropertyListenerSupport.java:44 )
> at org.eclipse.core.internal.databinding.beans.BeanPropertyList
> ener.doAddTo(BeanPropertyListener.java:56)
> at org.eclipse.core.databinding.property.NativePropertyListener
> .addTo(NativePropertyListener.java:41)
> at org.eclipse.core.internal.databinding.property.value.SimpleP
> ropertyObservableValue$3.run(SimplePropertyObservableValue.j ava:83)
> at org.eclipse.core.databinding.observable.Realm$1.run(Realm.ja
> va:148)
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
> at org.eclipse.core.databinding.observable.Realm.safeRun(Realm.
> java:152)
> at org.eclipse.core.databinding.observable.Realm.exec(Realm.jav
> a:170)
> at org.eclipse.core.internal.databinding.propert
>
>
>
> This is my code: (tabViewerRec = Table of items, cmbMaster is combobox
> that should contain the selection
>
> widgetValue = WidgetProperties.selection().observe(cmbMaster);
> selection =
> ViewersObservables.observeSingleSelection(tabViewerRec);
> modelValue = BeansObservables.observeDetailValue(selection,
> "master", Recipient.class);
> bindingContext.bindValue(widgetValue, modelValue);


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: DataBinding for a combobox which holds a Elist from a model [message #658029 is a reply to message #658011] Sat, 05 March 2011 08:50 Go to previous messageGo to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Hi Ed,

thank you for your fast answer.
These are my first steps with the combination of JFace/EMF and I'm new to JFace-Databinding.

So it is in all propability that my approach is wrong.
Do you have a codesnippet somewhere, where this problem is solved? Or a tutorial how to use JFace-Databinding together with EMF? Would be very helpful.

Thanks by now,

Best regards
Markus
Re: DataBinding for a combobox which holds a Elist from a model [message #658058 is a reply to message #658029] Sat, 05 March 2011 17:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010706010903090601020501
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Markus,

Googling "EMF Databinding" turns up a bunch of good sources of
information including

http://tomsondev.bestsolution.at/2009/06/06/galileo-emf-data binding-part-1/


Markus Oley wrote:
> Hi Ed,
> thank you for your fast answer. These are my first steps with the
> combination of JFace/EMF and I'm new to JFace-Databinding.
> So it is in all propability that my approach is wrong. Do you have a
> codesnippet somewhere, where this problem is solved? Or a tutorial how
> to use JFace-Databinding together with EMF? Would be very helpful.
>
> Thanks by now,
> Best regards
> Markus

--------------010706010903090601020501
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Markus,<br>
<br>
Googling "EMF Databinding" turns up a bunch of good sources of
information including<br>
<blockquote><a
href=" http://tomsondev.bestsolution.at/2009/06/06/galileo-emf-data binding-part-1/"> http://tomsondev.bestsolution.at/2009/06/06/galileo-emf-data binding-part-1/</a><br>
</blockquote>
<br>
Markus Oley wrote:
<blockquote cite="mid:ikst4a$t4k$1@news.eclipse.org" type="cite">Hi Ed,
<br>
thank you for your fast answer. These are my first steps with the
combination of JFace/EMF and I'm new to JFace-Databinding. <br>
So it is in all propability that my approach is wrong. Do you have a
codesnippet somewhere, where this problem is solved? Or a tutorial how
to use JFace-Databinding together with EMF? Would be very helpful.
<br>
<br>
Thanks by now, <br>
Best regards
<br>
Markus
<br>
</blockquote>
</body>
</html>

--------------010706010903090601020501--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: DataBinding for a combobox which holds a Elist from a model [message #658065 is a reply to message #658058] Sat, 05 March 2011 20:38 Go to previous messageGo to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
OK, thank a lot... I will look
Re: DataBinding for a combobox which holds a Elist from a model [message #658069 is a reply to message #658058] Sat, 05 March 2011 22:37 Go to previous messageGo to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Hi Ed,

sorry, but these examples don't work for me, since the signatures of some methods changed. Could you please give me any further hints?

Thanks by now,

Markus
Re: DataBinding for a combobox which holds a Elist from a model [message #658099 is a reply to message #658058] Sun, 06 March 2011 12:26 Go to previous messageGo to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Hi again Ed,

experimenting a little bit, I found the solution (snippet below). The only problem is, that this is an attribute, which can be null. How can I fill an empty entry, which maps to null?

Best regards
Markus






Snippet:
IViewerObservableValue widgetValue2 = ViewersObservables.observeSingleSelection(comboviewer);
EStructuralFeature eStructuralFeature = recClass.getEStructuralFeature(AidPackage.RECIPIENT__MASTER) ;
IObservableValue modelValue = EMFObservables.observeDetailValue(Realm.getDefault(), selection, eStructuralFeature);
EMFEditObservables.observeDetailValue(Realm.getDefault(),
AdapterFactoryEditingDomain.getEditingDomainFor(currentRec),
modelValue, eStructuralFeature);

bindingContext.bindValue(widgetValue2, modelValue);


Re: DataBinding for a combobox which holds a Elist from a model [message #658110 is a reply to message #658099] Sun, 06 March 2011 16:15 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Markus,

Comments below.

Markus Oley wrote:
> Hi again Ed,
> experimenting a little bit, I found the solution (snippet below). The
> only problem is, that this is an attribute, which can be null. How can
> I fill an empty entry, which maps to null?
I'm not a data binding expert, so I don't really know what you're asking
specifically, but I do know that in general, making a distinction
between null and the empty string is problematic in text widgets. It
seems a general problem but there is no general solution. It's just an
additional state that's not well represented by just a text widget.
>
> Best regards Markus
>
>
>
>
>
>
> Snippet:
> IViewerObservableValue widgetValue2 =
> ViewersObservables.observeSingleSelection(comboviewer);
> EStructuralFeature eStructuralFeature =
> recClass.getEStructuralFeature(AidPackage.RECIPIENT__MASTER) ;
There's AidPackage.Literals.RECIPIENT__MASTER already available.
> IObservableValue modelValue =
> EMFObservables.observeDetailValue(Realm.getDefault(), selection,
> eStructuralFeature);
> EMFEditObservables.observeDetailValue(Realm.getDefault(),
>
> AdapterFactoryEditingDomain.getEditingDomainFor(currentRec),
> modelValue, eStructuralFeature);
>
> bindingContext.bindValue(widgetValue2, modelValue);
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: DataBinding for a combobox which holds a Elist from a model [message #658213 is a reply to message #658110] Mon, 07 March 2011 12:36 Go to previous messageGo to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Hi Ed,

OK, thank you
Re: DataBinding for a combobox which holds a Elist from a model [message #658219 is a reply to message #658213] Mon, 07 March 2011 13:00 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
The null conversion is something your IConverter has to handle. So you
need to use the bindValue() method which accepts 4 params.

It's also not clear from your code if you are using an
EMFDatabindingContext or DatabindingContext. Make sure you use the
EMFDatabindingContext!

Tom

Am 07.03.11 13:36, schrieb Markus Oley:
> Hi Ed,
> OK, thank you
Previous Topic:Data Binding for Android?
Next Topic:[databinding] JUnit tests, howto ?
Goto Forum:
  


Current Time: Fri Mar 29 02:33:46 GMT 2024

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

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

Back to the top