TimestampCellFormatter.prepareDateField(timestampField);
fields.add(timestampField);
ListGridField severityField = new ListGridField("severity", MSG.view_inventory_eventHistory_severity());
severityField.setAlign(Alignment.CENTER);
severityField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
String icon = ImageManager.getEventSeverityBadge(EventSeverity.valueOf(o.toString()));
return Canvas.imgHTML(icon, 24, 24);
}
});
severityField.setShowHover(true);
severityField.setHoverCustomizer(new HoverCustomizer() {
public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
String sevEnumName = record.getAttribute("severity");
if (sevEnumName == null) {
return null;
}
EventSeverity severity = EventSeverity.valueOf(sevEnumName);
switch (severity) {
case DEBUG:
return MSG.common_severity_debug();
case INFO:
return MSG.common_severity_info();
case WARN:
return MSG.common_severity_warn();
case ERROR:
return MSG.common_severity_error();
case FATAL:
return MSG.common_severity_fatal();
default:
return null;
}
}
});
fields.add(severityField);
ListGridField detailField = new ListGridField("detail", MSG.view_inventory_eventHistory_details());
detailField.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
if (null == value) {
return "";
} else if (((String) value).length() <= 200) {
return (String) value;
} else {
return ((String) value).substring(0, 200); // first 200 chars
}
}
});
fields.add(detailField);
ListGridField sourceField = new ListGridField("source", MSG.view_inventory_eventHistory_sourceLocation());
sourceField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
String sourceLocation = listGridRecord.getAttribute("source");
int length = sourceLocation.length();
if (length > 40) {
return "..." + sourceLocation.substring(length - 40); // the last 40 chars
}
return sourceLocation;
}
});
sourceField.setShowHover(true);
sourceField.setHoverCustomizer(new HoverCustomizer() {
public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
if (value == null) {
return null;
}
String sourceLocation = (String) value;
return (sourceLocation.length() > 40) ? sourceLocation : null;
}
});
fields.add(sourceField);
if (this.entityContext.type != EntityContext.Type.Resource) {
ListGridField resourceNameField = new ListGridField(AncestryUtil.RESOURCE_NAME, MSG.common_title_resource());
resourceNameField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
return LinkManager.getHref(url, o.toString());
}
});