Example usage for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow setPageCreator

List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow setPageCreator

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow setPageCreator.

Prototype

public ModalWindow setPageCreator(final PageCreator creator) 

Source Link

Document

Sets the PageCreator instance.

Usage

From source file:org.apache.syncope.client.console.panels.GroupDetailsPanel.java

License:Apache License

public GroupDetailsPanel(final String id, final GroupTO groupTO, final boolean templateMode) {
    super(id);/*from  w  w w  .  j a va2s  . c  o m*/

    ownerContainer = new WebMarkupContainer("ownerContainer");
    ownerContainer.setOutputMarkupId(true);
    this.add(ownerContainer);

    final ModalWindow userOwnerSelectWin = new ModalWindow("userOwnerSelectWin");
    userOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    userOwnerSelectWin.setCookieName("create-userOwnerSelect-modal");
    this.add(userOwnerSelectWin);
    final ModalWindow groupOwnerSelectWin = new ModalWindow("groupOwnerSelectWin");
    groupOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    groupOwnerSelectWin.setCookieName("create-groupOwnerSelect-modal");
    this.add(groupOwnerSelectWin);
    final ModalWindow parentSelectWin = new ModalWindow("parentSelectWin");
    parentSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    parentSelectWin.setCookieName("create-parentSelect-modal");
    this.add(parentSelectWin);

    if (templateMode) {
        parentFragment = new Fragment("parent", "parentFragment", this);

        parentModel = new ParentModel(groupTO);
        @SuppressWarnings("unchecked")
        final AjaxTextFieldPanel parent = new AjaxTextFieldPanel("parent", "parent", parentModel);
        parent.setReadOnly(true);
        parent.setOutputMarkupId(true);
        parentFragment.add(parent);
        final AjaxLink<Void> parentSelect = new IndicatingAjaxLink<Void>("parentSelect") {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                parentSelectWin.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = -7834632442532690940L;

                    @Override
                    public Page createPage() {
                        return new GroupSelectModalPage(getPage().getPageReference(), parentSelectWin,
                                ParentSelectPayload.class);
                    }
                });
                parentSelectWin.show(target);
            }
        };
        parentFragment.add(parentSelect);
        final IndicatingAjaxLink<Void> parentReset = new IndicatingAjaxLink<Void>("parentReset") {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                parentModel.setObject(null);
                target.add(parent);
            }
        };
        parentFragment.add(parentReset);
    } else {
        parentFragment = new Fragment("parent", "emptyFragment", this);
    }
    parentFragment.setOutputMarkupId(true);
    this.add(parentFragment);

    final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", "name",
            new PropertyModel<String>(groupTO, "key"));

    final WebMarkupContainer jexlHelp = JexlHelpUtils.getJexlHelpWebContainer("jexlHelp");

    final AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtils.getAjaxLink(jexlHelp, "questionMarkJexlHelp");
    this.add(questionMarkJexlHelp);
    questionMarkJexlHelp.add(jexlHelp);

    if (!templateMode) {
        name.addRequiredLabel();
        questionMarkJexlHelp.setVisible(false);
    }
    this.add(name);

    userOwnerModel = new OwnerModel(groupTO, AttributableType.USER);
    @SuppressWarnings("unchecked")
    final AjaxTextFieldPanel userOwner = new AjaxTextFieldPanel("userOwner", "userOwner", userOwnerModel);
    userOwner.setReadOnly(true);
    userOwner.setOutputMarkupId(true);
    ownerContainer.add(userOwner);
    final AjaxLink<Void> userOwnerSelect = new IndicatingAjaxLink<Void>("userOwnerSelect") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            userOwnerSelectWin.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    return new UserOwnerSelectModalPage(getPage().getPageReference(), userOwnerSelectWin);
                }
            });
            userOwnerSelectWin.show(target);
        }
    };
    ownerContainer.add(userOwnerSelect);
    final IndicatingAjaxLink<Void> userOwnerReset = new IndicatingAjaxLink<Void>("userOwnerReset") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            userOwnerModel.setObject(null);
            target.add(userOwner);
        }
    };
    ownerContainer.add(userOwnerReset);

    groupOwnerModel = new OwnerModel(groupTO, AttributableType.GROUP);
    @SuppressWarnings("unchecked")
    final AjaxTextFieldPanel groupOwner = new AjaxTextFieldPanel("groupOwner", "groupOwner", groupOwnerModel);
    groupOwner.setReadOnly(true);
    groupOwner.setOutputMarkupId(true);
    ownerContainer.add(groupOwner);
    final AjaxLink<Void> groupOwnerSelect = new IndicatingAjaxLink<Void>("groupOwnerSelect") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            parentSelectWin.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    return new GroupSelectModalPage(getPage().getPageReference(), parentSelectWin,
                            GroupOwnerSelectPayload.class);
                }
            });
            parentSelectWin.show(target);
        }
    };
    ownerContainer.add(groupOwnerSelect);
    final IndicatingAjaxLink<Void> groupOwnerReset = new IndicatingAjaxLink<Void>("groupOwnerReset") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            groupOwnerModel.setObject(null);
            target.add(groupOwner);
        }
    };
    ownerContainer.add(groupOwnerReset);

    final AjaxCheckBoxPanel inhOwner = new AjaxCheckBoxPanel("inheritOwner", "inheritOwner",
            new PropertyModel<Boolean>(groupTO, "inheritOwner"));
    this.add(inhOwner);

    final AjaxCheckBoxPanel inhTemplates = new AjaxCheckBoxPanel("inheritTemplates", "inheritTemplates",
            new PropertyModel<Boolean>(groupTO, "inheritTemplates"));
    inhTemplates.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            send(getPage(), Broadcast.BREADTH, new GroupAttrTemplatesChange(Type.gPlainAttrTemplates, target));
            send(getPage(), Broadcast.BREADTH, new GroupAttrTemplatesChange(Type.gDerAttrTemplates, target));
            send(getPage(), Broadcast.BREADTH, new GroupAttrTemplatesChange(Type.gVirAttrTemplates, target));
        }
    });
    this.add(inhTemplates);
}

From source file:org.apache.syncope.client.console.panels.GroupTabPanel.java

License:Apache License

@SuppressWarnings({ "unchecked", "rawtypes" })
public GroupTabPanel(final String id, final GroupTO selectedNode, final ModalWindow window,
        final PageReference pageRef) {

    super(id);/*from  w w  w  .  jav a 2  s .com*/

    this.add(new Label("displayName", selectedNode.getDisplayName()));

    final ActionLinksPanel links = new ActionLinksPanel("actionLinks", new Model(), pageRef);
    links.setOutputMarkupId(true);
    this.add(links);
    links.addWithRoles(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() {
                    GroupTO groupTO = new GroupTO();
                    groupTO.setParent(selectedNode.getKey());
                    return new GroupModalPage(pageRef, window, groupTO);
                }
            });

            window.show(target);
        }
    }, ActionLink.ActionType.CREATE, xmlRolesReader.getEntitlement("Groups", "create"));
    links.addWithRoles(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 StatusModalPage<GroupTO>(pageRef, window,
                            groupRestClient.read(selectedNode.getKey()));
                }
            });

            window.show(target);
        }
    }, ActionLink.ActionType.MANAGE_RESOURCES, xmlRolesReader.getEntitlement("Groups", "update"));
    links.addWithRoles(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() {
                    GroupTO groupTO = groupRestClient.read(selectedNode.getKey());
                    return new GroupModalPage(pageRef, window, groupTO);
                }
            });

            window.show(target);
        }
    }, ActionLink.ActionType.EDIT, xmlRolesReader.getEntitlement("Groups", "update"));
    links.addWithRoles(new ActionLink() {

        private static final long serialVersionUID = -3722207913631435501L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            try {
                final GroupTO groupTO = groupRestClient.delete(selectedNode.getETagValue(),
                        selectedNode.getKey());

                ((Groups) pageRef.getPage()).setModalResult(true);

                window.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = -7834632442532690940L;

                    @Override
                    public Page createPage() {
                        return new ResultStatusModalPage.Builder(window, groupTO).build();
                    }
                });

                window.show(target);
            } catch (SyncopeClientException e) {
                error(getString(Constants.OPERATION_ERROR) + ": " + e.getMessage());
                ((Groups) pageRef.getPage()).getFeedbackPanel().refresh(target);
            }
        }
    }, ActionLink.ActionType.DELETE, xmlRolesReader.getEntitlement("Groups", "delete"));

    final Form form = new Form("groupForm");
    form.setModel(new CompoundPropertyModel(selectedNode));
    form.setOutputMarkupId(true);

    final GroupPanel groupPanel = new GroupPanel.Builder("groupPanel").form(form).groupTO(selectedNode)
            .groupModalPageMode(Mode.ADMIN).build();
    groupPanel.setEnabled(false);
    form.add(groupPanel);

    final WebMarkupContainer userListContainer = new WebMarkupContainer("userListContainer");

    userListContainer.setOutputMarkupId(true);
    userListContainer.setEnabled(true);
    userListContainer.add(new UserSearchResultPanel("userList", true, null, pageRef, userRestClient));
    userListContainer.add(new ClearIndicatingAjaxButton("search", new ResourceModel("search"), pageRef) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
            userListContainer.replace(new UserSearchResultPanel("userList", true,
                    SyncopeClient.getUserSearchConditionBuilder().inGroups(selectedNode.getKey()).query(),
                    pageRef, userRestClient));

            target.add(userListContainer);
        }
    });

    form.add(userListContainer);
    add(form);
}

From source file:org.apache.syncope.client.console.panels.MembershipsPanel.java

License:Apache License

public MembershipsPanel(final String id, final UserTO userTO, final Mode mode, final StatusPanel statusPanel,
        final PageReference pageRef) {

    super(id);/*from ww  w .j  av a2 s .  com*/
    this.userTO = userTO;
    this.statusPanel = statusPanel;

    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 TreeGroupProvider(groupTreeBuilder, 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 GroupTO groupTO = (GroupTO) 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>(groupTO.getDisplayName());
                }

                @Override
                protected void onClick(final AjaxRequestTarget target) {
                    if (groupTO.getKey() > 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.getGroupKey() == groupTO.getKey()) {
                                        return new MembershipModalPage(pageRef, membWin, membTO, mode);
                                    }
                                }
                                MembershipTO membTO = new MembershipTO();
                                membTO.setGroupKey(groupTO.getKey());
                                membTO.setGroupName(groupTO.getName());

                                return new MembershipModalPage(pageRef, membWin, membTO, mode);
                            }
                        });
                        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("groupId", new Model<Long>(membershipTO.getGroupKey())));
            item.add(new Label("groupName", new Model<String>(membershipTO.getGroupName())));

            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,
                                    mode);

                        }
                    });
                    membWin.show(target);
                }
            };
            item.add(editLink);

            AjaxLink deleteLink = new IndicatingOnConfirmAjaxLink("deleteLink", pageRef) {

                private static final long serialVersionUID = -7978723352517770644L;

                @Override
                protected void onClickInternal(final AjaxRequestTarget target) {
                    userTO.getMemberships().remove(membershipTO);
                    ((UserModalPage) getPage()).getUserTO().getMemberships().remove(membershipTO);
                    target.add(membershipsContainer);

                    GroupTO groupTO = groupTreeBuilder.findGroup(membershipTO.getGroupKey());
                    Set<String> resourcesToRemove = groupTO == null ? Collections.<String>emptySet()
                            : groupTO.getResources();
                    if (!resourcesToRemove.isEmpty()) {
                        Set<String> resourcesAssignedViaMembership = new HashSet<>();
                        for (MembershipTO membTO : userTO.getMemberships()) {
                            groupTO = groupTreeBuilder.findGroup(membTO.getGroupKey());
                            if (groupTO != null) {
                                resourcesAssignedViaMembership.addAll(groupTO.getResources());
                            }
                        }
                        resourcesToRemove.removeAll(resourcesAssignedViaMembership);
                        resourcesToRemove.removeAll(userTO.getResources());
                    }

                    StatusUtils.update(userTO, statusPanel, target, Collections.<String>emptySet(),
                            resourcesToRemove);
                }
            };
            item.add(deleteLink);
        }
    };

    membershipsContainer.add(membView);

    setWindowClosedCallback(membWin, membershipsContainer);
}

From source file:org.apache.syncope.client.console.panels.PoliciesPanel.java

License:Apache License

public PoliciesPanel(final String id, final PageReference pageRef, final PolicyType policyType) {
    super(id);/*  w w w.  j a  v a  2  s .c o  m*/
    this.pageRef = pageRef;
    this.policyType = policyType;

    // Modal window for editing user attributes
    final ModalWindow mwindow = new ModalWindow("editModalWin");
    mwindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    mwindow.setInitialHeight(MODAL_WIN_HEIGHT);
    mwindow.setInitialWidth(MODAL_WIN_WIDTH);
    mwindow.setCookieName("policy-modal");
    add(mwindow);

    // Container for user list
    final WebMarkupContainer container = new WebMarkupContainer("container");
    container.setOutputMarkupId(true);
    add(container);

    setWindowClosedCallback(mwindow, container);

    final List<IColumn<AbstractPolicyTO, String>> columns = new ArrayList<>();

    columns.add(new PropertyColumn<AbstractPolicyTO, String>(new ResourceModel("key"), "key", "key"));

    columns.add(new PropertyColumn<AbstractPolicyTO, String>(new ResourceModel("description"), "description",
            "description"));

    columns.add(new AbstractColumn<AbstractPolicyTO, String>(new ResourceModel("type")) {

        private static final long serialVersionUID = 8263694778917279290L;

        @Override
        public void populateItem(final Item<ICellPopulator<AbstractPolicyTO>> cellItem,
                final String componentId, final IModel<AbstractPolicyTO> model) {

            cellItem.add(new Label(componentId, getString(model.getObject().getType().name())));
        }
    });

    columns.add(new AbstractColumn<AbstractPolicyTO, String>(new ResourceModel("actions", "")) {

        private static final long serialVersionUID = 2054811145491901166L;

        @Override
        public String getCssClass() {
            return "action";
        }

        @Override
        public void populateItem(final Item<ICellPopulator<AbstractPolicyTO>> cellItem,
                final String componentId, final IModel<AbstractPolicyTO> model) {

            final AbstractPolicyTO policyTO = model.getObject();

            final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, pageRef);

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

                @Override
                public void onClick(final AjaxRequestTarget target) {

                    mwindow.setPageCreator(new ModalWindow.PageCreator() {

                        private static final long serialVersionUID = -7834632442532690940L;

                        @SuppressWarnings({ "unchecked", "rawtypes" })
                        @Override
                        public Page createPage() {
                            return new PolicyModalPage(pageRef, mwindow, policyTO);
                        }
                    });

                    mwindow.show(target);
                }
            }, ActionLink.ActionType.EDIT, "Policies");

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    try {
                        policyRestClient.delete(policyTO.getKey(), policyTO.getClass());
                        info(getString(Constants.OPERATION_SUCCEEDED));
                    } catch (SyncopeClientException e) {
                        error(getString(Constants.OPERATION_ERROR));

                        LOG.error("While deleting policy {}({})", policyTO.getKey(), policyTO.getDescription(),
                                e);
                    }

                    target.add(container);
                    ((NotificationPanel) getPage().get(Constants.FEEDBACK)).refresh(target);
                }
            }, ActionLink.ActionType.DELETE, "Policies");

            cellItem.add(panel);
        }
    });

    @SuppressWarnings({ "unchecked", "rawtypes" })
    final AjaxFallbackDefaultDataTable table = new AjaxFallbackDefaultDataTable("datatable", columns,
            new PolicyDataProvider(), paginatorRows);

    container.add(table);

    final AjaxLink<Void> createButton = new ClearIndicatingAjaxLink<Void>("createLink", pageRef) {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        protected void onClickInternal(final AjaxRequestTarget target) {
            mwindow.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

                @SuppressWarnings({ "unchecked", "rawtypes" })
                @Override
                public Page createPage() {
                    return new PolicyModalPage(pageRef, mwindow, getPolicyTOInstance(policyType));
                }
            });

            mwindow.show(target);
        }
    };

    add(createButton);

    MetaDataRoleAuthorizationStrategy.authorize(createButton, ENABLE,
            xmlRolesReader.getEntitlement("Policies", "create"));

    @SuppressWarnings("rawtypes")
    final Form paginatorForm = new Form("PaginatorForm");

    @SuppressWarnings({ "unchecked", "rawtypes" })
    final DropDownChoice rowsChooser = new DropDownChoice("rowsChooser",
            new PropertyModel(this, "paginatorRows"), prefMan.getPaginatorChoices());

    rowsChooser.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            prefMan.set(getWebRequest(), (WebResponse) getResponse(), Constants.PREF_POLICY_PAGINATOR_ROWS,
                    String.valueOf(paginatorRows));
            table.setItemsPerPage(paginatorRows);

            target.add(container);
        }
    });

    paginatorForm.add(rowsChooser);
    add(paginatorForm);
}

From source file:org.apache.syncope.client.console.panels.RoleDetailsPanel.java

License:Apache License

public RoleDetailsPanel(final String id, final RoleTO roleTO, final boolean templateMode) {
    super(id);//from  w  ww.  j av a2 s  . com

    ownerContainer = new WebMarkupContainer("ownerContainer");
    ownerContainer.setOutputMarkupId(true);
    this.add(ownerContainer);

    final ModalWindow userOwnerSelectWin = new ModalWindow("userOwnerSelectWin");
    userOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    userOwnerSelectWin.setCookieName("create-userOwnerSelect-modal");
    this.add(userOwnerSelectWin);
    final ModalWindow roleOwnerSelectWin = new ModalWindow("roleOwnerSelectWin");
    roleOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    roleOwnerSelectWin.setCookieName("create-roleOwnerSelect-modal");
    this.add(roleOwnerSelectWin);
    final ModalWindow parentSelectWin = new ModalWindow("parentSelectWin");
    parentSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    parentSelectWin.setCookieName("create-parentSelect-modal");
    this.add(parentSelectWin);

    if (templateMode) {
        parentFragment = new Fragment("parent", "parentFragment", this);

        parentModel = new ParentModel(roleTO);
        @SuppressWarnings("unchecked")
        final AjaxTextFieldPanel parent = new AjaxTextFieldPanel("parent", "parent", parentModel);
        parent.setReadOnly(true);
        parent.setOutputMarkupId(true);
        parentFragment.add(parent);
        final AjaxLink<Void> parentSelect = new IndicatingAjaxLink<Void>("parentSelect") {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                parentSelectWin.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = -7834632442532690940L;

                    @Override
                    public Page createPage() {
                        return new RoleSelectModalPage(getPage().getPageReference(), parentSelectWin,
                                ParentSelectPayload.class);
                    }
                });
                parentSelectWin.show(target);
            }
        };
        parentFragment.add(parentSelect);
        final IndicatingAjaxLink<Void> parentReset = new IndicatingAjaxLink<Void>("parentReset") {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                parentModel.setObject(null);
                target.add(parent);
            }
        };
        parentFragment.add(parentReset);
    } else {
        parentFragment = new Fragment("parent", "emptyFragment", this);
    }
    parentFragment.setOutputMarkupId(true);
    this.add(parentFragment);

    final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", "name",
            new PropertyModel<String>(roleTO, "key"));

    final WebMarkupContainer jexlHelp = JexlHelpUtil.getJexlHelpWebContainer("jexlHelp");

    final AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtil.getAjaxLink(jexlHelp, "questionMarkJexlHelp");
    this.add(questionMarkJexlHelp);
    questionMarkJexlHelp.add(jexlHelp);

    if (!templateMode) {
        name.addRequiredLabel();
        questionMarkJexlHelp.setVisible(false);
    }
    this.add(name);

    userOwnerModel = new OwnerModel(roleTO, AttributableType.USER);
    @SuppressWarnings("unchecked")
    final AjaxTextFieldPanel userOwner = new AjaxTextFieldPanel("userOwner", "userOwner", userOwnerModel);
    userOwner.setReadOnly(true);
    userOwner.setOutputMarkupId(true);
    ownerContainer.add(userOwner);
    final AjaxLink<Void> userOwnerSelect = new IndicatingAjaxLink<Void>("userOwnerSelect") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            userOwnerSelectWin.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    return new UserOwnerSelectModalPage(getPage().getPageReference(), userOwnerSelectWin);
                }
            });
            userOwnerSelectWin.show(target);
        }
    };
    ownerContainer.add(userOwnerSelect);
    final IndicatingAjaxLink<Void> userOwnerReset = new IndicatingAjaxLink<Void>("userOwnerReset") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            userOwnerModel.setObject(null);
            target.add(userOwner);
        }
    };
    ownerContainer.add(userOwnerReset);

    roleOwnerModel = new OwnerModel(roleTO, AttributableType.ROLE);
    @SuppressWarnings("unchecked")
    final AjaxTextFieldPanel roleOwner = new AjaxTextFieldPanel("roleOwner", "roleOwner", roleOwnerModel);
    roleOwner.setReadOnly(true);
    roleOwner.setOutputMarkupId(true);
    ownerContainer.add(roleOwner);
    final AjaxLink<Void> roleOwnerSelect = new IndicatingAjaxLink<Void>("roleOwnerSelect") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            parentSelectWin.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    return new RoleSelectModalPage(getPage().getPageReference(), parentSelectWin,
                            RoleOwnerSelectPayload.class);
                }
            });
            parentSelectWin.show(target);
        }
    };
    ownerContainer.add(roleOwnerSelect);
    final IndicatingAjaxLink<Void> roleOwnerReset = new IndicatingAjaxLink<Void>("roleOwnerReset") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            roleOwnerModel.setObject(null);
            target.add(roleOwner);
        }
    };
    ownerContainer.add(roleOwnerReset);

    final AjaxCheckBoxPanel inhOwner = new AjaxCheckBoxPanel("inheritOwner", "inheritOwner",
            new PropertyModel<Boolean>(roleTO, "inheritOwner"));
    this.add(inhOwner);

    final AjaxCheckBoxPanel inhTemplates = new AjaxCheckBoxPanel("inheritTemplates", "inheritTemplates",
            new PropertyModel<Boolean>(roleTO, "inheritTemplates"));
    inhTemplates.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(Type.rPlainAttrTemplates, target));
            send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(Type.rDerAttrTemplates, target));
            send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(Type.rVirAttrTemplates, target));
        }
    });
    this.add(inhTemplates);
}

From source file:org.apache.syncope.client.console.panels.RoleTabPanel.java

License:Apache License

@SuppressWarnings({ "unchecked", "rawtypes" })
public RoleTabPanel(final String id, final RoleTO selectedNode, final ModalWindow window,
        final PageReference pageRef) {

    super(id);/*from   w w w. j a v  a2 s .co m*/

    this.add(new Label("displayName", selectedNode.getDisplayName()));

    final ActionLinksPanel links = new ActionLinksPanel("actionLinks", new Model(), pageRef);
    links.setOutputMarkupId(true);
    this.add(links);
    links.addWithRoles(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() {
                    RoleTO roleTO = new RoleTO();
                    roleTO.setParent(selectedNode.getKey());
                    return new RoleModalPage(pageRef, window, roleTO);
                }
            });

            window.show(target);
        }
    }, ActionLink.ActionType.CREATE, xmlRolesReader.getEntitlement("Roles", "create"));
    links.addWithRoles(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 StatusModalPage<RoleTO>(pageRef, window,
                            roleRestClient.read(selectedNode.getKey()));
                }
            });

            window.show(target);
        }
    }, ActionLink.ActionType.MANAGE_RESOURCES, xmlRolesReader.getEntitlement("Roles", "update"));
    links.addWithRoles(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() {
                    RoleTO roleTO = roleRestClient.read(selectedNode.getKey());
                    return new RoleModalPage(pageRef, window, roleTO);
                }
            });

            window.show(target);
        }
    }, ActionLink.ActionType.EDIT, xmlRolesReader.getEntitlement("Roles", "update"));
    links.addWithRoles(new ActionLink() {

        private static final long serialVersionUID = -3722207913631435501L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            try {
                final RoleTO roleTO = roleRestClient.delete(selectedNode.getETagValue(), selectedNode.getKey());

                ((Roles) pageRef.getPage()).setModalResult(true);

                window.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = -7834632442532690940L;

                    @Override
                    public Page createPage() {
                        return new ResultStatusModalPage.Builder(window, roleTO).build();
                    }
                });

                window.show(target);
            } catch (SyncopeClientException e) {
                error(getString(Constants.OPERATION_ERROR) + ": " + e.getMessage());
                ((Roles) pageRef.getPage()).getFeedbackPanel().refresh(target);
            }
        }
    }, ActionLink.ActionType.DELETE, xmlRolesReader.getEntitlement("Roles", "delete"));

    final Form form = new Form("roleForm");
    form.setModel(new CompoundPropertyModel(selectedNode));
    form.setOutputMarkupId(true);

    final RolePanel rolePanel = new RolePanel.Builder("rolePanel").form(form).roleTO(selectedNode)
            .roleModalPageMode(Mode.ADMIN).build();
    rolePanel.setEnabled(false);
    form.add(rolePanel);

    final WebMarkupContainer userListContainer = new WebMarkupContainer("userListContainer");

    userListContainer.setOutputMarkupId(true);
    userListContainer.setEnabled(true);
    userListContainer.add(new UserSearchResultPanel("userList", true, null, pageRef, userRestClient));
    userListContainer.add(new ClearIndicatingAjaxButton("search", new ResourceModel("search"), pageRef) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
            userListContainer.replace(new UserSearchResultPanel("userList", true,
                    SyncopeClient.getUserSearchConditionBuilder().hasRoles(selectedNode.getKey()).query(),
                    pageRef, userRestClient));

            target.add(userListContainer);
        }
    });

    form.add(userListContainer);
    add(form);
}

From source file:org.apache.syncope.client.console.SyncopeApplication.java

License:Apache License

public void setupNavigationPanel(final WebPage page, final XMLRolesReader xmlRolesReader,
        final boolean notsel) {
    final ModalWindow infoModal = new ModalWindow("infoModal");
    page.add(infoModal);/*from   www. j  a va2  s  .  c o  m*/
    infoModal.setInitialWidth(350);
    infoModal.setInitialHeight(300);
    infoModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    infoModal.setCookieName("infoModal");
    infoModal.setPageCreator(new ModalWindow.PageCreator() {

        private static final long serialVersionUID = -7834632442532690940L;

        @Override
        public Page createPage() {
            return new InfoModalPage();
        }
    });

    final AjaxLink<Page> infoLink = new AjaxLink<Page>("infoLink") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            infoModal.show(target);
        }
    };
    page.add(infoLink);

    BookmarkablePageLink<Page> schemaLink = new BookmarkablePageLink<>("schema", Schema.class);
    MetaDataRoleAuthorizationStrategy.authorize(schemaLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Schema", "list"));
    page.add(schemaLink);
    schemaLink.add(new Image("schemaIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "schema" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> usersLink = new BookmarkablePageLink<>("users", Users.class);
    MetaDataRoleAuthorizationStrategy.authorize(usersLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Users", "list"));
    page.add(usersLink);
    usersLink.add(new Image("usersIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "users" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> groupsLink = new BookmarkablePageLink<>("groups", Groups.class);
    MetaDataRoleAuthorizationStrategy.authorize(groupsLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Groups", "list"));
    page.add(groupsLink);
    groupsLink.add(new Image("groupsIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "groups" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> resourcesLink = new BookmarkablePageLink<>("resources", Resources.class);
    MetaDataRoleAuthorizationStrategy.authorize(resourcesLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Resources", "list"));
    page.add(resourcesLink);
    resourcesLink.add(new Image("resourcesIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "resources" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> todoLink = new BookmarkablePageLink<>("todo", Todo.class);
    MetaDataRoleAuthorizationStrategy.authorize(todoLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Approval", "list"));
    page.add(todoLink);
    todoLink.add(new Image("todoIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "todo" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> reportLink = new BookmarkablePageLink<>("reports", Reports.class);
    MetaDataRoleAuthorizationStrategy.authorize(reportLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Reports", "list"));
    page.add(reportLink);
    reportLink.add(new Image("reportsIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "reports" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> configurationLink = new BookmarkablePageLink<>("configuration",
            Configuration.class);
    MetaDataRoleAuthorizationStrategy.authorize(configurationLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Configuration", "list"));
    page.add(configurationLink);
    configurationLink.add(new Image("configurationIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "configuration" + Constants.PNG_EXT)));

    BookmarkablePageLink<Page> taskLink = new BookmarkablePageLink<>("tasks", Tasks.class);
    MetaDataRoleAuthorizationStrategy.authorize(taskLink, WebPage.ENABLE,
            xmlRolesReader.getEntitlement("Tasks", "list"));
    page.add(taskLink);
    taskLink.add(new Image("tasksIcon", new ContextRelativeResource(
            IMG_PREFIX + (notsel ? IMG_NOTSEL : StringUtils.EMPTY) + "tasks" + Constants.PNG_EXT)));

    page.add(new BookmarkablePageLink<Page>("logout", Logout.class));
}

From source file:org.apache.syncope.client.console.SyncopeApplication.java

License:Apache License

public void setupEditProfileModal(final WebPage page, final UserSelfRestClient userSelfRestClient) {
    // Modal window for editing user profile
    final ModalWindow editProfileModalWin = new ModalWindow("editProfileModal");
    editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editProfileModalWin.setInitialHeight(EDIT_PROFILE_WIN_HEIGHT);
    editProfileModalWin.setInitialWidth(EDIT_PROFILE_WIN_WIDTH);
    editProfileModalWin.setCookieName("edit-profile-modal");
    page.add(editProfileModalWin);/*w w w . j  a  va  2 s.  c  o  m*/

    final AjaxLink<Page> editProfileLink = new AjaxLink<Page>("editProfileLink") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            final UserTO userTO;
            if (SyncopeSession.get().isAuthenticated()) {
                try {
                    userTO = userSelfRestClient.read();
                } catch (Exception e) {
                    throw new WicketRuntimeException(e);
                }
            } else {
                userTO = new UserTO();
            }

            editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    return new UserSelfModalPage(page.getPageReference(), editProfileModalWin, userTO);
                }
            });

            editProfileModalWin.show(target);
        }
    };

    editProfileLink.add(new Label("username", SyncopeSession.get().getUsername()));

    if ("admin".equals(SyncopeSession.get().getUsername())) {
        editProfileLink.setEnabled(false);
    }

    page.add(editProfileLink);
}

From source file:org.apache.syncope.console.pages.Login.java

License:Apache License

public Login(final PageParameters parameters) {
    super(parameters);

    feedbackPanel = new NotificationPanel(Constants.FEEDBACK);
    add(feedbackPanel);/*from  w  w  w. ja va  2  s.c  o m*/

    form = new Form<Void>("login");

    userIdField = new TextField<String>("userId", new Model<String>());
    userIdField.setMarkupId("userId");
    form.add(userIdField);

    passwordField = new PasswordTextField("password", new Model<String>());
    passwordField.setMarkupId("password");
    form.add(passwordField);

    languageSelect = new LocaleDropDown("language");

    form.add(languageSelect);

    AjaxButton submitButton = new AjaxButton("submit", new Model<String>(getString("submit"))) {

        private static final long serialVersionUID = 429178684321093953L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            try {
                if (anonymousUser.equals(userIdField.getRawInput())) {
                    throw new AccessControlException("Illegal username");
                }

                authenticate(userIdField.getRawInput(), passwordField.getRawInput());

                setResponsePage(WelcomePage.class, parameters);
            } catch (AccessControlException e) {
                error(getString("login-error"));
                feedbackPanel.refresh(target);
                SyncopeSession.get().resetClients();
            }
        }
    };

    submitButton.setDefaultFormProcessing(false);
    form.add(submitButton);

    add(form);

    // Modal window for self registration
    final ModalWindow editProfileModalWin = new ModalWindow("selfRegModal");
    editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editProfileModalWin.setInitialHeight(SELF_REG_WIN_HEIGHT);
    editProfileModalWin.setInitialWidth(SELF_REG_WIN_WIDTH);
    editProfileModalWin.setCookieName("self-reg-modal");
    add(editProfileModalWin);

    Fragment selfRegFrag;
    if (userSelfRestClient.isSelfRegistrationAllowed()) {
        selfRegFrag = new Fragment("selfRegistration", "selfRegAllowed", this);

        final AjaxLink<Void> selfRegLink = new ClearIndicatingAjaxLink<Void>("link", getPageReference()) {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            protected void onClickInternal(final AjaxRequestTarget target) {
                editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = -7834632442532690940L;

                    @Override
                    public Page createPage() {
                        // anonymous authentication needed for self-registration
                        authenticate(anonymousUser, anonymousKey);

                        return new UserSelfModalPage(Login.this.getPageReference(), editProfileModalWin,
                                new UserTO());
                    }
                });

                editProfileModalWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {

                    private static final long serialVersionUID = 251794406325329768L;

                    @Override
                    public void onClose(final AjaxRequestTarget target) {
                        SyncopeSession.get().invalidate();
                    }
                });

                editProfileModalWin.show(target);
            }
        };
        selfRegLink.add(new Label("linkTitle", getString("selfRegistration")));

        Panel panel = new LinkPanel("selfRegistration", new ResourceModel("selfRegistration"));
        panel.add(selfRegLink);
        selfRegFrag.add(panel);
    } else {
        selfRegFrag = new Fragment("selfRegistration", "selfRegNotAllowed", this);
    }
    add(selfRegFrag);
}

From source file:org.apache.syncope.console.pages.panels.AjaxDataTablePanel.java

License:Apache License

public AjaxDataTablePanel(final String id, final List<IColumn<T, S>> columns,
        final ISortableDataProvider<T, S> dataProvider, final int rowsPerPage,
        final Collection<ActionLink.ActionType> actions, final BaseRestClient bulkActionExecutor,
        final String itemIdField, final String pageId, final PageReference pageRef) {

    super(id);/*from  w  w w.j  a  v  a 2  s  .co  m*/

    final ModalWindow bulkModalWin = new ModalWindow("bulkModal");
    bulkModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    bulkModalWin.setInitialHeight(600);
    bulkModalWin.setInitialWidth(900);
    bulkModalWin.setCookieName("bulk-modal");
    add(bulkModalWin);

    bulkModalWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {

        private static final long serialVersionUID = 8804221891699487149L;

        @Override
        public void onClose(final AjaxRequestTarget target) {
            final EventDataWrapper data = new EventDataWrapper();
            data.setTarget(target);
            data.setRows(rowsPerPage);

            send(pageRef.getPage(), Broadcast.BREADTH, data);

            final AbstractBasePage page = (AbstractBasePage) pageRef.getPage();

            if (page.isModalResult()) {
                // reset modal result
                page.setModalResult(false);
                // set operation succeeded
                getSession().info(getString(Constants.OPERATION_SUCCEEDED));
                // refresh feedback panel
                target.add(page.getFeedbackPanel());
            }
        }
    });

    Fragment fragment = new Fragment("tablePanel", "bulkAvailable", this);
    add(fragment);

    Form<T> bulkActionForm = new Form<T>("groupForm");
    fragment.add(bulkActionForm);

    group = new CheckGroup<T>("checkgroup", model);
    group.add(new AjaxFormChoiceComponentUpdatingBehavior() {

        private static final long serialVersionUID = -151291731388673682L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            // triggers AJAX form submit
        }
    });
    bulkActionForm.add(group);

    columns.add(0, new CheckGroupColumn<T, S>(group));
    dataTable = new AjaxFallbackDefaultDataTable<T, S>("dataTable", columns, dataProvider, rowsPerPage);
    group.add(dataTable);

    fragment.add(new ClearIndicatingAjaxButton("bulkActionLink", bulkActionForm, pageRef) {

        private static final long serialVersionUID = 382302811235019988L;

        @Override
        protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
            bulkModalWin.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690941L;

                @Override
                public Page createPage() {
                    return new BulkActionModalPage<T, S>(bulkModalWin, group.getModelObject(), columns, actions,
                            bulkActionExecutor, itemIdField, pageId);
                }
            });

            bulkModalWin.show(target);
        }
    });
}