Bug 158279 - FilteredTree must not create the widgets in the constructor
Summary: FilteredTree must not create the widgets in the constructor
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M3   Edit
Assignee: Karice McIntyre CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 139798
  Show dependency tree
 
Reported: 2006-09-22 06:26 EDT by Dani Megert CLA
Modified: 2006-10-31 12:01 EST (History)
2 users (show)

See Also:


Attachments
apply patch to org.eclipse.ui.workbench (3.26 KB, patch)
2006-09-22 14:32 EDT, Karice McIntyre CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2006-09-22 06:26:15 EDT
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.
Comment 1 Boris Bokowski CLA 2006-09-22 08:33:05 EDT
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);
Comment 2 Dani Megert CLA 2006-09-22 08:40:18 EDT
>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(...);
  }
Comment 3 Karice McIntyre CLA 2006-09-22 14:32:38 EDT
Created attachment 50716 [details]
apply patch to org.eclipse.ui.workbench

Dani, was something like this what you had in mind?
Comment 4 Dani Megert CLA 2006-09-25 04:46:11 EDT
Yes, this should do the trick.
Comment 5 Karice McIntyre CLA 2006-09-25 13:36:12 EDT
released to HEAD for build > 20060925
Comment 6 Dani Megert CLA 2006-09-26 12:19:56 EDT
It works but I think passing the parent twice could be avoided i.e. only pass it with super but not with init.
Comment 7 Karice McIntyre CLA 2006-09-26 13:55:32 EDT
noted - released change to FilteredTree and updated tests
Comment 8 Karice McIntyre CLA 2006-10-31 12:01:48 EST
verified in I20061031-0656