throw new IllegalArgumentException("Entity Type not supported");
}
}
});
pinnedField.setShowHover(true);
pinnedField.setHoverCustomizer(new HoverCustomizer() {
public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
return ImageManager.getPinnedIcon().equals(record.getAttribute(ATTR_IS_PINNED)) ? MSG
.view_drift_table_hover_defPinned() : MSG.view_drift_table_hover_defNotPinned();
}
});
fields.add(pinnedField);
ListGridField changeSetField = new ListGridField(ATTR_CHANGE_SET_VERSION, MSG.view_drift_table_snapshot());
changeSetField.setCanSortClientOnly(true);
fields.add(changeSetField);
ListGridField changeSetTimeField = new ListGridField(ATTR_CHANGE_SET_CTIME, MSG.view_drift_table_snapshotTime());
changeSetTimeField.setCellFormatter(new TimestampCellFormatter());
changeSetTimeField.setShowHover(true);
changeSetTimeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(ATTR_CHANGE_SET_CTIME));
changeSetTimeField.setCanSortClientOnly(true);
fields.add(changeSetTimeField);
ListGridField enabledField = new ListGridField(ATTR_IS_ENABLED_ICON, MSG.common_title_enabled());
enabledField.setType(ListGridFieldType.IMAGE);
enabledField.setAlign(Alignment.CENTER);
fields.add(enabledField);
ListGridField inComplianceField = new ListGridField(ATTR_COMPLIANCE_ICON, MSG.common_title_in_compliance());
inComplianceField.setType(ListGridFieldType.IMAGE);
inComplianceField.setAlign(Alignment.CENTER);
inComplianceField.setShowHover(true);
inComplianceField.setHoverCustomizer(new HoverCustomizer() {
@Override
public String hoverHTML(Object o, ListGridRecord record, int row, int column) {
int complianceCode = record.getAttributeAsInt(ATTR_COMPLIANCE);
DriftComplianceStatus complianceStatus = DriftComplianceStatus.fromCode(complianceCode);
switch (complianceStatus) {
case OUT_OF_COMPLIANCE_NO_BASEDIR:
return MSG.view_drift_table_hover_outOfCompliance_noBaseDir();
case OUT_OF_COMPLIANCE_DRIFT:
return MSG.view_drift_table_hover_outOfCompliance_drift();
default:
return "";
}
}
});
fields.add(inComplianceField);
/*
ListGridField driftHandlingModeField = new ListGridField(ATTR_DRIFT_HANDLING_MODE, MSG
.view_drift_table_driftHandlingMode());
fields.add(driftHandlingModeField);
*/
/*
ListGridField intervalField = new ListGridField(ATTR_INTERVAL, MSG.common_title_interval());
fields.add(intervalField);
*/
ListGridField baseDirField = new ListGridField(ATTR_BASE_DIR_STRING, MSG.view_drift_table_baseDir());
changeSetTimeField.setCanSortClientOnly(true);
fields.add(baseDirField);
ListGridField attachedField = new ListGridField(ATTR_ATTACHED, MSG.view_drift_table_attached());
fields.add(attachedField);
ListGridField templateField = new ListGridField(ATTR_TEMPLATE, MSG.view_drift_table_template());
templateField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
DriftDefinition def = (DriftDefinition) listGridRecord.getAttributeAsObject(ATTR_ENTITY);
if (null == def.getTemplate()) {
return MSG.common_val_none();
}
if (null != globalPermissions && globalPermissions.contains(Permission.MANAGE_SETTINGS)) {
int typeId = def.getResource().getResourceType().getId();
int templateId = def.getTemplate().getId();
String link = LinkManager.getDriftTemplateLink(typeId, templateId);
return LinkManager.getHref(link, o.toString());
} else {
return o.toString();
}
}
});
templateField.setCanSortClientOnly(true);
fields.add(templateField);
ListGridField editField = new ListGridField(ATTR_EDIT, hasWriteAccess ? MSG.common_title_edit() : MSG.common_title_view_mode());
editField.setType(ListGridFieldType.IMAGE);
editField.setAlign(Alignment.CENTER);
editField.setShowHover(true);
editField.setCanSort(false);
editField.addRecordClickHandler(new RecordClickHandler() {
public void onRecordClick(RecordClickEvent event) {
switch (entityContext.getType()) {
case Resource:
CoreGUI.goToView(LinkManager.getDriftDefinitionEditLink(entityContext.getResourceId(), event
.getRecord().getAttributeAsInt(ATTR_ID)));
break;
default:
throw new IllegalArgumentException("Entity Type not supported");
}
}
});
editField.setHoverCustomizer(new HoverCustomizer() {
public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
return MSG.view_drift_table_hover_edit();
}
});
fields.add(editField);
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) {
Integer resourceId = listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
String url = LinkManager.getResourceLink(resourceId);
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);
}
});
fields.add(resourceNameField);