ListGridField priorityField = new ListGridField("priority", MSG.view_alerts_field_priority());
priorityField.setType(ListGridFieldType.IMAGE);
priorityField.setAlign(Alignment.CENTER);
priorityField.setShowHover(true);
priorityField.setHoverCustomizer(new HoverCustomizer() {
@Override
public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
String prio = record.getAttribute("priority");
if (PRIORITY_ICON_HIGH.equals(prio)) {
return MSG.common_alert_high();
} else if (PRIORITY_ICON_MEDIUM.equals(prio)) {
return MSG.common_alert_medium();
} else if (PRIORITY_ICON_LOW.equals(prio)) {
return MSG.common_alert_low();
} else {
return ""; // will never get here
}
}
});
fields.add(priorityField);
ListGridField statusField = new ListGridField("acknowledgingSubject", MSG.common_title_acknowledged());
statusField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
String ackSubject = listGridRecord.getAttribute("acknowledgingSubject");
if (ackSubject == null) {
return " ";
} else {
Img checkedImg = new Img(ImageManager.getAlertStatusCheckedIcon(),80,16);
checkedImg.setImageType(ImageStyle.CENTER);
return checkedImg.getInnerHTML();
}
}
});
statusField.setShowHover(true);
statusField.setHoverCustomizer(new HoverCustomizer() {
public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
String ackSubject = record.getAttribute("acknowledgingSubject");
StringBuilder sb = new StringBuilder("<p");
if (ackSubject == null) {
sb.append(" style='width:150px'>");
sb.append(MSG.view_alerts_field_ack_status_noAckHover());
} else {
sb.append(" style='width:500px'>");
Date ackDateTime = record.getAttributeAsDate("acknowledgeTime");
String ackDateTimeString = TimestampCellFormatter.format(ackDateTime,
TimestampCellFormatter.DATE_TIME_FORMAT_FULL);
sb.append(MSG.view_alerts_field_ack_status_ackHover(ackSubject, ackDateTimeString));
}
sb.append("</p>");
return sb.toString();
}
});
fields.add(statusField);
ListGridField recoveredField = new ListGridField("recovered", MSG.common_title_recovered());
recoveredField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
Long recovered = listGridRecord.getAttributeAsLong("recovered");
if(recovered.longValue() > 0) {
Img checkedImg = new Img(ImageManager.getAlertStatusCheckedIcon(),80,16);
checkedImg.setImageType(ImageStyle.CENTER);
return checkedImg.getInnerHTML();
} else {
return " ";
}
}
});
recoveredField.setHoverCustomizer(new HoverCustomizer() {
@Override
public String hoverHTML(Object o, ListGridRecord listGridRecord, int i, int i2) {
Long recovered = listGridRecord.getAttributeAsLong("recovered");
if(recovered.longValue() > 0) {
Date recoveredTime = listGridRecord.getAttributeAsDate("recoveredTime");
String recoveredTimeString = TimestampCellFormatter.format(recoveredTime,
TimestampCellFormatter.DATE_TIME_FORMAT_FULL);
return new StringBuilder()
.append("<p style='width:500px'>")
.append(MSG.view_alerts_field_recovered_status_hover(recoveredTimeString))
.append("</p>").toString();
}
return "";
}
});
recoveredField.setShowHover(true);
fields.add(recoveredField);
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 value, ListGridRecord record, int rowNum, int colNum) {
String url = LinkManager.getResourceLink(record.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
return LinkManager.getHref(url, value.toString());
}
});
resourceNameField.setShowHover(true);
resourceNameField.setHoverCustomizer(new HoverCustomizer() {
public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
}
});