ITreeViewerListener.treeExpanded() not showing added child nodes [message #468176] |
Tue, 04 August 2009 09:10  |
Eclipse User |
|
|
|
I've just added databinding to my application which consists primarily of
a TreeViewer the navigates my model. Originally child nodes were added to
nodes in the tree as those nodes were expanded. After I setup databinding
adding the children directly in treeExpanded(TreeExpansionEvent) no longer
works and I'm trying to figure out why. I inspected the results of calling
getChildren on my IContentProvider (implemented by
ObservableListTreeContentProvider) and the children are returned as
expected but once treeExpanded() returns, the tree is not updated except
that the little arrow next to the parent node disappears completely. No
children appear under it. Here's how I set up the databinding (pardon the
formatting):
Realm realm = SWTObservables.getRealm(viewer.getControl().getDisplay());
ObservableListTreeContentProvider contentProvider = new
ObservableListTreeContentProvider(childrenProp.listFactory(r ealm), new
TreeStructureAdvisorImpl());
viewer.setContentProvider(contentProvider);
viewer.setLabelProvider(new
ObservableMapLabelProvider(Properties.observeEach(contentPro vider.getKnownElements(),
labelProps)));
viewer.setInput(model);
And the treeExpanded() method:
public void treeExpanded(TreeExpansionEvent event) {
AbstractTreeViewer treeViewer = event.getTreeViewer();
Object element = event.getElement();
System.err.println(element + " was expanded");
if(element instanceof TypeA){
TypeA prop = (TypeA) element;
Data data = fetchData(prop); // fetch data adds child nodes to the
model, essentially children.add(datum) where children is a List.
}
}
Any help in determining why the child nodes don't appear in the tree
though they appear in the model and the property change fires, would be
very much appreciated.
Also, I'd like to thank Matthew for his help with my original databinding
problem.
Ben
|
|
|
|
Powered by
FUDForum. Page generated in 0.02822 seconds