문제

"ITableLabelProvider " interface has given two methods to implement out label provider, one of the methods is

     public String getColumnText(Object element, int columnIndex);

in this method element represents one entire row, based on the column index we will get data and set to table.

My requirement is , I want a method such that element represents one column, so based on column index I can access data.

도움이 되었습니까?

해결책

At the moment there is no label provider, which would provide element, representing just a column (even cell). It is actually quite logical, if you think about it. So, you should rely on column index to fetch the data (for example, having a switch by column index).

Another possibility would be to do it like this:

TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.LEFT);
tableViewerColumn.getColumn().setText("Column");
tableViewerColumn.setLabelProvider(new ColumnLabelProvider() {
    @Override
    public String getText(Object element) {
        return ((RowRepresentingObject) element).getColumnValue();
    }
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top