| [news.eclipse.platform.swt] Re: TreeViewer with visible root |
I'm having a problem with TreeViewer when I want the root node of the model to be visible (root being the node that doesn't have any parents). Expanding the root node always shows the root node as a child. For example, if I expand root, I see root, root. If I expand that, I see root, root, root, etc.Hi Sarah. What are you passing in the setInput() method and what are you doing in the getElements() method? As I understand it, if you are passing the root element in the setInput(), you just return that same element as an object array in the getElements() method, as follows:
From debugging the code, it looks like the structured viewer ultimately calls getElements(), rather than getChildren(), when getting children for the root. Since I want the root to be visible, getElements() returns root, hence the root, root, root, etc. Is there a restriction on TreeViewer that the root can't be visible?
public Object getElements(Object inputElement) {
return new Object[] {inputElement};Hope this helps. Mark