*
* @param attributeInfo attribute info
* @return field for grid
*/
private ListGridField createAttributeGridField(final AttributeInfo attributeInfo) {
ListGridField gridField = new ListGridField(attributeInfo.getName(), attributeInfo.getLabel());
gridField.setAlign(Alignment.LEFT);
gridField.setCanEdit(false);
gridField.setShowIfCondition(new IdentifyingListGridFieldIfFunction(attributeInfo.isIdentifying()));
if (attributeInfo instanceof PrimitiveAttributeInfo) {
PrimitiveAttributeInfo info = (PrimitiveAttributeInfo) attributeInfo;
if (info.getType().equals(PrimitiveType.BOOLEAN)) {
gridField.setType(ListGridFieldType.BOOLEAN);
} else if (info.getType().equals(PrimitiveType.STRING)) {
gridField.setType(ListGridFieldType.TEXT);
} else if (info.getType().equals(PrimitiveType.DATE)) {
gridField.setType(ListGridFieldType.DATE);
} else if (info.getType().equals(PrimitiveType.SHORT)) {
gridField.setType(ListGridFieldType.INTEGER);
} else if (info.getType().equals(PrimitiveType.INTEGER)) {
gridField.setType(ListGridFieldType.INTEGER);
} else if (info.getType().equals(PrimitiveType.LONG)) {
gridField.setType(ListGridFieldType.INTEGER);
} else if (info.getType().equals(PrimitiveType.FLOAT)) {
gridField.setType(ListGridFieldType.FLOAT);
} else if (info.getType().equals(PrimitiveType.DOUBLE)) {
gridField.setType(ListGridFieldType.FLOAT);
} else if (info.getType().equals(PrimitiveType.IMGURL)) {
gridField.setType(ListGridFieldType.IMAGE);
if (showImageAttributeOnHover) {
addCellOverHandler(new ImageCellHandler(attributeInfo));
}
} else if (info.getType().equals(PrimitiveType.CURRENCY)) {
gridField.setType(ListGridFieldType.TEXT);
} else if (info.getType().equals(PrimitiveType.URL)) {
gridField.setType(ListGridFieldType.TEXT);
gridField.setAttribute("text-decoration", "underline");
addCellClickHandler(new UrlCellHandler(attributeInfo));
}
} else if (attributeInfo instanceof AssociationAttributeInfo) {
gridField.setType(ListGridFieldType.TEXT);
}
return gridField;
}