private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<Resource>> cellItem,
String componentId, IModel<Resource> rowModel) {
Resource entity = rowModel.getObject();
cellItem.add(new Label(
componentId, entity.getTitle()));
}
});
// Owner column
columns.add(new AbstractColumn<Resource, String>(new ResourceModel(MKEY_OWNER),
Resource.FIELD_OWNER + "." + User.FIELD_DISPLAY_NAME) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<Resource>> cellItem,
String componentId, IModel<Resource> rowModel) {
Resource resource = rowModel.getObject();
User owner = resource.getOwner();
cellItem.add(new Label(componentId, owner == null ? "" : owner.getDisplayName()));
}
});
// Producers column
columns.add(new AbstractColumn<Resource, String>(new ResourceModel(MKEY_PRODUCERS)) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<Resource>> cellItem,
String componentId, IModel<Resource> rowModel) {
Resource resource = rowModel.getObject();
Set<User> consumers = getResourceTenderOwners(
resource.getSupplies());
String representation = representationFactory.getRepresentation(
consumers, CLEN_TENDER_OWNERS);
cellItem.add(new Label(componentId, representation));
}
});
// Consumers column
columns.add(new AbstractColumn<Resource, String>(new ResourceModel(MKEY_CONSUMERS)) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<Resource>> cellItem,
String componentId, IModel<Resource> rowModel) {
Resource resource = rowModel.getObject();
Set<User> consumers = getResourceTenderOwners(resource.getNeeds());
String representation = representationFactory.getRepresentation(
consumers, CLEN_TENDER_OWNERS);
cellItem.add(new Label(componentId, representation));
}
});
// Needed/Supplied amount column
columns.add(new AbstractColumn<Resource, String>(new ResourceModel(MKEY_AMOUNT)) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<Resource>> cellItem,
String componentId, IModel<Resource> rowModel) {
Resource resource = rowModel.getObject();
cellItem.add(new Label(componentId,
resourceInformant.getConsumeAmount(resource).toString() + " / "
+ resourceInformant.getSupplyAmount(resource).toString() + " "
+ getString(CommonStringKeys.MKEY_UOM_PREFIX + resourceInformant.getResourceUOM(resource))));
}