Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XWT » IStructuredContentProvider.getElements being called twice
IStructuredContentProvider.getElements being called twice [message #1220821] Fri, 13 December 2013 20:48 Go to next message
Sharon Dagan is currently offline Sharon DaganFriend
Messages: 12
Registered: November 2013
Junior Member
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 10:06 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
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 20:56 Go to previous messageGo to next message
Sharon Dagan is currently offline Sharon DaganFriend
Messages: 12
Registered: November 2013
Junior Member
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 08:54 Go to previous message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
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: Thu Apr 25 16:15:53 GMT 2024

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

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

Back to the top