javaswtjfacercpemf

How can I set an EList as an input in JFace TableViewer?


This is my first SO question. I hope i provide enough details.
I have an EMF Model with a class called ScopeContainer, which has two containment References as ELists of Different Types.

I have generated the

codes with the Genmodel

I am trying to show the contents of one of those lists in a org.eclipse.jface.viewers.TableViewer with only one Column.

This can't be a org.eclipse.swt.widgets.List since i want to be able to edit those entries.

TableViewer viewer;
AdapterFactory adapterFactory = storage.getDomain().getAdapterFactory();
AdapterFactoryLabelProvider labelProvider = new AdapterFactoryLabelProvider(adapterFactory);
AdapterFactoryContentProvider contentProvider = new AdapterFactoryContentProvider(adapterFactory);

viewer.setLabelProvider(labelProvider);
viewer.setContentProvider(contentProvider);
viewer.setInput(project.getScopecontainer().getFilters());

When I set the input as the the ScopeContainer Object. I can see all the objects in both lists When i set the input as the EList<Filter> the Table is empty. What do i have to do to set the Input of the TableViewer as EList?


Solution

  • A simple solution would be to override AdapterFactoryContentProvider.getElements() to return an array of Filter elements (derived from the EList<Filter> input).