Bug 205158 - [JFace][Viewers] Deferred content provider manager for table elements
Summary: [JFace][Viewers] Deferred content provider manager for table elements
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 509006
  Show dependency tree
 
Reported: 2007-10-02 05:17 EDT by Fabio Mancinelli CLA
Modified: 2016-12-09 15:16 EST (History)
2 users (show)

See Also:


Attachments
The class implementing the DeferredTableContentManager (10.39 KB, text/plain)
2007-10-02 05:17 EDT, Fabio Mancinelli CLA
no flags Details
The IDeferredStructuredContentProvider interface (718 bytes, text/plain)
2007-10-02 05:18 EDT, Fabio Mancinelli CLA
no flags Details
New implementation and example (9.32 KB, application/x-gzip)
2007-10-03 18:11 EDT, Fabio Mancinelli CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.