Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Lazy Loading in JFace(Deferred Loading - Lazy Loading)
icon4.gif  Lazy Loading in JFace [message #518463] Thu, 04 March 2010 08:24 Go to next message
Aravindhan Annamalai is currently offline Aravindhan AnnamalaiFriend
Messages: 89
Registered: July 2009
Location: Chennai
Member
In JFace tree viewer, the get Children() method is called only on the click of the parent node... which in turn fetches the data...

I thought this is a kind of lazy loading.... because setInput() doesn't fetch the whole data and, only when you expand your tree nodes it fetches the needed data either locally or from a db call.

Recently, i came across this class DeferredTreeContentManager.... and now i see arguments on Deferred Loading Vs Lazy Loading...

r is it tht lazy loading is achieved thro the implementation of this DeferredTreeContentManager class...???


Need some info on this... whr do i find a snippet on DeferredTreeContentManager...?

Regards, Aravind
Re: Lazy Loading in JFace [message #519819 is a reply to message #518463] Tue, 09 March 2010 23:06 Go to previous messageGo to next message
Craig Foote is currently offline Craig FooteFriend
Messages: 217
Registered: July 2009
Senior Member
I'm not sure about the lazy loading but I have used the
DeferredTreeContentManager.

I instanciated one in my content provider and made #getChildren call its
#getChildren. The object passed to its #getChildren must adapt to
IDeferredWorkbenchAdapter so you need to write a factory and adapter. The
manager requests the adapter from the Platform and calls its
#getDeferredChildren. When you declare an 'adapters' extension that
adapts the input object to IDeferredWorkbenchAdapter, code the adapter
such that it gets the children of the adapted object in this method. As
each child is created, add it to the provided 'collector'.

The result of all this is that the ContentProvider#getChildren call to
DeferredTreeContentManager#getChildren will immediately return a
'PendingUpdateAdapter' displaying 'Pending...'. As children are added to
the 'collector', new nodes are added to the tree. When the last is added
and #getDeferredChildren completes, the PendingUpdateAdapter is removed.
The call to #getDeferredChildren is done in a job and the new nodes are
added to the tree in a thread-smart way making the tree interactive-
capable while they're being created. Pretty slick.

This makes me think that 'lazy' implies child nodes are created and
rendered as needed but 'deferred' in multi-threaded. Just a guess though.

Craig

On Thu, 04 Mar 2010 03:24:57 -0500, Aravindhan.A wrote:

> In JFace tree viewer, the get Children() method is called only on the
> click of the parent node... which in turn fetches the data...
>
> I thought this is a kind of lazy loading.... because setInput() doesn't
> fetch the whole data and, only when you expand your tree nodes it
> fetches the needed data either locally or from a db call.
>
> Recently, i came across this class DeferredTreeContentManager.... and
> now i see arguments on Deferred Loading Vs Lazy Loading...
>
> r is it tht lazy loading is achieved thro the implementation of this
> DeferredTreeContentManager class...???
>
>
> Need some info on this... whr do i find a snippet on
> DeferredTreeContentManager...?
>
> Regards, Aravind
Re: Lazy Loading in JFace [message #519824 is a reply to message #519819] Wed, 10 March 2010 05:38 Go to previous messageGo to next message
Aravindhan Annamalai is currently offline Aravindhan AnnamalaiFriend
Messages: 89
Registered: July 2009
Location: Chennai
Member
Hi Craig,

Thanks for the reply.

we have three classes in place.

1)DeferredTreeContentprovider
2)CustomDeferredTreeContentManager extends DeferredTreeContentManager
3)CustomTreeContentprovider implements IDeferredWorkbenchAdapter

treeViewer.setInput(new DeferredTreeContentProvider());

DeferredTreeContentprovider is the class where we have the instances of CustomDeferredTreeContentManager(Manager) and
CustomTreeContentprovider(Delegate)

DeferredTreeContentprovider is the class which decides either to call manager's getChildren() (or) delegate's getChildren() in its getChildren() method as stated below....

public Object[] getChildren(Object parent) {
if (manager != null && !xxx.isConnected() ) {
return manager.getChildren(parent);
}
return delegate.getChildren(parent);
}

manager.getChildren() call leads to the display of pending..... label, as it calls the PendingUpdateAdapter. ie in our case only when the root node is expanded

delegate.getChildren() calls the getChildren() in CustomTreeContentProvider where we return the object upon certain conditions.

when i expand the child node... it shows only the busy cursor and not the pending label.

CustomDeferredTreeContentManager is extending DeferredTreeContentManager and over riding getAdapter() and getFetchJobName() methods in it

CustomTreeContentProvider is overriding fetchDeferredChildren() method as it is implementing IDeferredWorkbenchAdapter.

juz wanna check with you whether this approach is fine...?

Regards, Aravind

Re: Lazy Loading in JFace [message #520069 is a reply to message #519824] Thu, 11 March 2010 02:40 Go to previous message
Craig Foote is currently offline Craig FooteFriend
Messages: 217
Registered: July 2009
Senior Member
Sure, overriding those methods seems to lead to the same result without
requiring your input objects adapt to IDeferredWorkbenchAdapter so I
think its a neat solution.

Craig

On Wed, 10 Mar 2010 11:08:23 +0530, Aravindhan.A wrote:

> Hi Craig,
>
> Thanks for the reply.
>
> we have three classes in place.
>
> 1)DeferredTreeContentprovider
> 2)CustomDeferredTreeContentManager extends DeferredTreeContentManager
> 3)CustomTreeContentprovider implements IDeferredWorkbenchAdapter
>
> treeViewer.setInput(new DeferredTreeContentProvider());
>
> DeferredTreeContentprovider is the class where we have the instances of
> CustomDeferredTreeContentManager(Manager) and
> CustomTreeContentprovider(Delegate)
>
> DeferredTreeContentprovider is the class which decides either to call
> manager's getChildren() (or) delegate's getChildren() in its
> getChildren() method as stated below....
>
> public Object[] getChildren(Object parent) {
> if (manager != null && !xxx.isConnected() ) {
> return manager.getChildren(parent);
> }
> return delegate.getChildren(parent);
> }
>
> manager.getChildren() call leads to the display of pending..... label,
> as it calls the PendingUpdateAdapter. ie in our case only when the root
> node is expanded
>
> delegate.getChildren() calls the getChildren() in
> CustomTreeContentProvider where we return the object upon certain
> conditions.
>
> when i expand the child node... it shows only the busy cursor and not
> the pending label.
>
> CustomDeferredTreeContentManager is extending DeferredTreeContentManager
> and over riding getAdapter() and getFetchJobName() methods in it
>
> CustomTreeContentProvider is overriding fetchDeferredChildren() method
> as it is implementing IDeferredWorkbenchAdapter.
>
> juz wanna check with you whether this approach is fine...?
>
> Regards, Aravind
Previous Topic:Text compare ?
Next Topic:Why TreeViewer is not intended to be subclassed by clients.
Goto Forum:
  


Current Time: Thu Apr 25 07:57:43 GMT 2024

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

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

Back to the top