[EMF-Databinding] TableViewer databinding to add, remove and changes values from a list [message #901657] |
Mon, 13 August 2012 22:46 |
Paco Blanco 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 (I am a very bad google searcher but not so much )
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? (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 |
Thomas Schindl Messages: 6651 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)
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04785 seconds