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());
}