private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<Contract>> cellItem,
String componentId, IModel<Contract> rowModel) {
Contract contract = rowModel.getObject();
cellItem.add(new Label(componentId, contract.getTitle()));
}
});
//Contract's creator column
columns.add(new AbstractColumn<Contract, String>(new ResourceModel(MKEY_CONTRACT_CREATOR),
Contract.FIELD_OWNER + "." + User.FIELD_DISPLAY_NAME) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<Contract>> cellItem,
String componentId, IModel<Contract> rowModel) {
String creatorNickName = "";
Contract contract = rowModel.getObject();
User creator = contract.getOwner();
if(creator != null) {
creatorNickName = creator.getDisplayName();
}
cellItem.add(new Label(componentId, creatorNickName));
}
@Override
public String getCssClass() {
return "creatorColumn";
}
});
// Resources column
columns.add(new AbstractColumn<Contract, String>(new ResourceModel(MKEY_CONTRACT_RESOURCES)) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<Contract>> cellItem,
String componentId, IModel<Contract> rowModel) {
Contract contract = rowModel.getObject();
String representation = representationFactory.getRepresentation(
contract.getResources(), CLEN_RESOURCES);
cellItem.add(new Label(componentId, representation));
}
});
// Status column
columns.add(new AbstractColumn<Contract, String>(new ResourceModel(MKEY_CONTRACT_STATUS), Contract.FIELD_STATUS) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<Contract>> cellItem,
String componentId, IModel<Contract> rowModel) {
Contract contract = rowModel.getObject();
ContractStatus contractStatus = contractStatusInformant.getContractStatus(contract,
authorizedUserService.getCurrentUserId());
if(contractStatus != null) {
cellItem.add(new Label(componentId, new ResourceModel(MKEY_STATE_PREFIX + contractStatus.name())));
} else {
cellItem.add(new Label(componentId, "???"));
}
}
});
// Creation date column
columns.add(new AbstractColumn<Contract, String>(new ResourceModel(MKEY_CONTRACT_CREATION), Contract.FIELD_CREATION_DATE) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<Contract>> cellItem,
String componentId, IModel<Contract> rowModel) {
Contract contract = rowModel.getObject();
Date date = contract.getCreationDate();
cellItem.add(new Label(componentId, date == null ? "" : DateFormat.getInstance().format(date)));
}
});
// Modified date column
columns.add(new AbstractColumn<Contract, String>(new ResourceModel(MKEY_CONTRACT_MODIFICATION), Contract.FIELD_MODIFICATION_DATE) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<Contract>> cellItem,
String componentId, IModel<Contract> rowModel) {
Contract contract = rowModel.getObject();
Date date = contract.getModificationDate();
cellItem.add(new Label(componentId, date == null ? "" : DateFormat.getInstance().format(date)));
}
});
// Viewers count column
columns.add(new AbstractColumn<Contract, String>(new ResourceModel(MKEY_VIEWERS_COUNT),
Contract.FIELD_VIWERS_COUNT) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<Contract>> cellItem,
String componentId, IModel<Contract> rowModel) {
Contract contract = rowModel.getObject();
Integer viewersCount = contract.getViewersCount();
cellItem.add(new Label(componentId, viewersCount == null ? "" : viewersCount.toString()));
}
});