SWT - Table Row - Changing font color
Posted
by
jkteater
on Stack Overflow
See other posts from Stack Overflow
or by jkteater
Published on 2012-09-26T20:52:08Z
Indexed on
2012/09/28
15:38 UTC
Read the original article
Hit count: 298
Is it possible to change the font color for a row based on a value in one of the columns?
My table has a column that displays a status. The value of the column is going to either be Failed or Success.
If it is Success I would like for that rows font be green. If the status equals Failed, I want that rows font be red.
Is this possible, if so where would I put the logic.
EDIT
Here is my Table Viewer code, I am not going to show all the columns, just a couple
private void createColumns() {
String[] titles = { "ItemId", "RevId", "PRL", "Dataset Name", "Printer/Profile" , "Success/Fail" };
int[] bounds = { 100, 75, 75, 150, 200, 100 };
TableViewerColumn col = createTableViewerColumn(titles[0], bounds[0], 0);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
if(element instanceof AplotResultsDataModel.ResultsData) {
return ((AplotResultsDataModel.ResultsData)element).getItemId();
}
return super.getText(element);
}
});
col = createTableViewerColumn(titles[1], bounds[1], 1);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
if(element instanceof AplotResultsDataModel.ResultsData) {
return ((AplotResultsDataModel.ResultsData)element).getRevId();
}
return super.getText(element);
}
}); --ETC
© Stack Overflow or respective owner