if (!colMap.containsKey(cell.getTitle())) {
SortableColumn<List<ResultCell>, SafeHtml> column =
new SortableColumn<List<ResultCell>, SafeHtml>(new SafeHtmlCell()) {
@Override
public SafeHtml getValue(List<ResultCell> cells) {
ResultCell c = lookupCell(cell.getTitle(), cells);
SafeHtmlBuilder sb = new SafeHtmlBuilder();
if (c == null) { // not necessary always have this column
sb.appendHtmlConstant("<br/>");
} else {
PropertyInfo property = PropertyInfo.Builder.fromResultCell(c);
// populate warnings in tooltip
List<String> warnings = property.getWarnings();
if (warnings != null && !warnings.isEmpty()) {
List<String> warningMsgs = transform(warnings, new Function<String, String>(){
@Override
public String apply(String errorCode) {
return errMsgs.getString(errorCode);
}
});
sb.appendHtmlConstant(
"<div title='" + Joiner.on("<br/>").join(warningMsgs) + "' style='background-color: yellow;'>" +
property.asHtml() + "</div>");
} else {
sb.appendHtmlConstant(property.asHtml());
}
}
return sb.toSafeHtml();
}
};
resultTable.addColumn(column, cell.getTitle());
colMap.put(cell.getTitle(), column);
sortHandler.setComparator(column, new Comparator<List<ResultCell>>() {
@Override
public int compare(List<ResultCell> cell1s, List<ResultCell> cell2s) {
// dynamic columns, both c1 and c2 can be null
ResultCell c1 = lookupCell(cell.getTitle(), cell1s);
ResultCell c2 = lookupCell(cell.getTitle(), cell2s);
if (c1 == null) {
if (c2 == null) {
return 0;
} else {