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
Post a Comment