final List<IColumn<GroupTaskAccessDO, String>> columns = new ArrayList<IColumn<GroupTaskAccessDO, String>>();
final CellItemListener<GroupTaskAccessDO> cellItemListener = new CellItemListener<GroupTaskAccessDO>() {
public void populateItem(final Item<ICellPopulator<GroupTaskAccessDO>> item, final String componentId,
final IModel<GroupTaskAccessDO> rowModel)
{
final GroupTaskAccessDO acces = rowModel.getObject();
appendCssClasses(item, acces.getId(), acces.isDeleted());
}
};
columns.add(new CellItemListenerPropertyColumn<GroupTaskAccessDO>(new Model<String>(getString("task")), getSortable("task.title",
sortable), "task.title", cellItemListener) {
/**
* @see org.projectforge.web.wicket.CellItemListenerPropertyColumn#populateItem(org.apache.wicket.markup.repeater.Item,
* java.lang.String, org.apache.wicket.model.IModel)
*/
@Override
public void populateItem(final Item<ICellPopulator<GroupTaskAccessDO>> item, final String componentId,
final IModel<GroupTaskAccessDO> rowModel)
{
final GroupTaskAccessDO access = rowModel.getObject();
final TaskDO task = access.getTask();
final StringBuffer buf = new StringBuffer();
taskFormatter.appendFormattedTask(getRequestCycle(), buf, task, true, false);
final Label formattedTaskLabel = new Label(ListSelectActionPanel.LABEL_ID, buf.toString());
formattedTaskLabel.setEscapeModelStrings(false);
item.add(new ListSelectActionPanel(componentId, rowModel, AccessEditPage.class, access.getId(), returnToPage, formattedTaskLabel));
addRowClick(item);
cellItemListener.populateItem(item, componentId, rowModel);
}
});
columns.add(new CellItemListenerPropertyColumn<GroupTaskAccessDO>(new Model<String>(getString("group")), getSortable("group.name",
sortable), "group.name", cellItemListener));
columns.add(new CellItemListenerPropertyColumn<GroupTaskAccessDO>(new Model<String>(getString("recursive")), getSortable("recursive",
sortable), "recursive", cellItemListener) {
@Override
public void populateItem(final Item<ICellPopulator<GroupTaskAccessDO>> item, final String componentId,
final IModel<GroupTaskAccessDO> rowModel)
{
final GroupTaskAccessDO access = rowModel.getObject();
if (access.isRecursive() == true) {
item.add(new IconPanel(componentId, IconType.ACCEPT));
} else {
item.add(createInvisibleDummyComponent(componentId));
}
cellItemListener.populateItem(item, componentId, rowModel);
}
});
columns.add(new CellItemListenerPropertyColumn<GroupTaskAccessDO>(new Model<String>(getString("access.type")), null, "accessEntries",
cellItemListener) {
@Override
public void populateItem(final Item<ICellPopulator<GroupTaskAccessDO>> item, final String componentId,
final IModel<GroupTaskAccessDO> rowModel)
{
final int rowIndex = ((Item< ? >) item.findParent(Item.class)).getIndex();
final GroupTaskAccessDO access = rowModel.getObject();
final List<AccessEntryDO> accessEntries = access.getOrderedEntries();
final AccessTablePanel accessTablePanel = new AccessTablePanel(componentId, accessEntries);
if (rowIndex == 0) {
accessTablePanel.setDrawHeader(true);
}
item.add(accessTablePanel);
accessTablePanel.init();
cellItemListener.populateItem(item, componentId, rowModel);
}
});
columns.add(new CellItemListenerPropertyColumn<GroupTaskAccessDO>(getString("description"), getSortable("description", sortable),
"description", cellItemListener) {
@Override
public void populateItem(final Item<ICellPopulator<GroupTaskAccessDO>> item, final String componentId,
final IModel<GroupTaskAccessDO> rowModel)
{
final GroupTaskAccessDO access = rowModel.getObject();
final Label label = new Label(componentId, StringUtils.abbreviate(access.getDescription(), 100));
cellItemListener.populateItem(item, componentId, rowModel);
item.add(label);
}
});
return columns;