Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Databinding of a matrix model with a TableViewer
Databinding of a matrix model with a TableViewer [message #849092] Wed, 18 April 2012 22:02 Go to next message
Max Hohenegger is currently offline Max HoheneggerFriend
Messages: 11
Registered: April 2012
Junior Member

Hello!

I have a model that represents a matrix. Instances will contain a list of columns which in turn contain lists of values.
I would like to view and edit this model with a JFace TableViewer using EMF-databinding but there is a problem: I can't find a property that does what I need.

I managed to use the EMFEditProperties with a TableViewer for the special case of a matrix with a single column (you may call it a list):
The IListProperty I get from
o.e.emf.databinding.edit.EMFEditProperties.list(EditingDomain, EStructuralFeature) gives me a property I can use to observe such a list-model. The resulting IObservableList can be used as an input for a TableViewer with a single TableViewerColumn that uses the ColumnLabelProvider and ColumnEditingSupport.
In that case I can simply use the ObservableListContentProvider for the TableViewer.

But what do I do with lists of lists?
I tried FeaturePaths and custom LabelProviders/ContentProviders but couldn't get it to work. Maybe I need my own SimpleListProperty? Or a different widget?
I was surprised that I couldn't find anything useful about matrices and EMF-databinding. Is this completely unfeasible or just so simple that nobody bothers writing a tutorial?

Thanks in advance!
Max

PS: I could imagine this would be easier with rows instead of columns in the model, as the IStructuredContentProvider works on rows, but unfortunately I will need columns. Smile
Re: Databinding of a matrix model with a TableViewer [message #849517 is a reply to message #849092] Thu, 19 April 2012 08:02 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
I'm not sure what your are asking now exactly. Is it how to implement a
LabelProvider because there's a so called ObservableMapLabelProvider and
ObservableMapCellLabelProvider and there are tutorials around for it.

Tom

Am 19.04.12 00:02, schrieb Max Hohenegger:
> Hello!
>
> I have a model that represents a matrix. Instances will contain a list
> of columns which in turn contain lists of values.
> I would like to view and edit this model with a JFace TableViewer using
> EMF-databinding but there is a problem: I can't find a property that
> does what I need.
>
> I managed to use the EMFEditProperties with a TableViewer for the
> special case of a matrix with a single column (you may call it a list):
> The IListProperty I get from
> o.e.emf.databinding.edit.EMFEditProperties.list(EditingDomain,
> EStructuralFeature) gives me a property I can use to observe such a
> list-model. The resulting IObservableList can be used as an input for a
> TableViewer with a single TableViewerColumn that uses the
> ColumnLabelProvider and ColumnEditingSupport.
> In that case I can simply use the ObservableListContentProvider for the
> TableViewer.
>
> But what do I do with lists of lists?
> I tried FeaturePaths and custom LabelProviders/ContentProviders but
> couldn't get it to work. Maybe I need my own SimpleListProperty? Or a
> different widget?
> I was surprised that I couldn't find anything useful about matrices and
> EMF-databinding. Is this completely unfeasible or just so simple that
> nobody bothers writing a tutorial?
>
> Thanks in advance!
> Max
>
> PS: I could imagine this would be easier with rows instead of columns in
> the model, as the IStructuredContentProvider works on rows, but
> unfortunately I will need columns. :)
Re: Databinding of a matrix model with a TableViewer [message #868773 is a reply to message #849517] Wed, 02 May 2012 14:15 Go to previous messageGo to next message
Max Hohenegger is currently offline Max HoheneggerFriend
Messages: 11
Registered: April 2012
Junior Member

Thanks for your reply Tom, the problem is fixed now.

For future reference:
I wanted to show and edit a column-based matrix model in a TableViewer using standard EMF databinding.
So I created a row-based proxy-model that would work with the databinding, but wraps the column-based model. Whenever I access the values, e.g. in LabelProvider or EditingSupport, I would use the column-based model. This works because every row knows its index within the matrix and can then access the according entry within each column.

The resulting code looks rather messy, which is why I would recommend everyone to use a row-based model if you have a choice. On the bright side it scales well up to at least a 100x100 matrix. Smile
Re: Databinding of a matrix model with a TableViewer [message #868822 is a reply to message #868773] Wed, 02 May 2012 15:33 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Be aware of the many many observables you'll produce for 100x100 =>
10.000 observable instances!

See
http://tomsondev.bestsolution.at/2011/10/07/jface-viewer-and-eclipse-databinding-with-10-000-objects/

And SWT-Tables generally don't like many columns (not sure which number
is the cut off but IIRC win32 platform most affected).

Tom

Am 02.05.12 16:15, schrieb Max Hohenegger:
> Thanks for your reply Tom, the problem is fixed now.
>
> For future reference:
> I wanted to show and edit a column-based matrix model in a TableViewer
> using standard EMF databinding.
> So I created a row-based proxy-model that would work with the
> databinding, but wraps the column-based model. Whenever I access the
> values, e.g. in LabelProvider or EditingSupport, I would use the
> column-based model. This works because every row knows its index within
> the matrix and can then access the according entry within each column.
>
> The resulting code looks rather messy, which is why I would recommend
> everyone to use a row-based model if you have a choice. On the bright
> side it scales well up to at least a 100x100 matrix. :)
Previous Topic:Cannot find eProxyURI: platform:/plugin/org.eclipse.xsd/model/XSD.ecore#//XSDSchema
Next Topic:Problem with org.eclipse.emf.example.databinding.project in juno
Goto Forum:
  


Current Time: Wed Apr 24 21:18:00 GMT 2024

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

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

Back to the top