@Override
public void populateItem(final Item<ICellPopulator<TaskTO>> cellItem, final String componentId,
final IModel<TaskTO> model) {
final SyncTaskTO taskTO = (SyncTaskTO) 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 SyncTaskModalPage(window, taskTO, callerPageRef);
}
});
window.show(target);
}
}, ActionLink.ActionType.EDIT, "Tasks", "read");
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 UserTemplateModalPage(callerPageRef, window, taskTO);
}
});
window.show(target);
}
}, ActionLink.ActionType.TEMPLATE, "Tasks", "read");
panel.add(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
restClient.startExecution(taskTO.getId(), false);
getSession().info(getString("operation_succeded"));
} catch (SyncopeClientCompositeErrorException scce) {
error(scce.getMessage());
}
target.add(container);
target.add(getPage().get("feedback"));
}
}, ActionLink.ActionType.EXECUTE, "Tasks", "execute");
panel.add(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
restClient.startExecution(taskTO.getId(), true);
getSession().info(getString("operation_succeded"));
} catch (SyncopeClientCompositeErrorException scce) {
error(scce.getMessage());
}
target.add(container);
target.add(getPage().get("feedback"));
}
}, ActionLink.ActionType.DRYRUN, "Tasks", "execute");
panel.add(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
restClient.delete(taskTO.getId(), SyncTaskTO.class);
info(getString("operation_succeded"));
} catch (SyncopeClientCompositeErrorException scce) {
error(scce.getMessage());
}
target.add(container);
target.add(getPage().get("feedback"));
}
}, ActionLink.ActionType.DELETE, "Tasks", "delete");
cellItem.add(panel);
}
});
table = Tasks.updateTaskTable(
columns,
new TasksProvider(restClient, paginatorRows, getId(), SyncTaskTO.class),
container,
0);
container.add(table);
Form paginatorForm = new Form("PaginatorForm");
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(getWebRequest(), (WebResponse) getResponse(), Constants.PREF_SYNC_TASKS_PAGINATOR_ROWS,
String.valueOf(paginatorRows));
table = Tasks.updateTaskTable(
columns,
new TasksProvider(restClient, paginatorRows, getId(), SyncTaskTO.class),
container,
table == null ? 0 : table.getCurrentPage());
target.add(container);
}
});
paginatorForm.add(rowsChooser);
add(paginatorForm);
// create new user
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 SyncTaskModalPage(window, new SyncTaskTO(), callerPageRef);
}
});
window.show(target);
}