final WebMarkupContainer membershipsContainer = new WebMarkupContainer("membershipsContainer");
membershipsContainer.setOutputMarkupId(true);
add(membershipsContainer);
final ModalWindow membWin = new ModalWindow("membershipWin");
membWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
membWin.setCookieName("create-membership-modal");
add(membWin);
final ITreeProvider<DefaultMutableTreeNode> treeProvider = new TreeRoleProvider(roleTreeBuilder, true);
final DefaultMutableTreeNodeExpansionModel treeModel = new DefaultMutableTreeNodeExpansionModel();
tree = new DefaultNestedTree<DefaultMutableTreeNode>("treeTable", treeProvider, treeModel) {
private static final long serialVersionUID = 7137658050662575546L;
@Override
protected Component newContentComponent(final String id, final IModel<DefaultMutableTreeNode> node) {
final DefaultMutableTreeNode treeNode = node.getObject();
final RoleTO roleTO = (RoleTO) treeNode.getUserObject();
return new Folder<DefaultMutableTreeNode>(id, MembershipsPanel.this.tree, node) {
private static final long serialVersionUID = 9046323319920426493L;
@Override
protected boolean isClickable() {
return true;
}
@Override
protected IModel<?> newLabelModel(final IModel<DefaultMutableTreeNode> model) {
return new Model<String>(roleTO.getDisplayName());
}
@Override
protected void onClick(final AjaxRequestTarget target) {
if (roleTO.getId() > 0) {
membWin.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = 7661763358801821185L;
@Override
public Page createPage() {
PageReference pageRef = getPage().getPageReference();
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) {