[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Using ColumnLabelProvider with multi-column TreeViewers

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());
treeViewer.setInput(cat_list);

The classes GroceryStoreProvider and GroceryNameProvider extend ColumnLabelProvider, and they just return some text that is found in my model (through getText()).

When I put some println statements in the getText() method, I noticed they weren't displayed on the console. Am I missing a step?

Any help would be appreciated.

Thanks, Berk