Hi,
I am trying to use the new multi-column trees and the treeviewer object
in one of my project. Right now, I am simply trying to display some
values, but I can't get it to work: nothing is displayed in the Tree. I
couldn't find any examples or snippets about the use of these classes,
and the books that I have don't cover them. Can you please let me know
if I'm doing something wrong?
I have the following code for creating the tree
// Create the tree
Tree single = new Tree(tabcomp, SWT.SINGLE | SWT.CHECK);
// Create the JFace TreeViewer object
TreeViewer treeViewer = new TreeViewer(single);
TreeViewerColumn column1 = new TreeViewerColumn(treeViewer, SWT.NONE);
column1.setLabelProvider(new GroceryNameProvider());
column1.getColumn().setText("Name");
TreeViewerColumn column2 = new TreeViewerColumn(treeViewer, SWT.NONE);
column2.setLabelProvider(new GroceryStoreProvider());
column2.getColumn().setText("Store");
// Then the books list
// create the groceryList and bookList models
// Finally, the root of the list
cat_list.addChild(groceryList);
cat_list.addChild(bookList);
// Set up the viewer
treeViewer.setContentProvider(new ItemTreeContentProvider());
treeViewer.setLabelProvider(new ItemTreeLabelProvider());