Reputation: 5999
I created a TableViewer ( jface ).
I want in some cases to hidden the image.( to control on the visible of the image ) The logic is done in different class and not in the tableViewer. How I can get the cell and then the to control the image visibility ? .( I know the name of the cell and it is always the first cell in the tableviewer ) //The gridViewer Class
public class MyGridViewer extends TableViewer {
public MyGridViewer (Composite parent) {
super(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
final Table table = this.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
this.setContentProvider(new MyModelProvider());
}
}
@Override
protected void inputChanged(Object input, Object oldInput) {
removeColumn();
tableCol = new TableViewerColumn(this, SWT.NONE);
column = tableCol.getColumn();
column.setText(dataColumnHeader.getName());
column.setWidth(100);
column.setResizable(true);
column.setMoveable(true);
tableCol.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
DataRow r = (DataRow) element;
DataCell c = r.getDataCellByName(dataColumnHeader.getName());
if (c != null && c.getValue() != null) {
return c.getValue().toString();
}
return null;
}
@Override
public Image getImage(Object element) {
//Add my imgae
}
});
editingSupport = new StringCellEditingSupport(this, dataColumnHeader);
tableCol.setEditingSupport(editingSupport);
super.inputChanged(input, oldInput);
}
Upvotes: 1
Views: 374
Reputation: 111216
ColumnLabelProvider
has a getImage
method similar to the getText
method:
public Image getImage(Object element);
Upvotes: 1