Bug 205158

Summary: [JFace][Viewers] Deferred content provider manager for table elements
Product: [Eclipse Project] Platform Reporter: Fabio Mancinelli <fm>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: remy.suen, tom.schindl
Version: 3.4   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 509006    
Attachments:
Description Flags
The class implementing the DeferredTableContentManager
none
The IDeferredStructuredContentProvider interface
none
New implementation and example none

Description Fabio Mancinelli CLA 2007-10-02 05:17:58 EDT
Created attachment 79536 [details]
The class implementing the DeferredTableContentManager

JFace provides a DeferredTreeContentManager for fetching in a deferred way the children of a given tree node, i.e., the result of a getChildren in a TreeContentProvider.

Nothing is provided for fetching, in the same way, the elements returned by getElements() in a IStructuredContentProvider. 

A similar manager would allow to fetch table elements and tree roots in the same way children are fetched by the DeferredTreeContentManager.

I wrote an adaptation of DeferredTreeContentManager that allows a developer to write content providers that provide their elements in a deferred way.


More information:
There are two elements involved in the solution:

* DeferredTableContentManager
* IDeferredStructuredContentProvider (extends IStructuredContentProvider)

Here it is what would be their typical usage:

private class MyContentProvider implements IDeferredStructuredContentProvider {
  ...
  public Object[] getElements(Object inputElement) {
    //manager is an instance of DeferredTableContentManager
    return manager.getElements(inputElement);
  }

  public void fetchDeferredElements(Object object, IElementCollector collector, IProgressMonitor monitor) {
    //Do here the long fetching job and put results in collector to add them to the target table
  }
}

...
TableViewer viewer = ...
viewer.setContentProvider(new MyContentProvider(tableViewer));
viewer.setInput(...);

That's it.

Notes:
The same can be done for Trees and Lists. Unfortunately the add method is defined in AbstractTreeViewer, AbstractListViewer and AbstractTableViewer but not in their common superclass so there have to be 3 different DeferredManagers. 

In the attachment you can find the implementation.

Cheers,
Fabio
Comment 1 Fabio Mancinelli CLA 2007-10-02 05:18:41 EDT
Created attachment 79537 [details]
The IDeferredStructuredContentProvider interface
Comment 2 Fabio Mancinelli CLA 2007-10-03 18:11:34 EDT
Created attachment 79684 [details]
New implementation and example

An RCP application showing the implementation of the idea.
Comment 3 Boris Bokowski CLA 2009-11-26 09:50:35 EST
Hitesh is now responsible for watching bugs in the [Viewers] component area.