Bug 38027

Summary: [Viewers] TableTreeViewer should use ITreeContentProvider.getChildren when accessing the raw children
Product: [Eclipse Project] Platform Reporter: Chris Wege <wege>
Component: UIAssignee: Nick Edgar <n.a.edgar>
Status: RESOLVED DUPLICATE QA Contact:
Severity: minor    
Priority: P4 CC: dirk_baeumer
Version: 2.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
Demonstrate drill down problem when returning the root element in ITreeContentProvider>>getElements() none

Description Chris Wege CLA 2003-05-23 06:14:09 EDT
Build 200303272130

The table tree viewer uses ITreeContentProvider.getElement() to access the raw
children. Tree Viewer uses ITreeContentProvider.getChildren(). Shouldn't use
table tree getChildren as well
Comment 1 Nick Edgar CLA 2003-05-26 14:17:16 EDT
For both TreeViewer and TableTreeViewer, it uses getElements for the top-level 
elements, and getChildren for child elements (and children of child elements, 
etc.).  See AbstractTreeViewer.getRawChildren.
Comment 2 Dirk Baeumer CLA 2003-05-26 14:39:54 EDT
Chris,

Nick is right. Do you still have the code we looked at at code camp. I am 
wondering what the problem is since I am pretty sure that we ended up in the 
getRawChildren() method of the structured viewer for the table tree viewer 
instance.
Comment 3 Chris Wege CLA 2003-05-27 06:19:38 EDT
Created attachment 4971 [details]
Demonstrate drill down problem when returning the root element in ITreeContentProvider>>getElements()

In the target workspace show view Metrics>>Metrics Table View and click on any
IJavaElement in the Package Explorer. This should show some values in the view.
I want the selected element to be presented in the view:
public Object[] getElements(Object inputElement) {
//	return getChildren(inputElement);
	return new Object[] {inputElement};
}
Now when you drill down in the hierarchy you always get the root element.
Comment 4 Chris Wege CLA 2003-05-27 06:20:37 EDT
In TableTreeViewer>>getRawChildren you find

if (equals(parent, getRoot()))
	return super.getRawChildren(parent);

It gets the children in StructuredViewer>>getRawChildren with 

	result = cp.getElements(parent);

I must admit that at a second glace it works exactly like in the TreeViewer. So
if it is not a bug I would say it is a design flaw that you don't allow the user
the have the root element presented.

To explain what I want I attached the code from the camp.
Comment 5 Nick Edgar CLA 2003-05-27 09:47:49 EDT
In general, viewers do not handle multiple equal elements well.  For example, 
the internal map from model element to SWT item is a simple map, from one model 
element to one item.  This is another case.  It would be better not to case on 
the root element.  

Reopening the PR so that this can be addressed in the future.  Reducing 
severity and priority though.
Comment 6 Michal Tkacz CLA 2004-09-01 08:03:49 EDT
Isn't that now a duplicate of bug 9262? (both are quite old :(
Comment 7 Nick Edgar CLA 2004-09-01 09:08:12 EDT
Yes, thanks.

*** This bug has been marked as a duplicate of 9262 ***