final List<IColumn<HRPlanningEntryDO, String>> columns = new ArrayList<IColumn<HRPlanningEntryDO, String>>();
final CellItemListener<HRPlanningEntryDO> cellItemListener = new CellItemListener<HRPlanningEntryDO>() {
public void populateItem(final Item<ICellPopulator<HRPlanningEntryDO>> item, final String componentId,
final IModel<HRPlanningEntryDO> rowModel)
{
final HRPlanningEntryDO entry = rowModel.getObject();
appendCssClasses(item, entry.getPlanningId(), entry.isDeleted());
}
};
columns.add(new UserPropertyColumn<HRPlanningEntryDO>(getString("timesheet.user"), "planning.user.fullname", "planning.user",
cellItemListener) {
@Override
public void populateItem(final Item<ICellPopulator<HRPlanningEntryDO>> item, final String componentId,
final IModel<HRPlanningEntryDO> rowModel)
{
if (hasFullAccess() == true) {
item.add(new ListSelectActionPanel(componentId, rowModel, HRPlanningEditPage.class, rowModel.getObject().getPlanning().getId(),
HRPlanningListPage.this, getLabelString(rowModel)));
addRowClick(item);
} else {
item.add(new Label(componentId, getLabelString(rowModel)));
}
cellItemListener.populateItem(item, componentId, rowModel);
}
}.withUserFormatter(userFormatter));
columns.add(new CellItemListenerPropertyColumn<HRPlanningEntryDO>(getString("calendar.year"), "planning.week", "planning.week",
cellItemListener) {
@Override
public void populateItem(final Item<ICellPopulator<HRPlanningEntryDO>> item, final String componentId,
final IModel<HRPlanningEntryDO> rowModel)
{
final HRPlanningEntryDO entry = rowModel.getObject();
final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy");
final String year = simpleDateFormat.format(entry.getPlanning().getWeek());
final Label label = new Label(componentId, year);
item.add(label);
cellItemListener.populateItem(item, componentId, rowModel);
}
});
columns.add(new CellItemListenerPropertyColumn<HRPlanningEntryDO>(getString("calendar.weekOfYearShortLabel"),
"planning.formattedWeekOfYear", "planning.formattedWeekOfYear", cellItemListener));
columns.add(new CellItemListenerPropertyColumn<HRPlanningEntryDO>(getString("fibu.kunde"), "projekt.kunde.name", "projekt.kunde.name",
cellItemListener));
columns.add(new CellItemListenerPropertyColumn<HRPlanningEntryDO>(new Model<String>(getString("fibu.projekt")), "projektNameOrStatus",
"projektNameOrStatus", cellItemListener));
columns.add(new CellItemListenerPropertyColumn<HRPlanningEntryDO>(getString("hr.planning.priority"), "priority", "priority",
cellItemListener) {
@Override
public void populateItem(final Item<ICellPopulator<HRPlanningEntryDO>> item, final String componentId,
final IModel<HRPlanningEntryDO> rowModel)
{
final String formattedPriority = priorityFormatter.getFormattedPriority(rowModel.getObject().getPriority());
final Label label = new Label(componentId, new Model<String>(formattedPriority));
label.setEscapeModelStrings(false);
item.add(label);
cellItemListener.populateItem(item, componentId, rowModel);
cellItemListener.populateItem(item, componentId, rowModel);
}
});
columns.add(newNumberPropertyColumn("hr.planning.probability.short", "probability", cellItemListener).withSuffix("%"));
columns.add(newNumberPropertyColumn("hr.planning.total", "planning.totalHours", cellItemListener));
columns.add(newNumberPropertyColumn("hr.planning.sum", "totalHours", cellItemListener));
columns.add(newNumberPropertyColumn("hr.planning.unassignedHours", "unassignedHours", cellItemListener));
columns.add(newNumberPropertyColumn("calendar.shortday.monday", "mondayHours", cellItemListener));
columns.add(newNumberPropertyColumn("calendar.shortday.tuesday", "tuesdayHours", cellItemListener));
columns.add(newNumberPropertyColumn("calendar.shortday.wednesday", "wednesdayHours", cellItemListener));
columns.add(newNumberPropertyColumn("calendar.shortday.thursday", "thursdayHours", cellItemListener));
columns.add(newNumberPropertyColumn("calendar.shortday.friday", "fridayHours", cellItemListener));
columns.add(newNumberPropertyColumn("hr.planning.weekend", "weekendHours", cellItemListener));
columns.add(new CellItemListenerPropertyColumn<HRPlanningEntryDO>(getString("hr.planning.description"), "description", "description",
cellItemListener) {
@Override
public void populateItem(final Item<ICellPopulator<HRPlanningEntryDO>> item, final String componentId,
final IModel<HRPlanningEntryDO> rowModel)
{
final HRPlanningEntryDO entry = rowModel.getObject();
final Label label = new Label(componentId, new Model<String>() {
@Override
public String getObject()
{
String text;
if (form.getSearchFilter().isLongFormat() == true) {
text = HtmlHelper.escapeXml(entry.getDescription());
} else {
text = HtmlHelper.escapeXml(entry.getShortDescription());
}
return JiraUtils.linkJiraIssues(text); // Not in mass update mode: link on table row results otherwise in JIRA-Link.
}
});
label.setEscapeModelStrings(false);