@Override
public void populateItem(final Item<ICellPopulator<ReportTO>> cellItem, final String componentId,
final IModel<ReportTO> model) {
final ReportTO reportTO = model.getObject();
final ActionLinksPanel panel = new ActionLinksPanel(componentId, model);
panel.add(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
window.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
return new ReportModalPage(window, reportTO, Reports.this.getPageReference());
}
});
window.show(target);
}
}, ActionLink.ActionType.EDIT, "Reports", "read");
panel.add(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
reportRestClient.startExecution(reportTO.getId());
getSession().info(getString("operation_succeded"));
} catch (SyncopeClientCompositeErrorException scce) {
error(scce.getMessage());
}
target.add(getPage().get("feedback"));
target.add(reportContainer);
}
}, ActionLink.ActionType.EXECUTE, "Reports", "execute");
panel.add(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
reportRestClient.delete(reportTO.getId());
info(getString("operation_succeded"));
} catch (SyncopeClientCompositeErrorException scce) {
error(scce.getMessage());
}
target.add(reportContainer);
target.add(getPage().get("feedback"));
}
}, ActionLink.ActionType.DELETE, "Reports", "delete");
cellItem.add(panel);
}
});
final AjaxFallbackDefaultDataTable reportTable = new AjaxFallbackDefaultDataTable("reportTable", columns,
new ReportProvider(), paginatorRows);
reportContainer.add(reportTable);
reportContainer.setOutputMarkupId(true);
add(reportContainer);
Form paginatorForm = new Form("paginatorForm");
MetaDataRoleAuthorizationStrategy.authorize(paginatorForm, RENDER, xmlRolesReader.getAllAllowedRoles("Reports",
"list"));
final DropDownChoice rowsChooser = new DropDownChoice("rowsChooser", new PropertyModel(this, "paginatorRows"),
prefMan.getPaginatorChoices());
rowsChooser.add(new AjaxFormComponentUpdatingBehavior("onchange") {
private static final long serialVersionUID = -1107858522700306810L;
@Override
protected void onUpdate(final AjaxRequestTarget target) {
prefMan.set(getRequest(), getResponse(), Constants.PREF_REPORT_PAGINATOR_ROWS,
String.valueOf(paginatorRows));
reportTable.setItemsPerPage(paginatorRows);
target.add(reportContainer);
}
});
paginatorForm.add(rowsChooser);
add(paginatorForm);
AjaxLink createLink = new IndicatingAjaxLink("createLink") {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
window.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
return new ReportModalPage(window, new ReportTO(), Reports.this.getPageReference());
}
});
window.show(target);
}