Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF List databinding
EMF List databinding [message #431457] Sat, 11 July 2009 08:46 Go to next message
Matt Biggs is currently offline Matt BiggsFriend
Messages: 71
Registered: July 2009
Member
I am struggling to get EMF List databinding working with a tableviewer,
and am unsure if i am using the correct functionality.

In eclipse 3.4 i use to use:

final IObservableList property = EMFEditObservables.observeList(
editingDomain,
eObject,
FamilytreePackage.Literals.FAMILY__SOURCES
);
return property;

The equivalent in 3.5 appears to be:

final IEMFEditListProperty property = EMFEditProperties.list(
editingDomain,
FamilytreePackage.Literals.FAMILY__SOURCES
);
return property.observe(eObject);

However, this returns no values and the table remains empty. If i change
the 3.5 version to use multiList with a single EList it works. Eg:

final IEMFEditListProperty property = EMFEditProperties.multiList(
editingDomain,
FamilytreePackage.Literals.FAMILY__SOURCES
);
return property.observe(eObject);


Is this a bug or is my use of EMFEditProperties.list() incorrect?

Thanks

Matt
Re: EMF List databinding [message #431465 is a reply to message #431457] Sat, 11 July 2009 12:08 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6512
Registered: July 2009
Senior Member
Hi Matt,

Your usage is completely correct but I'm quite sure we are not having a
bug in our implementation also :-) That's why I started writing
JUnit-Tests after reading your post and can't reproduce it!

Are you sure you are not getting some exception or the eObject-instance
passed in is not the one you expect it to be.

An even stranger thing is you say Multi-List works because under the
covers we are simply creating an IEMFEditListProperty for every sublist.

Anyways I've added 2 Test-Plugins in CVS (the test suite is quite empty
though:-) and implemented a Test for EMFEditProperties#list() - maybe
you can extend the suite with a TestCase I can use to reproduce the
problem locally.

The plugins in question are:
-org.eclipse.emf/org.eclipse.emf/tests/org.eclipse.emf.test. databinding
-org.eclipse.emf/org.eclipse.emf/tests/org.eclipse.emf.test. databinding.edit

Please file a bug with an TestCase and then we can take a look and see
what's going wrong.

Tom

Matt Biggs schrieb:
> I am struggling to get EMF List databinding working with a tableviewer,
> and am unsure if i am using the correct functionality.
> In eclipse 3.4 i use to use:
>
> final IObservableList property = EMFEditObservables.observeList(
> editingDomain, eObject,
> FamilytreePackage.Literals.FAMILY__SOURCES
> );
> return property;
>
> The equivalent in 3.5 appears to be:
>
> final IEMFEditListProperty property = EMFEditProperties.list(
> editingDomain,
> FamilytreePackage.Literals.FAMILY__SOURCES
> );
> return property.observe(eObject);
>
> However, this returns no values and the table remains empty. If i change
> the 3.5 version to use multiList with a single EList it works. Eg:
>
> final IEMFEditListProperty property = EMFEditProperties.multiList(
> editingDomain,
> FamilytreePackage.Literals.FAMILY__SOURCES
> );
> return property.observe(eObject);
>
>
> Is this a bug or is my use of EMFEditProperties.list() incorrect?
>
> Thanks
>
> Matt
>
Re: EMF List databinding [message #431466 is a reply to message #431465] Sat, 11 July 2009 13:33 Go to previous messageGo to next message
Matt Biggs is currently offline Matt BiggsFriend
Messages: 71
Registered: July 2009
Member
Hi Tom,

It did indeed confuse me too, as when i looked i also noticed multiList
just wraps up list().

The method that appears to be going wrong for me is the
internalRefresh(Object element, boolean updateLabels) within the
AbstractTableViewer class.

Using multiList the call to equals(element, getRoot()) returns true as
the element and the getRoot() both return MultiList objects and the
equals method in MultiList checks if the two object == each other.

When i use a list() the element is an EMFEditObservableListDecorator
class. This then uses the equals() method of the
DecoratingObservableCollection class which instead of comparing itself
to the object passed in, tries to compare the object passed in to its
'decorated' field which is a SimpleObservableList class.

Therefore nothing gets populated.


I will try and knock up a quick test case to see if i can reproduce it
within your plugin.

In the meantime, maybe my poor explanation may shed some light? :)

cheers

Matt
Re: EMF List databinding [message #431468 is a reply to message #431466] Sat, 11 July 2009 14:38 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6512
Registered: July 2009
Senior Member
Hi,

This sounds very familiar to me indeed [1] but this then is IMHO an
upstream problem because we are inherting this from the core so e.g.
BeanObservables should have the same problem, not?

Can you show me the code you are using to setup the viewer?

Tom

[1] http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg3 4104.html

Matt Biggs schrieb:
> Hi Tom,
>
> It did indeed confuse me too, as when i looked i also noticed multiList
> just wraps up list().
>
> The method that appears to be going wrong for me is the
> internalRefresh(Object element, boolean updateLabels) within the
> AbstractTableViewer class.
>
> Using multiList the call to equals(element, getRoot()) returns true as
> the element and the getRoot() both return MultiList objects and the
> equals method in MultiList checks if the two object == each other.
>
> When i use a list() the element is an EMFEditObservableListDecorator
> class. This then uses the equals() method of the
> DecoratingObservableCollection class which instead of comparing itself
> to the object passed in, tries to compare the object passed in to its
> 'decorated' field which is a SimpleObservableList class.
>
> Therefore nothing gets populated.
>
>
> I will try and knock up a quick test case to see if i can reproduce it
> within your plugin.
>
> In the meantime, maybe my poor explanation may shed some light? :)
>
> cheers
>
> Matt
Re: EMF List databinding [message #431469 is a reply to message #431466] Sat, 11 July 2009 14:45 Go to previous messageGo to next message
Matt Biggs is currently offline Matt BiggsFriend
Messages: 71
Registered: July 2009
Member
Tom,

I have finally got to the bottom of the problem. I added my testcase to
your test plugins and (unfortunately for me) it worked perfectly as you
suggested.

Within my main app, i neglected to say i am also using teneo.

When the comparison is done normally, the containment collection is an
EObjectContainmentEList which uses the equals method of AbstractEList
which tests equality of its children and not the containing class itself.

When using teneo the collection is a HibernatePersistableEList which
uses the equals method of PersistableEList.

This eqauls method here simply has the below code.


/**
* Is overridden because it can't use delegates for equality because
the delegate (a hibernate or jpox list) will
* try to be equal with this persistable elist.
*
* This method does jvm instance equality because doing a full-fledge
equal would result in a load of the list.
*/
@Override
public boolean equals(Object object) {
return this == object;
}


Therefore, the two containing collections aren't the exact same object
and it fails to populate.

I appologise for suggesting it was a databinding issue :p

It is infact a teneo issue. I wonder if Martin can comment on it.
Perhaps the workaround is simply to use a Multilist with a single list
inside it, so the MultiList equals method is used instead of
PersistableELists.
Re: EMF List databinding [message #431470 is a reply to message #431469] Sat, 11 July 2009 14:49 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6512
Registered: July 2009
Senior Member
Hi,

See the reference thread and use an IElementComparer - I think teneo
can't do anything different else it would have to populate the list.

Tom

Matt Biggs schrieb:
> Tom,
>
> I have finally got to the bottom of the problem. I added my testcase to
> your test plugins and (unfortunately for me) it worked perfectly as you
> suggested.
>
> Within my main app, i neglected to say i am also using teneo.
>
> When the comparison is done normally, the containment collection is an
> EObjectContainmentEList which uses the equals method of AbstractEList
> which tests equality of its children and not the containing class itself.
>
> When using teneo the collection is a HibernatePersistableEList which
> uses the equals method of PersistableEList.
>
> This eqauls method here simply has the below code.
>
>
> /**
> * Is overridden because it can't use delegates for equality because
> the delegate (a hibernate or jpox list) will
> * try to be equal with this persistable elist.
> *
> * This method does jvm instance equality because doing a
> full-fledge equal would result in a load of the list.
> */
> @Override
> public boolean equals(Object object) {
> return this == object;
> }
>
>
> Therefore, the two containing collections aren't the exact same object
> and it fails to populate.
>
> I appologise for suggesting it was a databinding issue :p
>
> It is infact a teneo issue. I wonder if Martin can comment on it.
> Perhaps the workaround is simply to use a Multilist with a single list
> inside it, so the MultiList equals method is used instead of
> PersistableELists.
Re: EMF List databinding [message #431471 is a reply to message #431470] Sat, 11 July 2009 15:01 Go to previous message
Matt Biggs is currently offline Matt BiggsFriend
Messages: 71
Registered: July 2009
Member
Tom,

Thanks, That works. Although i changed the instanceof to use
IEMFEditObservable instead of EditingDomainEObjectObservableList.


Cheers for the help. Took a while to get the root cause.
Previous Topic:how to create a stand alone plugin foom EMF model
Next Topic:Java Generics Code Generation
Goto Forum:
  


Current Time: Sat Dec 14 17:53:08 GMT 2019

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

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

Back to the top