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

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

Introduction

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

Prototype

public void close(final IPartialPageRequestHandler target) 

Source Link

Document

Closes the modal window.

Usage

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

License:Apache License

public MembershipModalPage(final PageReference pageRef, final ModalWindow window,
        final MembershipTO membershipTO, final boolean templateMode) {

    final Form<MembershipTO> form = new Form<MembershipTO>("MembershipForm");

    final UserTO userTO = ((UserModalPage) pageRef.getPage()).getUserTO();

    form.setModel(new CompoundPropertyModel<MembershipTO>(membershipTO));

    submit = new AjaxButton(SUBMIT, new ResourceModel(SUBMIT)) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override/*from  ww  w .j a  v  a 2 s .  com*/
        protected void onSubmit(final AjaxRequestTarget target, final Form form) {
            userTO.getMemberships().remove(membershipTO);
            userTO.getMemberships().add(membershipTO);

            ((UserModalPage) pageRef.getPage()).setUserTO(userTO);

            window.close(target);
        }

        @Override
        protected void onError(final AjaxRequestTarget target, final Form<?> form) {
            feedbackPanel.refresh(target);
        }
    };

    form.add(submit);
    form.setDefaultButton(submit);

    final IndicatingAjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            ((UserModalPage) pageRef.getPage()).setUserTO(userTO);
            window.close(target);
        }

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

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

    //--------------------------------
    // Attributes panel
    //--------------------------------
    form.add(new AttributesPanel("attrs", membershipTO, form, templateMode));
    form.add(new SysInfoPanel("systeminformation", membershipTO));
    //--------------------------------

    //--------------------------------
    // Derived attributes container
    //--------------------------------
    form.add(new DerivedAttributesPanel("derAttrs", membershipTO));
    //--------------------------------

    //--------------------------------
    // Virtual attributes container
    //--------------------------------
    form.add(new VirtualAttributesPanel("virAttrs", membershipTO, templateMode));
    //--------------------------------

    add(form);
}

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

License:Apache License

public NotificationModalPage(final PageReference pageRef, final ModalWindow window,
        final NotificationTO notificationTO, final boolean createFlag) {

    final Form<NotificationTO> form = new Form<NotificationTO>(FORM,
            new CompoundPropertyModel<NotificationTO>(notificationTO));

    final AjaxTextFieldPanel sender = new AjaxTextFieldPanel("sender", getString("sender"),
            new PropertyModel<String>(notificationTO, "sender"));
    sender.addRequiredLabel();// ww  w .ja  v  a 2 s.  c  om
    sender.addValidator(EmailAddressValidator.getInstance());
    form.add(sender);

    final AjaxTextFieldPanel subject = new AjaxTextFieldPanel("subject", getString("subject"),
            new PropertyModel<String>(notificationTO, "subject"));
    subject.addRequiredLabel();
    form.add(subject);

    final AjaxDropDownChoicePanel<String> template = new AjaxDropDownChoicePanel<String>("template",
            getString("template"), new PropertyModel<String>(notificationTO, "template"));
    template.setChoices(restClient.getMailTemplates());
    template.addRequiredLabel();
    form.add(template);

    final AjaxDropDownChoicePanel<TraceLevel> traceLevel = new AjaxDropDownChoicePanel<TraceLevel>("traceLevel",
            getString("traceLevel"), new PropertyModel<TraceLevel>(notificationTO, "traceLevel"));
    traceLevel.setChoices(Arrays.asList(TraceLevel.values()));
    traceLevel.addRequiredLabel();
    form.add(traceLevel);

    final AjaxCheckBoxPanel isActive = new AjaxCheckBoxPanel("isActive", getString("isActive"),
            new PropertyModel<Boolean>(notificationTO, "active"));
    if (createFlag) {
        isActive.getField().setDefaultModelObject(Boolean.TRUE);
    }
    form.add(isActive);

    final WebMarkupContainer aboutContainer = new WebMarkupContainer("aboutContainer");
    aboutContainer.setOutputMarkupId(true);

    form.add(aboutContainer);

    final AjaxCheckBoxPanel checkAbout = new AjaxCheckBoxPanel("checkAbout", "checkAbout",
            new Model<Boolean>(notificationTO.getUserAbout() == null && notificationTO.getRoleAbout() == null));
    aboutContainer.add(checkAbout);

    final AjaxCheckBoxPanel checkUserAbout = new AjaxCheckBoxPanel("checkUserAbout", "checkUserAbout",
            new Model<Boolean>(notificationTO.getUserAbout() != null));
    aboutContainer.add(checkUserAbout);

    final AjaxCheckBoxPanel checkRoleAbout = new AjaxCheckBoxPanel("checkRoleAbout", "checkRoleAbout",
            new Model<Boolean>(notificationTO.getRoleAbout() != null));
    aboutContainer.add(checkRoleAbout);

    final UserSearchPanel userAbout = new UserSearchPanel.Builder("userAbout")
            .fiql(notificationTO.getUserAbout()).build();
    aboutContainer.add(userAbout);
    userAbout.setEnabled(checkUserAbout.getModelObject());

    final RoleSearchPanel roleAbout = new RoleSearchPanel.Builder("roleAbout")
            .fiql(notificationTO.getRoleAbout()).build();
    aboutContainer.add(roleAbout);
    roleAbout.setEnabled(checkRoleAbout.getModelObject());

    checkAbout.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            if (checkAbout.getModelObject()) {
                checkUserAbout.setModelObject(Boolean.FALSE);
                checkRoleAbout.setModelObject(Boolean.FALSE);
                userAbout.setEnabled(Boolean.FALSE);
                roleAbout.setEnabled(Boolean.FALSE);
            } else {
                checkAbout.setModelObject(Boolean.TRUE);
            }
            target.add(aboutContainer);
        }
    });

    checkUserAbout.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            if (checkUserAbout.getModelObject()) {
                checkAbout.setModelObject(!checkUserAbout.getModelObject());
                checkRoleAbout.setModelObject(!checkUserAbout.getModelObject());
                roleAbout.setEnabled(Boolean.FALSE);
            } else {
                checkUserAbout.setModelObject(Boolean.TRUE);
            }
            userAbout.setEnabled(Boolean.TRUE);
            target.add(aboutContainer);
        }
    });

    checkRoleAbout.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            if (checkRoleAbout.getModelObject()) {
                checkAbout.setModelObject(Boolean.FALSE);
                checkUserAbout.setModelObject(Boolean.FALSE);
                userAbout.setEnabled(Boolean.FALSE);
            } else {
                checkRoleAbout.setModelObject(Boolean.TRUE);
            }
            roleAbout.setEnabled(Boolean.TRUE);
            target.add(aboutContainer);
        }
    });

    final AjaxDropDownChoicePanel<IntMappingType> recipientAttrType = new AjaxDropDownChoicePanel<IntMappingType>(
            "recipientAttrType", new ResourceModel("recipientAttrType", "recipientAttrType").getObject(),
            new PropertyModel<IntMappingType>(notificationTO, "recipientAttrType"));
    recipientAttrType
            .setChoices(new ArrayList<IntMappingType>(IntMappingType.getAttributeTypes(AttributableType.USER,
                    EnumSet.of(IntMappingType.UserId, IntMappingType.Password))));
    recipientAttrType.setRequired(true);
    form.add(recipientAttrType);

    final AjaxDropDownChoicePanel<String> recipientAttrName = new AjaxDropDownChoicePanel<String>(
            "recipientAttrName", new ResourceModel("recipientAttrName", "recipientAttrName").getObject(),
            new PropertyModel<String>(notificationTO, "recipientAttrName"));
    recipientAttrName.setChoices(getSchemaNames(recipientAttrType.getModelObject()));
    recipientAttrName.setRequired(true);
    form.add(recipientAttrName);

    recipientAttrType.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            recipientAttrName.setChoices(getSchemaNames(recipientAttrType.getModelObject()));
            target.add(recipientAttrName);
        }
    });

    form.add(new LoggerCategoryPanel("eventSelection", loggerRestClient.listEvents(),
            new PropertyModel<List<String>>(notificationTO, "events"), getPageReference(), "Notification") {

        private static final long serialVersionUID = 6429053774964787735L;

        @Override
        protected String[] getListRoles() {
            return new String[] {};
        }

        @Override
        protected String[] getChangeRoles() {
            return new String[] {};
        }
    });

    final WebMarkupContainer recipientsContainer = new WebMarkupContainer("recipientsContainer");
    recipientsContainer.setOutputMarkupId(true);

    form.add(recipientsContainer);

    final AjaxCheckBoxPanel checkStaticRecipients = new AjaxCheckBoxPanel("checkStaticRecipients", "recipients",
            new Model<Boolean>(!notificationTO.getStaticRecipients().isEmpty()));
    form.add(checkStaticRecipients);

    if (createFlag) {
        checkStaticRecipients.getField().setDefaultModelObject(Boolean.FALSE);
    }

    final AjaxTextFieldPanel staticRecipientsFieldPanel = new AjaxTextFieldPanel("panel", "staticRecipients",
            new Model<String>(null));
    staticRecipientsFieldPanel.addValidator(EmailAddressValidator.getInstance());
    staticRecipientsFieldPanel.setRequired(checkStaticRecipients.getModelObject());

    if (notificationTO.getStaticRecipients().isEmpty()) {
        notificationTO.getStaticRecipients().add(null);
    }

    final MultiFieldPanel<String> staticRecipients = new MultiFieldPanel<String>("staticRecipients",
            new PropertyModel<List<String>>(notificationTO, "staticRecipients"), staticRecipientsFieldPanel);
    staticRecipients.setEnabled(checkStaticRecipients.getModelObject());
    form.add(staticRecipients);

    final AjaxCheckBoxPanel checkRecipients = new AjaxCheckBoxPanel("checkRecipients", "checkRecipients",
            new Model<Boolean>(notificationTO.getRecipients() == null ? false : true));
    recipientsContainer.add(checkRecipients);

    if (createFlag) {
        checkRecipients.getField().setDefaultModelObject(Boolean.TRUE);
    }

    final UserSearchPanel recipients = new UserSearchPanel.Builder("recipients")
            .fiql(notificationTO.getRecipients()).build();

    recipients.setEnabled(checkRecipients.getModelObject());
    recipientsContainer.add(recipients);

    final AjaxCheckBoxPanel selfAsRecipient = new AjaxCheckBoxPanel("selfAsRecipient",
            getString("selfAsRecipient"), new PropertyModel<Boolean>(notificationTO, "selfAsRecipient"));
    form.add(selfAsRecipient);

    if (createFlag) {
        selfAsRecipient.getField().setDefaultModelObject(Boolean.FALSE);
    }

    selfAsRecipient.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            if (!selfAsRecipient.getModelObject() && !checkRecipients.getModelObject()
                    && !checkStaticRecipients.getModelObject()) {
                checkRecipients.getField().setDefaultModelObject(Boolean.TRUE);
                target.add(checkRecipients);
                recipients.setEnabled(checkRecipients.getModelObject());
                target.add(recipients);
                target.add(recipientsContainer);
            }
        }
    });

    checkRecipients.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            if (!checkRecipients.getModelObject() && !selfAsRecipient.getModelObject()
                    && !checkStaticRecipients.getModelObject()) {
                checkStaticRecipients.getField().setDefaultModelObject(Boolean.TRUE);
                target.add(checkStaticRecipients);
                staticRecipients.setEnabled(Boolean.TRUE);
                target.add(staticRecipients);
                staticRecipientsFieldPanel.setRequired(Boolean.TRUE);
                target.add(staticRecipientsFieldPanel);
            }
            recipients.setEnabled(checkRecipients.getModelObject());
            target.add(recipients);
            target.add(recipientsContainer);
        }
    });

    checkStaticRecipients.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            if (!checkStaticRecipients.getModelObject() && !selfAsRecipient.getModelObject()
                    && !checkRecipients.getModelObject()) {
                checkRecipients.getField().setDefaultModelObject(Boolean.TRUE);
                checkRecipients.setEnabled(Boolean.TRUE);
                target.add(checkRecipients);
            }
            staticRecipients.setEnabled(checkStaticRecipients.getModelObject());
            staticRecipientsFieldPanel.setRequired(checkStaticRecipients.getModelObject());
            recipients.setEnabled(checkRecipients.getModelObject());
            target.add(staticRecipientsFieldPanel);
            target.add(staticRecipients);
            target.add(recipients);
            target.add(recipientsContainer);
        }
    });

    AjaxButton submit = new IndicatingAjaxButton(APPLY, new Model<String>(getString(SUBMIT))) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            notificationTO.setUserAbout(
                    !checkAbout.getModelObject() && checkUserAbout.getModelObject() ? userAbout.buildFIQL()
                            : null);
            notificationTO.setRoleAbout(
                    !checkAbout.getModelObject() && checkRoleAbout.getModelObject() ? roleAbout.buildFIQL()
                            : null);
            notificationTO.setRecipients(checkRecipients.getModelObject() ? recipients.buildFIQL() : null);
            notificationTO.getStaticRecipients().removeAll(Collections.singleton(null));

            try {
                if (createFlag) {
                    restClient.createNotification(notificationTO);
                } else {
                    restClient.updateNotification(notificationTO);
                }
                info(getString(Constants.OPERATION_SUCCEEDED));

                Configuration callerPage = (Configuration) pageRef.getPage();
                callerPage.setModalResult(true);

                window.close(target);
            } catch (SyncopeClientException scee) {
                error(getString(Constants.ERROR) + ": " + scee.getMessage());
                feedbackPanel.refresh(target);
            }
        }

        @Override
        protected void onError(final AjaxRequestTarget target, final Form<?> form) {
            feedbackPanel.refresh(target);
        }
    };

    final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            window.close(target);
        }
    };

    cancel.setDefaultFormProcessing(false);

    String allowedRoles = createFlag ? xmlRolesReader.getAllAllowedRoles("Notification", "create")
            : xmlRolesReader.getAllAllowedRoles("Notification", "update");
    MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles);

    form.add(submit);
    form.setDefaultButton(submit);

    form.add(cancel);

    add(form);
}

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

License:Apache License

public void addCancelButton(final ModalWindow window) {

    final AjaxButton cancel = new ClearIndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL), pageRef) {

        private static final long serialVersionUID = -2341391430136818025L;

        @Override/*from  w  w  w  .ja va  2 s .c  om*/
        protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
            window.close(target);
        }
    }.feedbackPanelAutomaticReload(false);

    cancel.setDefaultFormProcessing(false);
    bulkActionForm.addOrReplace(cancel);
}

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

License:Apache License

public PolicyModalPage(final PageReference pageRef, final ModalWindow window, final T policyTO) {
    super();//from   w ww.  j a v a  2s.  co m

    final Form<?> form = new Form<Void>(FORM);
    form.setOutputMarkupId(true);
    add(form);

    final AjaxTextFieldPanel policyid = new AjaxTextFieldPanel("id", "id",
            new PropertyModel<String>(policyTO, "id"));
    policyid.setEnabled(false);
    policyid.setStyleSheet("ui-widget-content ui-corner-all short_fixedsize");
    form.add(policyid);

    final AjaxTextFieldPanel description = new AjaxTextFieldPanel("description", "description",
            new PropertyModel<String>(policyTO, "description"));
    description.addRequiredLabel();
    description.setStyleSheet("ui-widget-content ui-corner-all medium_dynamicsize");
    form.add(description);

    final AjaxDropDownChoicePanel<PolicyType> type = new AjaxDropDownChoicePanel<PolicyType>("type", "type",
            new PropertyModel<PolicyType>(policyTO, "type"));
    switch (policyTO.getType()) {
    case GLOBAL_ACCOUNT:
    case ACCOUNT:
        type.setChoices(Arrays.asList(new PolicyType[] { PolicyType.GLOBAL_ACCOUNT, PolicyType.ACCOUNT }));
        break;

    case GLOBAL_PASSWORD:
    case PASSWORD:
        type.setChoices(Arrays.asList(new PolicyType[] { PolicyType.GLOBAL_PASSWORD, PolicyType.PASSWORD }));
        break;

    case GLOBAL_SYNC:
    case SYNC:
        type.setChoices(Arrays.asList(new PolicyType[] { PolicyType.GLOBAL_SYNC, PolicyType.SYNC }));

    default:
    }
    type.setChoiceRenderer(new PolicyTypeRenderer());
    type.addRequiredLabel();
    form.add(type);

    // Authentication resources - only for AccountPolicyTO
    Fragment fragment;
    if (policyTO instanceof AccountPolicyTO) {
        fragment = new Fragment("forAccountOnly", "authResourcesFragment", form);

        final List<String> resourceNames = new ArrayList<String>();
        for (ResourceTO resource : resourceRestClient.getAll()) {
            resourceNames.add(resource.getName());
        }
        fragment.add(new AjaxPalettePanel<String>("authResources",
                new PropertyModel<List<String>>(policyTO, "resources"), new ListModel<String>(resourceNames)));
    } else {
        fragment = new Fragment("forAccountOnly", "emptyFragment", form);
    }
    form.add(fragment);
    //

    final AbstractPolicySpec policy = getPolicySpecification(policyTO);

    form.add(new PolicyBeanPanel("panel", policy));

    final ModalWindow mwindow = new ModalWindow("metaEditModalWin");
    mwindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    mwindow.setInitialHeight(WIN_HEIGHT);
    mwindow.setInitialWidth(WIN_WIDTH);
    mwindow.setCookieName("meta-edit-modal");
    add(mwindow);

    List<IColumn<String, String>> resColumns = new ArrayList<IColumn<String, String>>();
    resColumns.add(new AbstractColumn<String, String>(new StringResourceModel("name", this, null, "")) {

        private static final long serialVersionUID = 2054811145491901166L;

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

            cellItem.add(new Label(componentId, rowModel.getObject()));
        }
    });
    resColumns.add(new AbstractColumn<String, String>(new StringResourceModel("actions", this, null, "")) {

        private static final long serialVersionUID = 2054811145491901166L;

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

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

            final String resource = 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) {
                    mwindow.setPageCreator(new ModalWindow.PageCreator() {

                        private static final long serialVersionUID = -7834632442532690940L;

                        @Override
                        public Page createPage() {
                            return new ResourceModalPage(PolicyModalPage.this.getPageReference(), mwindow,
                                    resourceRestClient.read(resource), false);
                        }
                    });

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

            cellItem.add(panel);
        }
    });
    ISortableDataProvider<String, String> resDataProvider = new SortableDataProvider<String, String>() {

        private static final long serialVersionUID = 8263758912838836438L;

        @Override
        public Iterator<? extends String> iterator(final long first, final long count) {
            return policyTO.getId() == 0 ? Collections.<String>emptyList().iterator()
                    : policyRestClient.getPolicy(policyTO.getId()).getUsedByResources()
                            .subList((int) first, (int) first + (int) count).iterator();
        }

        @Override
        public long size() {
            return policyTO.getId() == 0 ? 0
                    : policyRestClient.getPolicy(policyTO.getId()).getUsedByResources().size();
        }

        @Override
        public IModel<String> model(final String object) {
            return new Model<String>(object);
        }
    };
    final AjaxFallbackDefaultDataTable<String, String> resources = new AjaxFallbackDefaultDataTable<String, String>(
            "resources", resColumns, resDataProvider, 10);
    form.add(resources);

    List<IColumn<RoleTO, String>> roleColumns = new ArrayList<IColumn<RoleTO, String>>();
    roleColumns.add(new PropertyColumn<RoleTO, String>(new ResourceModel("id", "id"), "id", "id"));
    roleColumns.add(new PropertyColumn<RoleTO, String>(new ResourceModel("name", "name"), "name", "name"));
    roleColumns.add(new AbstractColumn<RoleTO, String>(new StringResourceModel("actions", this, null, "")) {

        private static final long serialVersionUID = 2054811145491901166L;

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

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

            final RoleTO role = 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) {
                    mwindow.setPageCreator(new ModalWindow.PageCreator() {

                        private static final long serialVersionUID = -7834632442532690940L;

                        @Override
                        public Page createPage() {
                            return new RoleModalPage(PolicyModalPage.this.getPageReference(), mwindow, role);
                        }
                    });

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

            cellItem.add(panel);
        }
    });
    ISortableDataProvider<RoleTO, String> roleDataProvider = new SortableDataProvider<RoleTO, String>() {

        private static final long serialVersionUID = 8263758912838836438L;

        @Override
        public Iterator<? extends RoleTO> iterator(final long first, final long count) {
            List<RoleTO> roles = new ArrayList<RoleTO>();

            if (policyTO.getId() > 0) {
                for (Long roleId : policyRestClient.getPolicy(policyTO.getId()).getUsedByRoles()
                        .subList((int) first, (int) first + (int) count)) {

                    roles.add(roleRestClient.read(roleId));
                }
            }

            return roles.iterator();
        }

        @Override
        public long size() {
            return policyTO.getId() == 0 ? 0
                    : policyRestClient.getPolicy(policyTO.getId()).getUsedByRoles().size();
        }

        @Override
        public IModel<RoleTO> model(final RoleTO object) {
            return new Model<RoleTO>(object);
        }
    };
    final AjaxFallbackDefaultDataTable<RoleTO, String> roles = new AjaxFallbackDefaultDataTable<RoleTO, String>(
            "roles", roleColumns, roleDataProvider, 10);
    form.add(roles);

    mwindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {

        private static final long serialVersionUID = 8804221891699487139L;

        @Override
        public void onClose(final AjaxRequestTarget target) {
            target.add(resources);
            target.add(roles);
            if (isModalResult()) {
                info(getString(Constants.OPERATION_SUCCEEDED));
                feedbackPanel.refresh(target);
                setModalResult(false);
            }
        }
    });

    final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(APPLY)) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            setPolicySpecification(policyTO, policy);

            try {
                if (policyTO.getId() > 0) {
                    policyRestClient.updatePolicy(policyTO);
                } else {
                    policyRestClient.createPolicy(policyTO);
                }
                ((BasePage) pageRef.getPage()).setModalResult(true);

                window.close(target);
            } catch (Exception e) {
                LOG.error("While creating policy", e);

                error(getString(Constants.ERROR) + ": " + e.getMessage());
                ((NotificationPanel) getPage().get(Constants.FEEDBACK)).refresh(target);
            }
        }

        @Override
        protected void onError(final AjaxRequestTarget target, final Form<?> form) {
            ((NotificationPanel) getPage().get(Constants.FEEDBACK)).refresh(target);
        }
    };
    form.add(submit);

    final IndicatingAjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            window.close(target);
        }

        @Override
        protected void onError(final AjaxRequestTarget target, final Form<?> form) {
        }
    };
    cancel.setDefaultFormProcessing(false);
    form.add(cancel);
}

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

License:Apache License

public ReportExecResultDownloadModalPage(final ModalWindow window, final PageReference callerPageRef) {

    final AjaxDropDownChoicePanel<ReportExecExportFormat> format = new AjaxDropDownChoicePanel<ReportExecExportFormat>(
            "format", "format", new Model<ReportExecExportFormat>());

    format.setChoices(Arrays.asList(ReportExecExportFormat.values()));

    format.setChoiceRenderer(new IChoiceRenderer<ReportExecExportFormat>() {

        private static final long serialVersionUID = -3941271550163141339L;

        @Override//ww  w.j  av a  2 s .  c  om
        public Object getDisplayValue(final ReportExecExportFormat object) {
            return object.name();
        }

        @Override
        public String getIdValue(final ReportExecExportFormat object, final int index) {

            return object.name();
        }
    });

    format.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            format.getField();

            ((ReportModalPage) callerPageRef.getPage()).setExportFormat(format.getField().getModelObject());
            window.close(target);
        }
    });
    add(format);
}

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

License:Apache License

public ReportModalPage(final ModalWindow window, final ReportTO reportTO, final PageReference callerPageRef) {
    super();//from   w  ww . ja  v a  2 s .  c  om
    this.reportTO = reportTO;

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

    setupProfile();
    setupExecutions();

    final CrontabContainer crontab = new CrontabContainer("crontab",
            new PropertyModel<String>(reportTO, "cronExpression"), reportTO.getCronExpression());
    form.add(crontab);

    final AjaxButton submit = new ClearIndicatingAjaxButton(APPLY, new ResourceModel(APPLY),
            getPageReference()) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
            ReportTO toSubmit = (ReportTO) form.getModelObject();
            toSubmit.setCronExpression(
                    StringUtils.hasText(toSubmit.getCronExpression()) ? crontab.getCronExpression() : null);

            try {
                if (toSubmit.getId() > 0) {
                    reportRestClient.update(toSubmit);
                } else {
                    reportRestClient.create(toSubmit);
                }

                ((BasePage) callerPageRef.getPage()).setModalResult(true);

                window.close(target);
            } catch (SyncopeClientException e) {
                LOG.error("While creating or updating report", e);
                error(getString(Constants.ERROR) + ": " + e.getMessage());
                feedbackPanel.refresh(target);
            }
        }

        @Override
        protected void onError(final AjaxRequestTarget target, final Form<?> form) {
            feedbackPanel.refresh(target);
        }
    };

    if (reportTO.getId() > 0) {
        MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER,
                xmlRolesReader.getAllAllowedRoles("Reports", "update"));
    } else {
        MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER,
                xmlRolesReader.getAllAllowedRoles("Reports", "create"));
    }

    form.add(submit);

    final AjaxButton cancel = new ClearIndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL),
            getPageReference()) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
            window.close(target);
        }
    };

    cancel.setDefaultFormProcessing(false);
    form.add(cancel);
}

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

License:Apache License

@SuppressWarnings({ "unchecked", "rawtypes" })
public ResourceModalPage(final PageReference pageRef, final ModalWindow window, final ResourceTO resourceTO,
        final boolean createFlag) {

    super();//w w w . java  2s.c om

    this.add(new Label("new",
            StringUtils.isBlank(resourceTO.getName()) ? new ResourceModel("new") : new Model("")));

    this.add(new Label("name", StringUtils.isBlank(resourceTO.getName()) ? "" : resourceTO.getName()));

    final Form<ResourceTO> form = new Form<ResourceTO>(FORM);
    form.setModel(new CompoundPropertyModel<ResourceTO>(resourceTO));

    //--------------------------------
    // Resource details panel
    //--------------------------------
    form.add(new ResourceDetailsPanel("details", resourceTO, resourceRestClient.getPropagationActionsClasses(),
            createFlag));

    form.add(new SysInfoPanel("systeminformation", resourceTO));
    //--------------------------------

    //--------------------------------
    // Resource mapping panels
    //--------------------------------
    form.add(new ResourceMappingPanel("umapping", resourceTO, AttributableType.USER));
    form.add(new ResourceMappingPanel("rmapping", resourceTO, AttributableType.ROLE));
    //--------------------------------

    //--------------------------------
    // Resource connector configuration panel
    //--------------------------------
    form.add(new ResourceConnConfPanel("connconf", resourceTO, createFlag));
    //--------------------------------

    //--------------------------------
    // Resource security panel
    //--------------------------------
    form.add(new ResourceSecurityPanel("security", resourceTO));
    //--------------------------------

    final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(SUBMIT, SUBMIT)) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            final ResourceTO resourceTO = (ResourceTO) form.getDefaultModelObject();

            boolean accountIdError = false;

            if (resourceTO.getUmapping() == null || resourceTO.getUmapping().getItems().isEmpty()) {
                resourceTO.setUmapping(null);
            } else {
                int uAccountIdCount = 0;
                for (MappingItemTO item : resourceTO.getUmapping().getItems()) {
                    if (item.isAccountid()) {
                        uAccountIdCount++;
                    }
                }
                accountIdError = uAccountIdCount != 1;
            }

            if (resourceTO.getRmapping() == null || resourceTO.getRmapping().getItems().isEmpty()) {
                resourceTO.setRmapping(null);
            } else {
                int rAccountIdCount = 0;
                for (MappingItemTO item : resourceTO.getRmapping().getItems()) {
                    if (item.isAccountid()) {
                        rAccountIdCount++;
                    }
                }
                accountIdError |= rAccountIdCount != 1;
            }

            if (accountIdError) {
                error(getString("accountIdValidation"));
                feedbackPanel.refresh(target);
            } else {
                try {
                    if (createFlag) {
                        resourceRestClient.create(resourceTO);
                    } else {
                        resourceRestClient.update(resourceTO);
                    }

                    if (pageRef != null && pageRef.getPage() instanceof AbstractBasePage) {
                        ((AbstractBasePage) pageRef.getPage()).setModalResult(true);
                    }
                    window.close(target);
                } catch (Exception e) {
                    LOG.error("Failure managing resource {}", resourceTO, e);
                    error(getString(Constants.ERROR) + ": " + e.getMessage());
                    feedbackPanel.refresh(target);
                }
            }
        }

        @Override
        protected void onError(final AjaxRequestTarget target, final Form<?> form) {
            feedbackPanel.refresh(target);
        }
    };

    form.add(submit);
    form.setDefaultButton(submit);

    final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            window.close(target);
        }

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

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

    add(form);

    MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE,
            xmlRolesReader.getAllAllowedRoles("Resources", createFlag ? "create" : "update"));
}

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

License:Apache License

public RoleSelectModalPage(final PageReference pageRef, final ModalWindow window, final Class<?> payloadClass) {
    super();/*ww w.  jav a 2  s  .c  om*/

    final ITreeProvider<DefaultMutableTreeNode> treeProvider = new TreeRoleProvider(roleTreeBuilder, true);
    final DefaultMutableTreeNodeExpansionModel treeModel = new DefaultMutableTreeNodeExpansionModel();

    tree = new DefaultNestedTree<DefaultMutableTreeNode>("treeTable", treeProvider, treeModel) {

        private static final long serialVersionUID = 7137658050662575546L;

        @Override
        protected Component newContentComponent(final String id, final IModel<DefaultMutableTreeNode> node) {
            final DefaultMutableTreeNode treeNode = node.getObject();
            final RoleTO roleTO = (RoleTO) treeNode.getUserObject();

            return new Folder<DefaultMutableTreeNode>(id, RoleSelectModalPage.this.tree, node) {

                private static final long serialVersionUID = 9046323319920426493L;

                @Override
                protected boolean isClickable() {
                    return true;
                }

                @Override
                protected IModel<?> newLabelModel(final IModel<DefaultMutableTreeNode> model) {
                    return new Model<String>(roleTO.getDisplayName());
                }

                @Override
                protected void onClick(final AjaxRequestTarget target) {
                    super.onClick(target);

                    try {
                        Constructor constructor = payloadClass.getConstructor(Long.class);
                        Object payload = constructor.newInstance(roleTO.getId());

                        send(pageRef.getPage(), Broadcast.BREADTH, payload);
                    } catch (Exception e) {
                        LOG.error("Could not send role select event", e);
                    }

                    window.close(target);
                }
            };
        }
    };
    tree.add(new WindowsTheme());
    tree.setOutputMarkupId(true);

    DefaultMutableTreeNodeExpansion.get().expandAll();

    this.add(tree);
}

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

License:Apache License

@Override
public void setSchemaModalPage(final PageReference pageRef, final ModalWindow window, final SchemaTO schemaTO,
        final boolean createFlag) {

    final SchemaTO schema = schemaTO == null ? new SchemaTO() : schemaTO;

    final Form<SchemaTO> schemaForm = new Form<SchemaTO>(FORM);

    schemaForm.setModel(new CompoundPropertyModel<SchemaTO>(schema));
    schemaForm.setOutputMarkupId(true);//from   www . ja  va  2  s  . c  o  m

    final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", getString("name"),
            new PropertyModel<String>(schema, "name"));
    name.addRequiredLabel();
    name.setEnabled(createFlag);
    schemaForm.add(name);

    final AjaxDropDownChoicePanel<AttributeSchemaType> type = new AjaxDropDownChoicePanel<AttributeSchemaType>(
            "type", getString("type"), new PropertyModel<AttributeSchemaType>(schema, "type"));
    type.setChoices(Arrays.asList(AttributeSchemaType.values()));
    type.addRequiredLabel();
    schemaForm.add(type);

    // -- long, double, date
    final AjaxTextFieldPanel conversionPattern = new AjaxTextFieldPanel("conversionPattern",
            getString("conversionPattern"), new PropertyModel<String>(schema, "conversionPattern"));
    schemaForm.add(conversionPattern);

    final WebMarkupContainer conversionParams = new WebMarkupContainer("conversionParams");
    conversionParams.setOutputMarkupPlaceholderTag(true);
    conversionParams.add(conversionPattern);
    schemaForm.add(conversionParams);

    // -- enum
    final AjaxTextFieldPanel enumerationValuesPanel = new AjaxTextFieldPanel("panel", "enumerationValues",
            new Model<String>(null));
    @SuppressWarnings({ "unchecked", "rawtypes" })
    final MultiFieldPanel<String> enumerationValues = new MultiFieldPanel<String>("enumerationValues",
            new Model(), enumerationValuesPanel);
    enumerationValues.setModelObject(getEnumValuesAsList(schema.getEnumerationValues()));

    @SuppressWarnings({ "unchecked", "rawtypes" })
    final MultiFieldPanel<String> enumerationKeys = new MultiFieldPanel<String>("enumerationKeys", new Model(),
            new AjaxTextFieldPanel("panel", "enumerationKeys", new Model<String>(null)));
    enumerationKeys.setModelObject(getEnumValuesAsList(schema.getEnumerationKeys()));

    final WebMarkupContainer enumParams = new WebMarkupContainer("enumParams");
    enumParams.setOutputMarkupPlaceholderTag(true);
    enumParams.add(enumerationValues);
    enumParams.add(enumerationKeys);
    schemaForm.add(enumParams);

    // -- encrypted
    final AjaxTextFieldPanel secretKey = new AjaxTextFieldPanel("secretKey", getString("secretKey"),
            new PropertyModel<String>(schema, "secretKey"));

    final AjaxDropDownChoicePanel<CipherAlgorithm> cipherAlgorithm = new AjaxDropDownChoicePanel<CipherAlgorithm>(
            "cipherAlgorithm", getString("cipherAlgorithm"),
            new PropertyModel<CipherAlgorithm>(schema, "cipherAlgorithm"));
    cipherAlgorithm.setChoices(Arrays.asList(CipherAlgorithm.values()));

    final WebMarkupContainer encryptedParams = new WebMarkupContainer("encryptedParams");
    encryptedParams.setOutputMarkupPlaceholderTag(true);
    encryptedParams.add(secretKey);
    encryptedParams.add(cipherAlgorithm);
    schemaForm.add(encryptedParams);

    // -- binary
    final AjaxTextFieldPanel mimeType = new AjaxTextFieldPanel("mimeType", getString("mimeType"),
            new PropertyModel<String>(schema, "mimeType"));
    mimeType.setChoices(mimeTypesInitializer.getMimeTypes());

    final WebMarkupContainer binaryParams = new WebMarkupContainer("binaryParams");
    binaryParams.setOutputMarkupPlaceholderTag(true);
    binaryParams.add(mimeType);
    schemaForm.add(binaryParams);

    // -- show or hide
    showHide(schema, type, conversionParams, conversionPattern, enumParams, enumerationValuesPanel,
            enumerationValues, enumerationKeys, encryptedParams, secretKey, cipherAlgorithm, binaryParams,
            mimeType);
    type.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            SchemaModalPage.this.showHide(schema, type, conversionParams, conversionPattern, enumParams,
                    enumerationValuesPanel, enumerationValues, enumerationKeys, encryptedParams, secretKey,
                    cipherAlgorithm, binaryParams, mimeType);
            target.add(schemaForm);
        }
    });

    final IModel<List<String>> validatorsList = new LoadableDetachableModel<List<String>>() {

        private static final long serialVersionUID = 5275935387613157437L;

        @Override
        protected List<String> load() {
            return schemaRestClient.getAllValidatorClasses();
        }
    };
    final AjaxDropDownChoicePanel<String> validatorClass = new AjaxDropDownChoicePanel<String>("validatorClass",
            getString("validatorClass"), new PropertyModel<String>(schema, "validatorClass"));
    ((DropDownChoice) validatorClass.getField()).setNullValid(true);
    validatorClass.setChoices(validatorsList.getObject());
    schemaForm.add(validatorClass);

    final AutoCompleteTextField<String> mandatoryCondition = new AutoCompleteTextField<String>(
            "mandatoryCondition") {

        private static final long serialVersionUID = -2428903969518079100L;

        @Override
        protected Iterator<String> getChoices(final String input) {
            List<String> choices = new ArrayList<String>();

            if (Strings.isEmpty(input)) {
                choices = Collections.emptyList();
            } else if ("true".startsWith(input.toLowerCase())) {
                choices.add("true");
            } else if ("false".startsWith(input.toLowerCase())) {
                choices.add("false");
            }

            return choices.iterator();
        }
    };
    mandatoryCondition.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
        }
    });
    schemaForm.add(mandatoryCondition);

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

    final AjaxLink<Void> pwdQuestionMarkJexlHelp = JexlHelpUtil.getAjaxLink(pwdJexlHelp,
            "questionMarkJexlHelp");
    schemaForm.add(pwdQuestionMarkJexlHelp);
    pwdQuestionMarkJexlHelp.add(pwdJexlHelp);

    final AjaxCheckBoxPanel multivalue = new AjaxCheckBoxPanel("multivalue", getString("multivalue"),
            new PropertyModel<Boolean>(schema, "multivalue"));
    schemaForm.add(multivalue);

    final AjaxCheckBoxPanel readonly = new AjaxCheckBoxPanel("readonly", getString("readonly"),
            new PropertyModel<Boolean>(schema, "readonly"));
    schemaForm.add(readonly);

    final AjaxCheckBoxPanel uniqueConstraint = new AjaxCheckBoxPanel("uniqueConstraint",
            getString("uniqueConstraint"), new PropertyModel<Boolean>(schema, "uniqueConstraint"));
    schemaForm.add(uniqueConstraint);

    final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(SUBMIT)) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            final SchemaTO schemaTO = (SchemaTO) form.getDefaultModelObject();

            schemaTO.setEnumerationValues(getEnumValuesAsString(enumerationValues.getView().getModelObject()));
            schemaTO.setEnumerationKeys(getEnumValuesAsString(enumerationKeys.getView().getModelObject()));

            if (schemaTO.isMultivalue() && schemaTO.isUniqueConstraint()) {
                error(getString("multivalueAndUniqueConstr.validation"));
                feedbackPanel.refresh(target);
                return;
            }

            try {
                if (createFlag) {
                    schemaRestClient.createSchema(kind, schemaTO);
                } else {
                    schemaRestClient.updateSchema(kind, schemaTO);
                }
                if (pageRef.getPage() instanceof BasePage) {
                    ((BasePage) pageRef.getPage()).setModalResult(true);
                }

                window.close(target);
            } catch (SyncopeClientException e) {
                error(getString(Constants.ERROR) + ": " + e.getMessage());
                feedbackPanel.refresh(target);
            }
        }

        @Override
        protected void onError(final AjaxRequestTarget target, final Form<?> form) {
            feedbackPanel.refresh(target);
        }
    };
    schemaForm.add(submit);

    final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            window.close(target);
        }
    };
    cancel.setDefaultFormProcessing(false);
    schemaForm.add(cancel);

    String allowedRoles = createFlag ? xmlRolesReader.getAllAllowedRoles("Schema", "create")
            : xmlRolesReader.getAllAllowedRoles("Schema", "update");

    MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles);

    add(schemaForm);
}

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

License:Apache License

public StatusModalPage(final PageReference pageRef, final ModalWindow window, final AbstractSubjectTO subjectTO,
        final boolean statusOnly) {

    super();/*from   w  ww. ja v a  2 s  .  c  o  m*/

    this.pageRef = pageRef;
    this.window = window;
    this.statusOnly = statusOnly;
    this.subjectTO = subjectTO;

    statusUtils = new StatusUtils(subjectTO instanceof UserTO ? userRestClient : roleRestClient);

    columns = new ArrayList<IColumn<StatusBean, String>>();
    columns.add(new AbstractColumn<StatusBean, String>(
            new StringResourceModel("resourceName", this, null, "Resource name"), "resourceName") {

        private static final long serialVersionUID = 2054811145491901166L;

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

            cellItem.add(new Label(componentId, model.getObject().getResourceName()) {

                private static final long serialVersionUID = 8432079838783825801L;

                @Override
                protected void onComponentTag(final ComponentTag tag) {
                    if (model.getObject().isLinked()) {
                        super.onComponentTag(tag);
                    } else {
                        tag.put("style", "color: #DDDDDD");
                    }
                }
            });
        }
    });

    columns.add(new PropertyColumn<StatusBean, String>(
            new StringResourceModel("accountLink", this, null, "Account link"), "accountLink", "accountLink"));

    columns.add(new AbstractColumn<StatusBean, String>(new StringResourceModel("status", this, null, "")) {

        private static final long serialVersionUID = -3503023501954863131L;

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

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

            if (model.getObject().isLinked()) {
                cellItem.add(statusUtils.getStatusImagePanel(componentId, model.getObject().getStatus()));
            } else {
                cellItem.add(new Label(componentId, ""));
            }
        }
    });

    table = new ActionDataTablePanel<StatusBean, String>("resourceDatatable", columns,
            (ISortableDataProvider<StatusBean, String>) new AttributableStatusProvider(), rowsPerPage,
            pageRef) {

        private static final long serialVersionUID = 6510391461033818316L;

        @Override
        public boolean isElementEnabled(final StatusBean element) {
            return !statusOnly || element.getStatus() != Status.OBJECT_NOT_FOUND;
        }
    };
    table.setOutputMarkupId(true);

    final String pageId = subjectTO instanceof RoleTO ? "Roles" : "Users";

    final Fragment pwdMgtFragment = new Fragment("pwdMgtFields", "pwdMgtFragment", this);
    addOrReplace(pwdMgtFragment);

    pwdMgt = new WebMarkupContainer("pwdMgt");
    pwdMgtFragment.add(pwdMgt.setOutputMarkupId(true));

    pwdMgtForm = new Form("pwdMgtForm");
    pwdMgtForm.setVisible(false).setEnabled(false);
    pwdMgt.add(pwdMgtForm);

    password = new PasswordTextField("password", new Model<String>());
    pwdMgtForm.add(password.setRequired(false).setEnabled(false));

    confirm = new PasswordTextField("confirm", new Model<String>());
    pwdMgtForm.add(confirm.setRequired(false).setEnabled(false));

    changepwd = new AjaxCheckBoxPanel("changepwd", "changepwd", new Model<Boolean>(false));
    pwdMgtForm.add(changepwd.setModelObject(false));
    pwdMgtForm.add(new Label("changePwdLabel", new ResourceModel("changePwdLabel", "Password propagation")));

    changepwd.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            password.setEnabled(changepwd.getModelObject());
            confirm.setEnabled(changepwd.getModelObject());
            target.add(pwdMgt);
        }
    });

    cancel = new ClearIndicatingAjaxButton("cancel", new ResourceModel("cancel"), pageRef) {

        private static final long serialVersionUID = -2341391430136818026L;

        @Override
        protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
            // ignore
            window.close(target);
        }
    }.feedbackPanelAutomaticReload(false);

    pwdMgtForm.add(cancel);

    final ClearIndicatingAjaxButton goon = new ClearIndicatingAjaxButton("continue",
            new ResourceModel("continue"), pageRef) {

        private static final long serialVersionUID = -2341391430136818027L;

        @Override
        protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
            // none
        }
    };

    pwdMgtForm.add(goon);

    if (statusOnly) {
        table.addAction(new ActionLink() {

            private static final long serialVersionUID = -3722207913631435501L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                try {
                    userRestClient.reactivate(subjectTO.getETagValue(), subjectTO.getId(),
                            new ArrayList<StatusBean>(table.getModelObject()));

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

                    window.close(target);
                } catch (Exception e) {
                    LOG.error("Error enabling resources", e);
                    error(getString(Constants.ERROR) + ": " + e.getMessage());
                    feedbackPanel.refresh(target);
                }
            }
        }, ActionLink.ActionType.REACTIVATE, pageId);

        table.addAction(new ActionLink() {

            private static final long serialVersionUID = -3722207913631435501L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                try {
                    userRestClient.suspend(subjectTO.getETagValue(), subjectTO.getId(),
                            new ArrayList<StatusBean>(table.getModelObject()));

                    if (pageRef.getPage() instanceof BasePage) {
                        ((BasePage) pageRef.getPage()).setModalResult(true);
                    }

                    window.close(target);
                } catch (Exception e) {
                    LOG.error("Error disabling resources", e);
                    error(getString(Constants.ERROR) + ": " + e.getMessage());
                    feedbackPanel.refresh(target);
                }
            }
        }, ActionLink.ActionType.SUSPEND, pageId);
    } else {
        table.addAction(new ActionLink() {

            private static final long serialVersionUID = -3722207913631435501L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                try {
                    if (subjectTO instanceof UserTO) {
                        userRestClient.unlink(subjectTO.getETagValue(), subjectTO.getId(),
                                new ArrayList<StatusBean>(table.getModelObject()));
                    } else {
                        roleRestClient.unlink(subjectTO.getETagValue(), subjectTO.getId(),
                                new ArrayList<StatusBean>(table.getModelObject()));
                    }

                    ((BasePage) pageRef.getPage()).setModalResult(true);
                    window.close(target);
                } catch (Exception e) {
                    LOG.error("Error unlinking resources", e);
                    error(getString(Constants.ERROR) + ": " + e.getMessage());
                    feedbackPanel.refresh(target);
                }
            }
        }, ActionLink.ActionType.UNLINK, pageId);

        table.addAction(new ActionLink() {

            private static final long serialVersionUID = -3722207913631435501L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                try {
                    if (subjectTO instanceof UserTO) {
                        userRestClient.link(subjectTO.getETagValue(), subjectTO.getId(),
                                new ArrayList<StatusBean>(table.getModelObject()));
                    } else {
                        roleRestClient.link(subjectTO.getETagValue(), subjectTO.getId(),
                                new ArrayList<StatusBean>(table.getModelObject()));
                    }

                    ((BasePage) pageRef.getPage()).setModalResult(true);
                    window.close(target);
                } catch (Exception e) {
                    LOG.error("Error linking resources", e);
                    error(getString(Constants.ERROR) + ": " + e.getMessage());
                    feedbackPanel.refresh(target);
                }
            }
        }, ActionLink.ActionType.LINK, pageId);

        table.addAction(new ActionLink() {

            private static final long serialVersionUID = -3722207913631435501L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                try {
                    BulkActionResult bulkActionResult;
                    if (subjectTO instanceof UserTO) {
                        bulkActionResult = userRestClient.deprovision(subjectTO.getETagValue(),
                                subjectTO.getId(), new ArrayList<StatusBean>(table.getModelObject()));
                    } else {
                        bulkActionResult = roleRestClient.deprovision(subjectTO.getETagValue(),
                                subjectTO.getId(), new ArrayList<StatusBean>(table.getModelObject()));
                    }

                    ((BasePage) pageRef.getPage()).setModalResult(true);
                    loadBulkActionResultPage(table.getModelObject(), bulkActionResult);
                } catch (Exception e) {
                    LOG.error("Error de-provisioning user", e);
                    error(getString(Constants.ERROR) + ": " + e.getMessage());
                    feedbackPanel.refresh(target);
                }
            }
        }, ActionLink.ActionType.DEPROVISION, pageId);

        table.addAction(new ActionLink() {

            private static final long serialVersionUID = -3722207913631435501L;

            @Override
            public void onClick(final AjaxRequestTarget target) {

                if (subjectTO instanceof UserTO) {
                    StatusModalPage.this.passwordManagement(target, ResourceAssociationActionType.PROVISION,
                            table.getModelObject());
                } else {
                    try {
                        final BulkActionResult bulkActionResult = roleRestClient.provision(
                                subjectTO.getETagValue(), subjectTO.getId(),
                                new ArrayList<StatusBean>(table.getModelObject()));

                        ((BasePage) pageRef.getPage()).setModalResult(true);
                        loadBulkActionResultPage(table.getModelObject(), bulkActionResult);
                    } catch (Exception e) {
                        LOG.error("Error provisioning user", e);
                        error(getString(Constants.ERROR) + ": " + e.getMessage());
                        feedbackPanel.refresh(target);
                    }
                }
            }
        }.feedbackPanelAutomaticReload(!(subjectTO instanceof UserTO)), ActionLink.ActionType.PROVISION,
                pageId);

        table.addAction(new ActionLink() {

            private static final long serialVersionUID = -3722207913631435501L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                try {
                    final BulkActionResult bulkActionResult;
                    if (subjectTO instanceof UserTO) {
                        bulkActionResult = userRestClient.unassign(subjectTO.getETagValue(), subjectTO.getId(),
                                new ArrayList<StatusBean>(table.getModelObject()));
                    } else {
                        bulkActionResult = roleRestClient.unassign(subjectTO.getETagValue(), subjectTO.getId(),
                                new ArrayList<StatusBean>(table.getModelObject()));
                    }

                    ((BasePage) pageRef.getPage()).setModalResult(true);
                    loadBulkActionResultPage(table.getModelObject(), bulkActionResult);
                } catch (Exception e) {
                    LOG.error("Error unassigning resources", e);
                    error(getString(Constants.ERROR) + ": " + e.getMessage());
                    feedbackPanel.refresh(target);
                }
            }
        }, ActionLink.ActionType.UNASSIGN, pageId);

        table.addAction(new ActionLink() {

            private static final long serialVersionUID = -3722207913631435501L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                if (subjectTO instanceof UserTO) {
                    StatusModalPage.this.passwordManagement(target, ResourceAssociationActionType.ASSIGN,
                            table.getModelObject());
                } else {
                    try {
                        final BulkActionResult bulkActionResult = roleRestClient.assign(
                                subjectTO.getETagValue(), subjectTO.getId(),
                                new ArrayList<StatusBean>(table.getModelObject()));

                        ((BasePage) pageRef.getPage()).setModalResult(true);
                        loadBulkActionResultPage(table.getModelObject(), bulkActionResult);
                    } catch (Exception e) {
                        LOG.error("Error assigning resources", e);
                        error(getString(Constants.ERROR) + ": " + e.getMessage());
                        feedbackPanel.refresh(target);
                    }
                }
            }
        }.feedbackPanelAutomaticReload(!(subjectTO instanceof UserTO)), ActionLink.ActionType.ASSIGN, pageId);
    }

    table.addCancelButton(window);
    add(table);
}