Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Data Binding] Bind list to one table column as aggregation value
[Data Binding] Bind list to one table column as aggregation value [message #1229348] Thu, 09 January 2014 08:54 Go to next message
kon f is currently offline kon fFriend
Messages: 152
Registered: March 2012
Senior Member
Hey,

I found a nice tutorial from Tom Schindl being able to bind a list of persons to a jface table viewer. This worked out easily for the first name and the last name.

In addition, I would like to show an aggregation value that is calculated from a list. So, if the list of projects gets updated (add or remove a project), the aggregation value should be updated as well.

Here is an example of my table:

Firstname | Lastname | #Projects
--------------------------------
Hans         Müller       3


I wasn't able to find an example on the web. Has anyone else had the same issue? I appreciate any help Smile

Thank you!

Kon

[Updated on: Thu, 09 January 2014 09:01]

Report message to a moderator

Re: [Data Binding] Bind list to one table column as aggregation value [message #1229385 is a reply to message #1229348] Thu, 09 January 2014 10:35 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
On 09-01-14 09:54, kon f wrote:
> Hey,
>
> I found a nice tutorial from
> http://tomsondev.bestsolution.at/2009/06/27/galileo-emf-databinding-part-5/
> being able to bind a list of persons to a jface table viewer. This
> worked out easily for the first name and the last name.
>
> In addition, I would like to show an aggregation value that is
> calculated from a list. So, if the list of projects gets updated (add or
> remove a project), the aggregation value should be updated as well.
You could enhance your model with an operation which calculates the
value.

http://www.vogella.com/tutorials/EclipseEMF/article.html#methods

Then you can bind this new model feature to one one of the columns of
your viewer.

Another option is to bind a dummy column, whereby the model is something
else then the EMF model. (A method in your code for example).
I can elaborate, if you want to know more.
Cheers Christophe

> Here is an example of my table:
>
>
> Firstname | Lastname | #Projects
> --------------------------------
> Tom Schindl 3
>
>
> I wasn't able to find an example on the web. Has anyone else had the
> same issue? I appreciate any help :)
>
> Thank you!
>
> Kon
Re: [Data Binding] Bind list to one table column as aggregation value [message #1229469 is a reply to message #1229385] Thu, 09 January 2014 14:02 Go to previous messageGo to next message
kon f is currently offline kon fFriend
Messages: 152
Registered: March 2012
Senior Member
Hey Christophe,

it would be nice if you could show your option. I'm just wondering how the synchronization process is working for the column (if a project is added/remove the column label needs to be updated).

At the moment, I fill the IObservableMap entry for the column with some dummy feature (like the first name - MyPackage.Literals.USER__FIRST_NAME) and use the label provider to show a different value (the aggregated project number). This approach just works for the first time. So if the view is opened and the user changes the amount of projects, the aggregated value is not notified/updated Sad

Thank you.

Kon
Re: [Data Binding] Bind list to one table column as aggregation value [message #1230291 is a reply to message #1229469] Sat, 11 January 2014 15:27 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
On 09-01-14 15:02, kon f wrote:
> Hey Christophe,
>
> it would be nice if you could show your option. I'm just wondering how
> the synchronization process is working for the column (if a project is
> added/remove the column label needs to be updated).

I just ran a little test here, if the aggregated value (#projects) is a
multivalued EFeature, you can simply add it to the IObservableMap entry
and it nicely increments when objects are added to the multivalued feature.

in the example here: the feature
OperatorsPackage.Literals.OPERATOR__NETWORKS
is multi valued.

listContentProvider = new ObservableListContentProvider();
tableViewer.setContentProvider(listContentProvider);

IObservableMap[] observeMaps = EMFObservables.observeMaps(
listContentProvider.getKnownElements(),
new EStructuralFeature[] {
GenericsPackage.Literals.COMPANY__NAME,
OperatorsPackage.Literals.OPERATOR__NETWORKS });

tableViewer.setLabelProvider(new ValueLabelProvider(observeMaps));
IEMFListProperty l = EMFEditProperties.resource(editingService
.getEditingDomain());
IObservableList observableList = l.observe(data);

tableViewer.setInput(observableList);

>
> At the moment, I fill the IObservableMap entry for the column with some
> dummy feature (like the first name -
> MyPackage.Literals.USER__FIRST_NAME) and use the label provider to show
> a different value (the aggregated project number). This approach just
> works for the first time. So if the view is opened and the user changes
> the amount of projects, the aggregated value is not notified/updated :(
>
> Thank you.
>
> Kon
Re: [Data Binding] Bind list to one table column as aggregation value [message #1264669 is a reply to message #1230291] Wed, 05 March 2014 11:57 Go to previous message
kon f is currently offline kon fFriend
Messages: 152
Registered: March 2012
Senior Member
Thank you Christophe,

this made the trick:

IObservableMap[] observeMaps = EMFObservables.observeMaps(
listContentProvider.getKnownElements(),
new EStructuralFeature[] {
GenericsPackage.Literals.COMPANY__NAME,
OperatorsPackage.Literals.OPERATOR__NETWORKS });


Apparently, my IObservableMap[] creation wasn't working well for the list. Thank you Smile

Kon
Previous Topic:[Xcore] How to model a customized constructor
Next Topic:EMF Resource Save issue
Goto Forum:
  


Current Time: Fri Apr 26 15:31:51 GMT 2024

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

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

Back to the top