java - Is getChildren() of ContentProvider called before treeExpanded() of ITreeViewerListener? -


i want fetch data if specific element of tree expanded.

public void treeexpanded(treeexpansionevent event) {      object element = event.getelement();    if (element instanceof myclass) {       fetch.......    } }  

the problem content provider seems trigger getchildren() before treeexpanded()-method nullpointerexception everytime expand element because content provider tries use data never fetched. how can solve properly?

your code should not depend on order in getchildren() , treeexpanded() called. implementation detail of treeviewer , may change in future.

fetch elements shown in getchildren() or inputchanged() of content provider.

if fetch operation takes long run in ui thread, run in background thread , return placeholder element replaced, once fetch operation finishes. example, see deferredtreecontentmanager of org.eclipse.ui.

alternatively can see if jface deferredcontentprovider fits needs.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -