Community
Participate
Working Groups
I20060921-0010. While trying to fix bug 139798 I hit the wall because it is not possible to access any client data when constructing a custom tree viewer by subclassing FilteredTree and implementing doCreateTreeViewer(...). The reason for this is that FilteredTree creates the widgets inside the constructor and hence it is in no way (except via static fields) possible to get access to the client instance when doCreateTreeViewer(...) is executed.
What kind of client data do you need to access in doCreateTreeViewer()? This is how a typical use of FilteredTree looks like, all client data is set after creating the FilteredTree: FilteredTree filterTree = new FilteredTree(composite, style); TreeViewer treeViewer = filterTree.getViewer(); treeViewer.setContentProvider(new WizardContentProvider()); treeViewer.setLabelProvider(new WorkbenchLabelProvider()); treeViewer.setComparator(NewWizardCollectionComparator.INSTANCE); treeViewer.setInput(viewerInput);
>What kind of client data do you need to access in doCreateTreeViewer()? I need to call a method on the outer class instance i.e. we already have a createTreeViewer() method in our quick view framework and that's the one we need to call i.e. new FilteredTree(...) { doCreateTreeViewer(...) { return createTreeViewer(...); } } another alternative I tried was passing in the outer class instance manually via constructor and then have doCreateTreeViewer(...) { return fEnclosing.createTreeViewer(...); }
Created attachment 50716 [details] apply patch to org.eclipse.ui.workbench Dani, was something like this what you had in mind?
Yes, this should do the trick.
released to HEAD for build > 20060925
It works but I think passing the parent twice could be avoided i.e. only pass it with super but not with init.
noted - released change to FilteredTree and updated tests
verified in I20061031-0656