for (MembershipTO membTO : membView.getList()) {
if (membTO.getRoleId() == roleTO.getId()) {
return new MembershipModalPage(pageRef, membWin, membTO, templateMode);
}
}
MembershipTO membTO = new MembershipTO();
membTO.setRoleId(roleTO.getId());
membTO.setRoleName(roleTO.getName());
return new MembershipModalPage(pageRef, membWin, membTO, templateMode);
}
});
membWin.show(target);
}
};
}
};
tree.add(new WindowsTheme());
tree.setOutputMarkupId(true);
DefaultMutableTreeNodeExpansion.get().expandAll();
this.add(tree);
membView = new ListView<MembershipTO>("memberships",
new PropertyModel<List<? extends MembershipTO>>(userTO, "memberships")) {
private static final long serialVersionUID = 9101744072914090143L;
@Override
protected void populateItem(final ListItem<MembershipTO> item) {
final MembershipTO membershipTO = (MembershipTO) item.getDefaultModelObject();
item.add(new Label("roleId", new Model<Long>(membershipTO.getRoleId())));
item.add(new Label("roleName", new Model<String>(membershipTO.getRoleName())));
AjaxLink editLink = new ClearIndicatingAjaxLink("editLink", pageRef) {
private static final long serialVersionUID = -7978723352517770644L;
@Override
protected void onClickInternal(final AjaxRequestTarget target) {
membWin.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
return new MembershipModalPage(getPage().getPageReference(), membWin,
membershipTO, templateMode);
}
});
membWin.show(target);
}
};
item.add(editLink);
AjaxLink deleteLink = new IndicatingDeleteOnConfirmAjaxLink("deleteLink", pageRef) {
private static final long serialVersionUID = -7978723352517770644L;
@Override
protected void onClickInternal(final AjaxRequestTarget target) {
userTO.removeMembership(membershipTO);
target.add(membershipsContainer);
RoleTO roleTO = RoleUtils.findRole(roleTreeBuilder, membershipTO.getRoleId());
Set<String> resourcesToRemove = roleTO == null
? Collections.<String>emptySet() : roleTO.getResources();
if (!resourcesToRemove.isEmpty()) {
Set<String> resourcesAssignedViaMembership = new HashSet<String>();
for (MembershipTO membTO : userTO.getMemberships()) {