}
@Override
public void populateItem(final Item<ICellPopulator<ResourceTO>> cellItem, final String componentId,
final IModel<ResourceTO> model) {
final ResourceTO resourceTO = model.getObject();
final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, getPageReference());
panel.add(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
editResourceWin.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
ResourceModalPage form = new ResourceModalPage(Resources.this.getPageReference(),
editResourceWin, resourceTO, false);
return form;
}
});
editResourceWin.show(target);
}
}, ActionLink.ActionType.EDIT, "Resources", "read");
panel.add(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
resourceRestClient.delete(resourceTO.getName());
info(getString("operation_succeded"));
} catch (SyncopeClientCompositeErrorException e) {
error(getString("operation_error"));
LOG.error("While deleting resource " + resourceTO.getName(), e);
}
target.add(feedbackPanel);
target.add(resourceContainer);
}
}, ActionLink.ActionType.DELETE, "Resources", "delete");
cellItem.add(panel);
}
});
final AjaxFallbackDefaultDataTable table = new AjaxFallbackDefaultDataTable("resourceDatatable", columns,
new ResourcesProvider(), resourcePaginatorRows);
resourceContainer = new WebMarkupContainer("resourceContainer");
resourceContainer.add(table);
resourceContainer.setOutputMarkupId(true);
add(resourceContainer);
setWindowClosedCallback(createResourceWin, resourceContainer);
setWindowClosedCallback(editResourceWin, resourceContainer);
createResourceWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
createResourceWin.setInitialHeight(WIN_HEIGHT);
createResourceWin.setInitialWidth(WIN_WIDTH);
createResourceWin.setCookieName("create-res-modal");
editResourceWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
editResourceWin.setInitialHeight(WIN_HEIGHT);
editResourceWin.setInitialWidth(WIN_WIDTH);
editResourceWin.setCookieName("edit-res-modal");
AjaxLink createResourceLink = new ClearIndicatingAjaxLink("createResourceLink", getPageReference()) {
private static final long serialVersionUID = -7978723352517770644L;
@Override
protected void onClickInternal(final AjaxRequestTarget target) {
createResourceWin.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
final ResourceModalPage windows = new ResourceModalPage(Resources.this.getPageReference(),
editResourceWin, new ResourceTO(), true);
return windows;
}
});
createResourceWin.show(target);