[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] re TablesViewer and new 3.3 API Snippet 24

I am new to JFace and am trying to have reusable table class based on snippet 24 that loops through the columns and sets up column titles etc. and column data etc. as follows

for column[j]

TableViewerColumn column[j] = new TableViewerColumn(v, SWT.NONE);
	column[j].getColumn().setWidth(w[j]);
	column[j].getColumn().setText(title[j]);
	column[j].getColumn().setMoveable(movable[j]);
	column[j].setLabelProvider(new ColumnLabelProvider() {

	public String getText(Object element) {
			return ((Person) element).getData(j);
	}
});

Everything works for the column width and titles etc. however it appears as if the loop only creates one ColumnLableProvder for all the columns. Is there a way around this or must you hard code the column data as per the snippet 24.

Original code - one block per column
*************************************
TableViewerColumn column = new TableViewerColumn(v, SWT.NONE);
	column.getColumn().setWidth(200);
	column.getColumn().setText("Givenname");
	column.getColumn().setMoveable(true);
	column.setLabelProvider(new ColumnLabelProvider() {

	public String getText(Object element) {
			return ((Person) element).givenname;
	}
});
******************************************************

Thanks
Peter Snowball