public ArrayList<ListGridField> getListGridFields(boolean includeResourceFields) {
ArrayList<ListGridField> fields = new ArrayList<ListGridField>();
ListGridField idField = new ListGridField(Field.ID, MSG.common_title_version());
idField.setShowHover(true);
idField.setHoverCustomizer(new HoverCustomizer() {
@Override
public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
if (Boolean.parseBoolean(record.getAttribute(Field.CURRENT_CONFIG))) {
return MSG.dataSource_configurationHistory_currentConfig();
}
return null;
}
});
fields.add(idField);
ListGridField submittedTimeField = new ListGridField(Field.CREATED_TIME, MSG
.dataSource_configurationHistory_dateSubmitted());
submittedTimeField.setType(ListGridFieldType.DATE);
TimestampCellFormatter.prepareDateField(submittedTimeField);
fields.add(submittedTimeField);
ListGridField completedTimeField = new ListGridField(Field.MODIFIED_TIME, MSG
.dataSource_configurationHistory_dateCompleted());
completedTimeField.setType(ListGridFieldType.DATE);
TimestampCellFormatter.prepareDateField(completedTimeField);
fields.add(completedTimeField);
ListGridField statusField = new ListGridField(Field.STATUS, MSG.common_title_status());
statusField.setAlign(Alignment.CENTER);
statusField.setCellFormatter(new CellFormatter() {
public String format(Object value, ListGridRecord listGridRecord, int i, int i1) {
ConfigurationUpdateStatus status = ConfigurationUpdateStatus.valueOf(value.toString());
return Canvas.imgHTML(getConfigurationUpdateStatusIcon(status), 16, 16);
}
});
statusField.setShowHover(true);
statusField.setHoverCustomizer(new HoverCustomizer() {
@Override
public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
String html = getStatusHtmlString(record);
return html;
}
});
statusField.addRecordClickHandler(new RecordClickHandler() {
@Override
public void onRecordClick(RecordClickEvent event) {
String err = event.getRecord().getAttribute(Field.ERROR_MESSAGE);
if (err != null && err.length() > 0) {
err = "<pre>" + err + "</pre>";
new ErrorMessageWindow(MSG.common_severity_error(), err).show();
}
}
});
fields.add(statusField);
ListGridField subjectField = new ListGridField(Field.SUBJECT, MSG.common_title_user());
fields.add(subjectField);
ListGridField updateTypeField = new ListGridField(Field.GROUP_CONFIG_UPDATE_ID, MSG
.dataSource_configurationHistory_updateType());
updateTypeField.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
if (value == null) {
return MSG.dataSource_configurationHistory_updateType_individual();
}
Integer groupId = record.getAttributeAsInt(Field.GROUP_ID);
return "<a href=\"" + getGroupConfigurationUpdateHistoryLink(groupId, (Number) value) + "\">"
+ MSG.dataSource_configurationHistory_updateType_group() + "</a>";
}
});
fields.add(updateTypeField);
// determine the widths of our columns
if (includeResourceFields) {
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());
}
});
resourceNameField.setShowHover(true);
resourceNameField.setHoverCustomizer(new HoverCustomizer() {
public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
}
});