View Full Version : [CLOSED] [beta2] ViewerCell.getItem() returns null

7 May 2008, 6:10 PM

I would expect that ViewerCell.getItem(), as called from within CellLabelProvider.update(ViewerCell), would return the current TableItem, but it returns null instead:

CellLabelProvider labelProvider = new CellLabelProvider() {
public void update(ViewerCell cell) {
TableItem item = (TableItem)cell.getItem(); // Returns null - why?
Looking at the beta2 TableViewer.java, there is this code:

protected void renderItem(Object element, int index) {
int cols = table.getColumnCount();
String[] values = new String[cols];
String[] toolTips = new String[cols];

for (int j = 0; j < cols; j++) {
CellLabelProvider lp = getCellLabelProvider(j);
viewerCell.reset(element, null, j, table.getColumn(j).getId());
values[j] = viewerCell.getText();
toolTips[j] = viewerCell.getToolTipText();
TableItem item = new TableItem(values);


table.insert(item, index);
Notice that the viewerCell.reset() call is passing null as the item and then the TableItem is created later but never updated in the ViewerCell - is this right?

BTW, if ViewerCell.getItem() did return the current TableItem, then this would be a way to set the widget for a column (until ViewerCell.setWidget() is supported as it was in MyGWT 5.2).


9 May 2008, 2:33 PM
I saw on another thread that the viewer-related code is being removed because of license issues. So feel free to close this. However, hopefully setting widgets in tables will be possible somehow in beta3.

- Andre

12 May 2008, 11:50 AM
Yes, the viewer code is now removed. You can add widgets to Tables by passing them into the TableItem constructor or calling setWidget on TableItem. This is the same as in beta2. The ticket is being closed.