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

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

Introduction

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

Prototype

public void show(final IPartialPageRequestHandler target) 

Source Link

Document

Shows the modal window.

Usage

From source file:org.apache.syncope.client.console.pages.Schema.java

License:Apache License

private <T extends AbstractSchemaModalPage> AjaxLink<Void> getCreateSchemaLink(final ModalWindow modalWindow,
        final AttributableType attrType, final SchemaType schemaType, final String winLinkName) {

    AjaxLink<Void> link = new ClearIndicatingAjaxLink<Void>(winLinkName, getPageReference()) {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override//from  w  ww.j  a  va  2s. c  o  m
        protected void onClickInternal(final AjaxRequestTarget target) {
            modalWindow.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    T page = SchemaModalPageFactory.getSchemaModalPage(attrType, schemaType);
                    page.setSchemaModalPage(Schema.this.getPageReference(), modalWindow, null, true);

                    return page;
                }
            });

            modalWindow.show(target);
        }
    };

    MetaDataRoleAuthorizationStrategy.authorize(link, ENABLE, allowedCreateRoles);

    return link;

}

From source file:org.apache.syncope.client.console.pages.TaskModalPage.java

License:Apache License

public TaskModalPage(final AbstractTaskTO taskTO) {
    final ModalWindow taskExecMessageWin = new ModalWindow("taskExecMessageWin");
    taskExecMessageWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    taskExecMessageWin.setCookieName("task-exec-message-win-modal");
    add(taskExecMessageWin);/*from w  w w.  ja  v a  2  s.  co  m*/

    form = new Form<>(FORM);
    form.setModel(new CompoundPropertyModel<>(taskTO));
    add(form);

    profile = new WebMarkupContainer("profile");
    profile.setOutputMarkupId(true);
    form.add(profile);

    executions = new WebMarkupContainer("executionContainer");
    executions.setOutputMarkupId(true);
    form.add(executions);

    final Label idLabel = new Label("idLabel", new ResourceModel("key"));
    profile.add(idLabel);

    final AjaxTextFieldPanel id = new AjaxTextFieldPanel("key", getString("key"),
            new PropertyModel<String>(taskTO, "key"));

    id.setEnabled(false);
    profile.add(id);

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

    final int paginatorRows = 10;

    columns.add(new PropertyColumn<TaskExecTO, String>(new ResourceModel("key"), "key", "key"));
    columns.add(new DatePropertyColumn<TaskExecTO>(new ResourceModel("startDate"), "startDate", "startDate"));
    columns.add(new DatePropertyColumn<TaskExecTO>(new ResourceModel("endDate"), "endDate", "endDate"));
    columns.add(new PropertyColumn<TaskExecTO, String>(new ResourceModel("status"), "status", "status"));
    columns.add(new ActionColumn<TaskExecTO, String>(new ResourceModel("actions", "")) {

        private static final long serialVersionUID = 2054811145491901166L;

        @Override
        public ActionLinksPanel getActions(final String componentId, final IModel<TaskExecTO> model) {

            final TaskExecTO taskExecutionTO = 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) {
                    taskExecMessageWin.setPageCreator(new ModalWindow.PageCreator() {

                        private static final long serialVersionUID = -7834632442532690940L;

                        @Override
                        public Page createPage() {
                            return new ExecMessageModalPage(model.getObject().getMessage());
                        }
                    });
                    taskExecMessageWin.show(target);
                }
            }, ActionLink.ActionType.EDIT, TASKS, StringUtils.hasText(model.getObject().getMessage()));

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    try {
                        taskRestClient.deleteExecution(taskExecutionTO.getKey());

                        taskTO.getExecutions().remove(taskExecutionTO);

                        info(getString(Constants.OPERATION_SUCCEEDED));
                    } catch (SyncopeClientException scce) {
                        error(scce.getMessage());
                    }

                    feedbackPanel.refresh(target);
                    target.add(executions);
                }
            }, ActionLink.ActionType.DELETE, TASKS);

            return panel;
        }

        @Override
        public Component getHeader(final String componentId) {
            final ActionLinksPanel panel = new ActionLinksPanel(componentId, new Model(), getPageReference());

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -7978723352517770644L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    if (target != null) {
                        final AjaxFallbackDefaultDataTable<TaskExecTO, String> currentTable = new AjaxFallbackDefaultDataTable<TaskExecTO, String>(
                                "executionsTable", columns,
                                new TaskExecutionsProvider(getCurrentTaskExecution(taskTO)), paginatorRows);
                        currentTable.setOutputMarkupId(true);
                        target.add(currentTable);
                        executions.addOrReplace(currentTable);
                    }
                }
            }, ActionLink.ActionType.RELOAD, TASKS, "list");

            return panel;
        }
    });

    final AjaxFallbackDefaultDataTable<TaskExecTO, String> table = new AjaxFallbackDefaultDataTable<TaskExecTO, String>(
            "executionsTable", columns, new TaskExecutionsProvider(getCurrentTaskExecution(taskTO)),
            paginatorRows);

    executions.add(table);
}

From source file:org.apache.syncope.client.console.pages.Users.java

License:Apache License

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

    // Modal window for editing user attributes
    final ModalWindow editModalWin = new ModalWindow("editModal");
    editModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editModalWin.setInitialHeight(EDIT_MODAL_WIN_HEIGHT);
    editModalWin.setInitialWidth(EDIT_MODAL_WIN_WIDTH);
    editModalWin.setCookieName("edit-modal");
    add(editModalWin);/*from  w w  w .  ja  v  a2  s. c om*/

    final AbstractSearchResultPanel searchResult = new UserSearchResultPanel("searchResult", true, null,
            getPageReference(), restClient);
    add(searchResult);

    final AbstractSearchResultPanel listResult = new UserSearchResultPanel("listResult", false, null,
            getPageReference(), restClient);
    add(listResult);

    // create new user
    final AjaxLink<Void> createLink = new ClearIndicatingAjaxLink<Void>("createLink", getPageReference()) {

        private static final long serialVersionUID = -7978723352517770644L;

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

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    return new EditUserModalPage(Users.this.getPageReference(), editModalWin, new UserTO());
                }
            });

            editModalWin.show(target);
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(createLink, ENABLE,
            xmlRolesReader.getEntitlement("Users", "create"));
    add(createLink);

    setWindowClosedReloadCallback(editModalWin);

    final Form<?> searchForm = new Form<>("searchForm");
    add(searchForm);

    final UserSearchPanel searchPanel = new UserSearchPanel.Builder("searchPanel").build();
    searchForm.add(searchPanel);

    final ClearIndicatingAjaxButton searchButton = new ClearIndicatingAjaxButton("search",
            new ResourceModel("search"), getPageReference()) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
            final String fiql = searchPanel.buildFIQL();
            LOG.debug("FIQL: " + fiql);

            doSearch(target, fiql, searchResult);

            Session.get().getFeedbackMessages().clear();
            searchPanel.getSearchFeedback().refresh(target);
        }

        @Override
        protected void onError(final AjaxRequestTarget target, final Form<?> form) {

            searchPanel.getSearchFeedback().refresh(target);
        }
    };

    searchForm.add(searchButton);
    searchForm.setDefaultButton(searchButton);
}

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);// ww  w  .j  a v  a  2 s. c  om

    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);//w w  w  .  j  a v  a  2s .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  w  ww . ja  va  2s  .  c o  m*/
    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);/*from   w  ww . jav  a2  s.co  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 w w . ja  v a 2 s  . 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 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 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() {
                    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   w w w . j  a v a 2  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));
}