Skip to main content



      Home
Home » Modeling » EMF » [EMF-Databinding] TableViewer databinding to add, remove and changes values from a list
[EMF-Databinding] TableViewer databinding to add, remove and changes values from a list [message #901657] Mon, 13 August 2012 18:46 Go to next message
Eclipse UserFriend
IEMFListProperty mProp = EMFEditProperties.list(editingDomain, ModelPackage.Literals.MODEL__SUBELEMENTS);
TableViewer tv = new TableViewer(...);
tv.setContentProvider(new ObservableListContentProvider());
tv.setInput(mProp.observeDetail(model));
//(set labelProvider, filter, sorter...)

This typical databinding only reacts to addition and removals of values from the list but not from changes of the attributes of each object of the list.
Logically, a table usually shows the value of the attributes of each object of the list so reacting (by databinding) to changes in these attributes should be an expect code snippet in the web that I do not find Surprised (I am a very bad google searcher but not so much Razz)

Is there a simple solution to this? Some code snippet or url is accepted.

My teorical approach is very complex and heavy-weighted:
1) Add an observer to each value of the list that reacts to the features of the table that we want to show. Add a listener to each created observed to refresh all the view of the table (.refresh, maybe an optimized refresh only if the elements are shown or in the cache)
2) Add a listener to the first observer of the list to react from addition and removal of objects. If it is an addition, to assign the observer and listener like 1) to this new value. If it is a removal, dispose the observer of 1) (that I think this action removes all added listeners)

Is my way a good method? Surprised (I expect not)

[Updated on: Mon, 13 August 2012 18:47] by Moderator

Re: [EMF-Databinding] TableViewer databinding to add, remove and changes values from a list [message #901658 is a reply to message #901657] Mon, 13 August 2012 19:00 Go to previous messageGo to next message
Eclipse UserFriend
You are searching for an ObservableMapLabelProvider or
ObservableMapCellLabelProvider.

See
http://tomsondev.bestsolution.at/2009/06/27/galileo-emf-databinding-part-5/
for a custom one (GenericMapCellLabelProvider)

or
http://tomsondev.bestsolution.at/2009/06/08/galileo-emf-databinding-%E2%80%93-part-3/
(TreeLabelProviderImpl)

Tom

Am 14.08.12 00:46, schrieb Paco Blanco:
> IEMFListProperty mProp = EMFEditProperties.list(editingDomain,
> ModelPackage.Literals.MODEL__SUBELEMENTS);
> TableViewer tv = new TableViewer(...);
> tv.setContentProvider(new ObservableListContentProvider());
> tv.setInput(mProp.observeDetail(master));
> //(set labelProvider, filter, sorter...)
>
> This typical databinding only reacts to addition and removals of values
> from the list but not from changes of the attributes of each object of
> the list.
> Logically, a table usually shows the value of the attributes of each
> object of the list so reacting (by databinding) to changes in these
> attributes should be an expect code snippet in the web that I do not
> find :o (I am a very bad google searcher but not so much :p)
>
> Is there a simple solution to this? Some code snippet or url is accepted.
>
> My teorical approach is very complex and heavy-weighted:
> 1) Add an observer to each value of the list that reacts to the features
> of the table that we want to show. Add a listener to each created
> observed to refresh all the view of the table (.refresh, maybe an
> optimized refresh only if the elements are shown or in the cache)
> 2) Add a listener to the first observer of the list to react from
> addition and removal of objects. If it is an addition, to assign the
> observer and listener like 1) to this new value. If it is a removal,
> dispose the observer of 1) (that I think this action removes all added
> listeners)
>
> Is my way a good method? :o (I expect not)
Re: [EMF-Databinding] TableViewer databinding to add, remove and changes values from a list [message #902026 is a reply to message #901658] Wed, 15 August 2012 10:25 Go to previous messageGo to next message
Eclipse UserFriend
OMG! I had to be asleep when I read your part 5 article.
The part 5 article has a simple and very understandable snippet code
Thank you very much
Re: [EMF-Databinding] TableViewer databinding to add, remove and changes values from a list [message #902048 is a reply to message #902026] Wed, 15 August 2012 12:02 Go to previous message
Eclipse UserFriend
All code is in emfs git repo!

Tom

Am 15.08.12 16:25, schrieb Paco Blanco:
> OMG! I had to be asleep when I read your part 5 article.
> The part 5 article has a simple and very understandable snippet code
> Thank you very much
Previous Topic:EMF dependencies in plain OSGi application
Next Topic:How to find all uses of an EDataType/eClassifier
Goto Forum:
  


Current Time: Tue Jul 08 23:16:53 EDT 2025

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

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

Back to the top