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

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

Introduction

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

Prototype

public ModalWindow setCssClassName(final String cssClassName) 

Source Link

Document

Sets the CSS class name for this window.

Usage

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

License:Apache License

@SuppressWarnings({ "unchecked", "rawtypes" })
private void setupExecutions() {
    final WebMarkupContainer executions = new WebMarkupContainer("executionContainer");
    executions.setOutputMarkupId(true);//from   w  w  w . j a  va  2 s.c  o  m
    form.add(executions);

    final ModalWindow reportExecMessageWin = new ModalWindow("reportExecMessageWin");
    reportExecMessageWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    reportExecMessageWin.setCookieName("report-exec-message-win-modal");
    add(reportExecMessageWin);

    final ModalWindow reportExecExportWin = new ModalWindow("reportExecExportWin");
    reportExecExportWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    reportExecExportWin.setCookieName("report-exec-export-win-modal");
    reportExecExportWin.setInitialHeight(EXEC_EXPORT_WIN_HEIGHT);
    reportExecExportWin.setInitialWidth(EXEC_EXPORT_WIN_WIDTH);
    reportExecExportWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {

        private static final long serialVersionUID = 8804221891699487139L;

        @Override
        public void onClose(final AjaxRequestTarget target) {
            AjaxExportDownloadBehavior behavior = new AjaxExportDownloadBehavior(
                    ReportModalPage.this.exportFormat, ReportModalPage.this.exportExecId);
            executions.add(behavior);
            behavior.initiate(target);
        }
    });
    add(reportExecExportWin);

    final List<IColumn> columns = new ArrayList<IColumn>();
    columns.add(new PropertyColumn(new ResourceModel("key"), "key", "key"));
    columns.add(new DatePropertyColumn(new ResourceModel("startDate"), "startDate", "startDate"));
    columns.add(new DatePropertyColumn(new ResourceModel("endDate"), "endDate", "endDate"));
    columns.add(new PropertyColumn(new ResourceModel("status"), "status", "status"));
    columns.add(new ActionColumn<ReportExecTO, String>(new ResourceModel("actions", "")) {

        private static final long serialVersionUID = 2054811145491901166L;

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

            final ReportExecTO 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) {
                    reportExecMessageWin.setPageCreator(new ModalWindow.PageCreator() {

                        private static final long serialVersionUID = -7834632442532690940L;

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

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

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

                        private static final long serialVersionUID = -7834632442532690940L;

                        @Override
                        public Page createPage() {
                            ReportModalPage.this.exportExecId = model.getObject().getKey();
                            return new ReportExecResultDownloadModalPage(reportExecExportWin,
                                    ReportModalPage.this.getPageReference());
                        }
                    });
                    reportExecExportWin.show(target);
                }
            }, ActionLink.ActionType.EXPORT, "Reports",
                    ReportExecStatus.SUCCESS.name().equals(model.getObject().getStatus()));

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

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

                        reportTO.getExecutions().remove(taskExecutionTO);

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

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

            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 ReportTO currentReportTO = reportTO.getKey() == 0 ? reportTO
                                : reportRestClient.read(reportTO.getKey());
                        reportTO.getExecutions().clear();
                        reportTO.getExecutions().addAll(currentReportTO.getExecutions());
                        final AjaxFallbackDefaultDataTable currentTable = new AjaxFallbackDefaultDataTable(
                                "executionsTable", columns, new ReportExecutionsProvider(reportTO), 10);
                        currentTable.setOutputMarkupId(true);
                        target.add(currentTable);
                        executions.addOrReplace(currentTable);
                    }
                }
            }, ActionLink.ActionType.RELOAD, TASKS, "list");

            return panel;
        }
    });

    final AjaxFallbackDefaultDataTable table = new AjaxFallbackDefaultDataTable("executionsTable", columns,
            new ReportExecutionsProvider(reportTO), 10);
    executions.add(table);
}

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

License:Apache License

private ResultStatusModalPage(final Builder builder) {
    super();//from   w w w. ja  v  a2  s.  c  o m
    this.subject = builder.subject;
    statusUtils = new StatusUtils(this.userRestClient);
    if (builder.mode == null) {
        this.mode = Mode.ADMIN;
    } else {
        this.mode = builder.mode;
    }

    final BaseModalPage page = this;

    final WebMarkupContainer container = new WebMarkupContainer("container");
    container.setOutputMarkupId(true);
    add(container);

    final Fragment fragment = new Fragment("resultFrag",
            mode == Mode.SELF ? "userSelfResultFrag" : "propagationResultFrag", this);
    fragment.setOutputMarkupId(true);
    container.add(fragment);

    if (mode == Mode.ADMIN) {
        // add Syncope propagation status
        PropagationStatus syncope = new PropagationStatus();
        syncope.setResource("Syncope");
        syncope.setStatus(PropagationTaskExecStatus.SUCCESS);

        List<PropagationStatus> propagations = new ArrayList<PropagationStatus>();
        propagations.add(syncope);
        propagations.addAll(subject.getPropagationStatusTOs());

        fragment.add(new Label("info",
                ((subject instanceof UserTO) && ((UserTO) subject).getUsername() != null)
                        ? ((UserTO) subject).getUsername()
                        : ((subject instanceof GroupTO) && ((GroupTO) subject).getName() != null)
                                ? ((GroupTO) subject).getName()
                                : String.valueOf(subject.getKey())));

        final ListView<PropagationStatus> propRes = new ListView<PropagationStatus>("resources", propagations) {

            private static final long serialVersionUID = -1020475259727720708L;

            @Override
            protected void populateItem(final ListItem<PropagationStatus> item) {
                final PropagationStatus propTO = (PropagationStatus) item.getDefaultModelObject();

                final ListView attributes = getConnObjectView(propTO);

                final Fragment attrhead;
                if (attributes.getModelObject() == null || attributes.getModelObject().isEmpty()) {
                    attrhead = new Fragment("attrhead", "emptyAttrHeadFrag", page);
                } else {
                    attrhead = new Fragment("attrhead", "attrHeadFrag", page);
                }

                item.add(attrhead);
                item.add(attributes);

                attrhead.add(new Label("resource", propTO.getResource()));

                attrhead.add(new Label("propagation",
                        propTO.getStatus() == null ? "UNDEFINED" : propTO.getStatus().toString()));

                final Image image;
                final String alt, title;
                final ModalWindow failureWindow = new ModalWindow("failureWindow");
                final AjaxLink<?> failureWindowLink = new AjaxLink<Void>("showFailureWindow") {

                    private static final long serialVersionUID = -7978723352517770644L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        failureWindow.show(target);
                    }
                };

                switch (propTO.getStatus()) {

                case SUCCESS:
                case SUBMITTED:
                case CREATED:
                    image = new Image("icon", new ContextRelativeResource(
                            IMG_PREFIX + Status.ACTIVE.toString() + Constants.PNG_EXT));
                    alt = "success icon";
                    title = "success";
                    failureWindow.setVisible(false);
                    failureWindowLink.setEnabled(false);
                    break;

                default:
                    image = new Image("icon", new ContextRelativeResource(
                            IMG_PREFIX + Status.SUSPENDED.toString() + Constants.PNG_EXT));
                    alt = "failure icon";
                    title = "failure";
                }

                image.add(new Behavior() {

                    private static final long serialVersionUID = 1469628524240283489L;

                    @Override
                    public void onComponentTag(final Component component, final ComponentTag tag) {
                        tag.put("alt", alt);
                        tag.put("title", title);
                    }
                });
                final FailureMessageModalPage executionFailureMessagePage;
                if (propTO.getFailureReason() == null) {
                    executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(),
                            StringUtils.EMPTY);
                } else {
                    executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(),
                            propTO.getFailureReason());
                }

                failureWindow.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = -7834632442532690940L;

                    @Override
                    public Page createPage() {
                        return executionFailureMessagePage;
                    }
                });
                failureWindow.setCookieName("failureWindow");
                failureWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
                failureWindowLink.add(image);
                attrhead.add(failureWindowLink);
                attrhead.add(failureWindow);
            }
        };
        fragment.add(propRes);
    }

    final AjaxLink<Void> close = new IndicatingAjaxLink<Void>("close") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            builder.window.close(target);
        }
    };
    container.add(close);

    setOutputMarkupId(true);
}

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 ww .j  av  a  2s  .  c  o 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 .j a v  a 2s  . 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);//from  w w  w .  ja va  2  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 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.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.ja  v a  2s  .  c  om
    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);/* www.ja  va  2s  .  c  om*/
    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 .jav  a  2s .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.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);//  ww w  .j  a  va2s  .  c  om
    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 .  jav a  2  s .  co 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);
}