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 |
|
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 #658029 is a reply to message #658011] |
Sat, 05 March 2011 08:50 |
|
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 #658099 is a reply to message #658058] |
Sun, 06 March 2011 12:26 |
|
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 |
Ed Merks Messages: 33216 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/
|
|
| | |
Goto Forum:
Current Time: Thu Sep 19 02:49:39 GMT 2024
Powered by FUDForum. Page generated in 0.04973 seconds
|