Skip to main content



      Home
Home » Eclipse Projects » XWT » IStructuredContentProvider.getElements being called twice
IStructuredContentProvider.getElements being called twice [message #1220821] Fri, 13 December 2013 15:48 Go to next message
Eclipse UserFriend
Hi,

I have a JFace TableViewer that is bound to an EMF model like so:
<TableViewer x:Name="f_v_elements" input="{Binding Path=elements}">
  <TableViewer.contentProvider>
    <part:ElementsContentProvider/>
  </TableViewer.contentProvider>
</TableViewer>


And a content provider:
Class ElementsContentProvider implements IStructuredContentProvider {
  @Override
  public Object[] getElements(Object inputElement) {
    System.out.println(inputElement.getClass());
  }
  ...
}


Before opening the view, I set the DATACONTEXT to an instance of my EMF model.
What I see is that the IStructuredContentProvider.getElements is being called twice.

In the first call, inputElement is of type org.eclipse.emf.ecore.util.EObjectContainmentEList which is a list with elements of my EMF model. That's OK.

The second call, inputElement is of type class org.eclipse.core.databinding.observable.list.WritableList.
Where did that came from, and what do I do with it?

Thanks,
-S.
Re: IStructuredContentProvider.getElements being called twice [message #1220853 is a reply to message #1220821] Sat, 14 December 2013 05:06 Go to previous messageGo to next message
Eclipse UserFriend
Sharon,
WritableList is a "special" Collection implementation of jface which wraps a regular Collection and automatically updates the viewer if elements are add()ed or remove()ed from the WritableList itself.
XWT will automatically convert your "regular" Collections (in your case it is an EMF EList implementation) to one of jface's databindg collections (WritableList).

Have a look at the following implementation:

org.eclipse.jface.viewers.ArrayContentProvider.getElements(Object)




Sharon Dagan wrote on Fri, 13 December 2013 21:48
Hi,

I have a JFace TableViewer that is bound to an EMF model like so:
<TableViewer x:Name="f_v_elements" input="{Binding Path=elements}">
  <TableViewer.contentProvider>
    <part:ElementsContentProvider/>
  </TableViewer.contentProvider>
</TableViewer>


And a content provider:
Class ElementsContentProvider implements IStructuredContentProvider {
  @Override
  public Object[] getElements(Object inputElement) {
    System.out.println(inputElement.getClass());
  }
  ...
}


Before opening the view, I set the DATACONTEXT to an instance of my EMF model.
What I see is that the IStructuredContentProvider.getElements is being called twice.

In the first call, inputElement is of type org.eclipse.emf.ecore.util.EObjectContainmentEList which is a list with elements of my EMF model. That's OK.

The second call, inputElement is of type class org.eclipse.core.databinding.observable.list.WritableList.
Where did that came from, and what do I do with it?

Thanks,
-S.

Re: IStructuredContentProvider.getElements being called twice [message #1220865 is a reply to message #1220853] Sat, 14 December 2013 15:56 Go to previous messageGo to next message
Eclipse UserFriend
I get it, but why does the setInput method being called twice? why not just one time with a WritableList?
Re: IStructuredContentProvider.getElements being called twice [message #1220878 is a reply to message #1220865] Sun, 15 December 2013 03:54 Go to previous message
Eclipse UserFriend
Yes, I have debugged the proper code locations and could not imagine why this has to be done twice. It seems there is some redundancy here: could you please file a bug report?

Sharon Dagan wrote on Sat, 14 December 2013 21:56
I get it, but why does the setInput method being called twice? why not just one time with a WritableList?

Previous Topic:Binding to an object instance rather than to one of its properties
Next Topic:Download and Install XWT
Goto Forum:
  


Current Time: Sun May 11 21:29:10 EDT 2025

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

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

Back to the top