@Override
public void populateItem(final Item<ICellPopulator<NotificationTO>> cellItem, final String componentId,
final IModel<NotificationTO> model) {
final NotificationTO notificationTO = 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) {
editNotificationWin.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
return new NotificationModalPage(Configuration.this.getPageReference(),
editNotificationWin, notificationTO, false);
}
});
editNotificationWin.show(target);
}
}, ActionLink.ActionType.EDIT, "Notification");
panel.add(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
notificationRestClient.deleteNotification(notificationTO.getId());
} catch (SyncopeClientCompositeErrorException e) {
LOG.error("While deleting a notification", e);
error(e.getMessage());
return;
}
info(getString("operation_succeeded"));
target.add(feedbackPanel);
target.add(notificationContainer);
}
}, ActionLink.ActionType.DELETE, "Notification");
cellItem.add(panel);
}
});
final AjaxFallbackDefaultDataTable notificationTable = new AjaxFallbackDefaultDataTable("notificationTable",
notificationCols, new NotificationProvider(), notificationPaginatorRows);
notificationContainer = new WebMarkupContainer("notificationContainer");
notificationContainer.add(notificationTable);
notificationContainer.setOutputMarkupId(true);
add(notificationContainer);
createNotificationWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
createNotificationWin.setInitialHeight(NOTIFICATION_WIN_HEIGHT);
createNotificationWin.setInitialWidth(NOTIFICATION_WIN_WIDTH);
createNotificationWin.setCookieName("create-notification-modal");
editNotificationWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
editNotificationWin.setInitialHeight(NOTIFICATION_WIN_HEIGHT);
editNotificationWin.setInitialWidth(NOTIFICATION_WIN_WIDTH);
editNotificationWin.setCookieName("edit-notification-modal");
setWindowClosedCallback(createNotificationWin, notificationContainer);
setWindowClosedCallback(editNotificationWin, notificationContainer);
AjaxLink createNotificationLink = new AjaxLink("createNotificationLink") {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
createNotificationWin.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
return new NotificationModalPage(Configuration.this.getPageReference(), createNotificationWin,
new NotificationTO(), true);
}
});
createNotificationWin.show(target);
}