Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 22:46 Go to next message
Paco Blanco is currently offline Paco BlancoFriend
Messages: 28
Registered: June 2012
Junior Member
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 22:47]

Report message to a 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 23:00 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5469
Registered: July 2009
Senior Member
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 14:25 Go to previous messageGo to next message
Paco Blanco is currently offline Paco BlancoFriend
Messages: 28
Registered: June 2012
Junior Member
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 16:02 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5469
Registered: July 2009
Senior Member
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: Fri Nov 28 00:50:59 GMT 2014

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

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