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

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

Introduction

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

Prototype

public ModalWindow(final String id) 

Source Link

Document

Creates a new modal window component.

Usage

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

License:Apache License

public Configuration() {
    super();//from w  ww  .  j  a v a2s.c  o m

    // Layouts
    add(new LayoutsPanel("adminUserLayoutPanel", AttrLayoutType.ADMIN_USER, feedbackPanel));
    add(new LayoutsPanel("selfUserLayoutPanel", AttrLayoutType.SELF_USER, feedbackPanel));
    add(new LayoutsPanel("adminGroupLayoutPanel", AttrLayoutType.ADMIN_GROUP, feedbackPanel));
    add(new LayoutsPanel("selfGroupLayoutPanel", AttrLayoutType.SELF_GROUP, feedbackPanel));
    add(new LayoutsPanel("adminMembershipLayoutPanel", AttrLayoutType.ADMIN_MEMBERSHIP, feedbackPanel));
    add(new LayoutsPanel("selfMembershipLayoutPanel", AttrLayoutType.SELF_MEMBERSHIP, feedbackPanel));

    add(syncopeConfWin = new ModalWindow("syncopeConfWin"));
    syncopeConfWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    syncopeConfWin.setInitialHeight(SYNCOPECONF_WIN_HEIGHT);
    syncopeConfWin.setInitialWidth(SYNCOPECONF_WIN_WIDTH);
    syncopeConfWin.setCookieName("syncopeconf-modal");
    setupSyncopeConf();

    add(new PoliciesPanel("passwordPoliciesPanel", getPageReference(), PolicyType.PASSWORD));
    add(new PoliciesPanel("accountPoliciesPanel", getPageReference(), PolicyType.ACCOUNT));
    add(new PoliciesPanel("syncPoliciesPanel", getPageReference(), PolicyType.SYNC));

    add(createNotificationWin = new ModalWindow("createNotificationWin"));
    createNotificationWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    createNotificationWin.setInitialHeight(NOTIFICATION_WIN_HEIGHT);
    createNotificationWin.setInitialWidth(NOTIFICATION_WIN_WIDTH);
    createNotificationWin.setCookieName("create-notification-modal");
    add(editNotificationWin = new ModalWindow("editNotificationWin"));
    editNotificationWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editNotificationWin.setInitialHeight(NOTIFICATION_WIN_HEIGHT);
    editNotificationWin.setInitialWidth(NOTIFICATION_WIN_WIDTH);
    editNotificationWin.setCookieName("edit-notification-modal");
    setupNotification();

    add(createSecurityQuestionWin = new ModalWindow("createSecurityQuestionWin"));
    createSecurityQuestionWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    createSecurityQuestionWin.setInitialHeight(SECURITY_QUESTION_WIN_HEIGHT);
    createSecurityQuestionWin.setInitialWidth(SECURITY_QUESTION_WIN_WIDTH);
    createSecurityQuestionWin.setCookieName("create-security-question-modal");
    add(editSecurityQuestionWin = new ModalWindow("editSecurityQuestionWin"));
    editSecurityQuestionWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editSecurityQuestionWin.setInitialHeight(SECURITY_QUESTION_WIN_HEIGHT);
    editSecurityQuestionWin.setInitialWidth(SECURITY_QUESTION_WIN_WIDTH);
    editSecurityQuestionWin.setCookieName("edit-security-question-modal");
    setupSecurityQuestion();

    // Workflow definition stuff
    WebMarkupContainer noActivitiEnabledForUsers = new WebMarkupContainer("noActivitiEnabledForUsers");
    noActivitiEnabledForUsers.setOutputMarkupPlaceholderTag(true);
    add(noActivitiEnabledForUsers);

    WebMarkupContainer workflowDefContainer = new WebMarkupContainer("workflowDefContainer");
    workflowDefContainer.setOutputMarkupPlaceholderTag(true);

    if (wfRestClient.isActivitiEnabledForUsers()) {
        noActivitiEnabledForUsers.setVisible(false);
    } else {
        workflowDefContainer.setVisible(false);
    }

    BookmarkablePageLink<Void> activitiModeler = new BookmarkablePageLink<>("activitiModeler",
            ActivitiModelerPopupPage.class);
    activitiModeler.setPopupSettings(new VeilPopupSettings().setHeight(600).setWidth(800));
    MetaDataRoleAuthorizationStrategy.authorize(activitiModeler, ENABLE,
            xmlRolesReader.getEntitlement("Configuration", "workflowDefRead"));
    workflowDefContainer.add(activitiModeler);
    // Check if Activiti Modeler directory is found
    boolean activitiModelerEnabled = false;
    try {
        String activitiModelerDirectory = WebApplicationContextUtils
                .getWebApplicationContext(WebApplication.get().getServletContext())
                .getBean("activitiModelerDirectory", String.class);
        File baseDir = new File(activitiModelerDirectory);
        activitiModelerEnabled = baseDir.exists() && baseDir.canRead() && baseDir.isDirectory();
    } catch (Exception e) {
        LOG.error("Could not check for Activiti Modeler directory", e);
    }
    activitiModeler.setEnabled(activitiModelerEnabled);

    BookmarkablePageLink<Void> xmlEditor = new BookmarkablePageLink<>("xmlEditor", XMLEditorPopupPage.class);
    xmlEditor.setPopupSettings(new VeilPopupSettings().setHeight(480).setWidth(800));
    MetaDataRoleAuthorizationStrategy.authorize(xmlEditor, ENABLE,
            xmlRolesReader.getEntitlement("Configuration", "workflowDefRead"));
    workflowDefContainer.add(xmlEditor);

    Image workflowDefDiagram = new Image("workflowDefDiagram", new Model()) {

        private static final long serialVersionUID = -8457850449086490660L;

        @Override
        protected IResource getImageResource() {
            return new DynamicImageResource() {

                private static final long serialVersionUID = 923201517955737928L;

                @Override
                protected byte[] getImageData(final IResource.Attributes attributes) {
                    return wfRestClient.isActivitiEnabledForUsers() ? wfRestClient.getDiagram() : new byte[0];
                }
            };
        }
    };
    workflowDefContainer.add(workflowDefDiagram);

    MetaDataRoleAuthorizationStrategy.authorize(workflowDefContainer, ENABLE,
            xmlRolesReader.getEntitlement("Configuration", "workflowDefRead"));
    add(workflowDefContainer);

    // Logger stuff
    PropertyListView<LoggerTO> coreLoggerList = new LoggerPropertyList(null, "corelogger",
            loggerRestClient.listLogs());
    WebMarkupContainer coreLoggerContainer = new WebMarkupContainer("coreLoggerContainer");
    coreLoggerContainer.add(coreLoggerList);
    coreLoggerContainer.setOutputMarkupId(true);

    MetaDataRoleAuthorizationStrategy.authorize(coreLoggerContainer, ENABLE,
            xmlRolesReader.getEntitlement("Configuration", "logList"));
    add(coreLoggerContainer);

    ConsoleLoggerController consoleLoggerController = new ConsoleLoggerController();
    PropertyListView<LoggerTO> consoleLoggerList = new LoggerPropertyList(consoleLoggerController,
            "consolelogger", consoleLoggerController.getLoggers());
    WebMarkupContainer consoleLoggerContainer = new WebMarkupContainer("consoleLoggerContainer");
    consoleLoggerContainer.add(consoleLoggerList);
    consoleLoggerContainer.setOutputMarkupId(true);

    MetaDataRoleAuthorizationStrategy.authorize(consoleLoggerContainer, ENABLE,
            xmlRolesReader.getEntitlement("Configuration", "logList"));
    add(consoleLoggerContainer);

    // Extension panels
    setupExtPanels();
}

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

License:Apache License

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

    groupTabsContainer = new WebMarkupContainer("groupTabsContainer");
    groupTabsContainer.setOutputMarkupId(true);
    add(groupTabsContainer);/*  w  w w  . j  av a  2 s  .  c  o m*/

    editGroupWin = new ModalWindow("editGroupWin");
    editGroupWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editGroupWin.setInitialHeight(WIN_HEIGHT);
    editGroupWin.setInitialWidth(WIN_WIDTH);
    editGroupWin.setCookieName("edit-group-modal");
    add(editGroupWin);

    final TreeGroupPanel treePanel = new TreeGroupPanel("treePanel");
    treePanel.setOutputMarkupId(true);
    groupTabsContainer.add(treePanel);

    final GroupSummaryPanel summaryPanel = new GroupSummaryPanel.Builder("summaryPanel").window(editGroupWin)
            .callerPageRef(Groups.this.getPageReference()).build();
    groupTabsContainer.add(summaryPanel);

    editGroupWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {

        private static final long serialVersionUID = 8804221891699487139L;

        @Override
        public void onClose(final AjaxRequestTarget target) {
            final GroupSummaryPanel summaryPanel = (GroupSummaryPanel) groupTabsContainer.get("summaryPanel");

            final TreeNodeClickUpdate data = new TreeNodeClickUpdate(target,
                    summaryPanel == null || summaryPanel.getSelectedNode() == null ? 0
                            : summaryPanel.getSelectedNode().getKey());

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

            if (modalResult) {
                getSession().info(getString(Constants.OPERATION_SUCCEEDED));
                feedbackPanel.refresh(target);
                modalResult = false;
            }

        }
    });

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

    final Form searchForm = new Form("searchForm");
    add(searchForm);

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

    searchForm.add(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("Node condition {}", 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);
        }
    });
}

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

License:Apache License

public PolicyModalPage(final PageReference pageRef, final ModalWindow window, final T policyTO) {
    super();//from   w w w. j av a 2 s  . com

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

    final AjaxTextFieldPanel policyid = new AjaxTextFieldPanel("key", "key",
            new PropertyModel<String>(policyTO, "key"));
    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<>("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<>();
        for (ResourceTO resource : resourceRestClient.getAll()) {
            resourceNames.add(resource.getKey());
        }
        fragment.add(new AjaxPalettePanel<>("authResources",
                new PropertyModel<List<String>>(policyTO, "resources"), new ListModel<>(resourceNames)));
    } else {
        fragment = new Fragment("forAccountOnly", "emptyFragment", form);
    }
    form.add(fragment);
    //

    final PolicySpec 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<>();
    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.getKey() == 0 ? Collections.<String>emptyList().iterator()
                    : policyRestClient.getPolicy(policyTO.getKey()).getUsedByResources()
                            .subList((int) first, (int) first + (int) count).iterator();
        }

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

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

    List<IColumn<GroupTO, String>> groupColumns = new ArrayList<>();
    groupColumns.add(new PropertyColumn<GroupTO, String>(new ResourceModel("key", "key"), "key", "key"));
    groupColumns.add(new PropertyColumn<GroupTO, String>(new ResourceModel("name", "name"), "name", "name"));
    groupColumns.add(new AbstractColumn<GroupTO, 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<GroupTO>> cellItem, final String componentId,
                final IModel<GroupTO> model) {

            final GroupTO group = 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 GroupModalPage(PolicyModalPage.this.getPageReference(), mwindow, group);
                        }
                    });

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

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

        private static final long serialVersionUID = 8263758912838836438L;

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

            if (policyTO.getKey() > 0) {
                for (Long groupId : policyRestClient.getPolicy(policyTO.getKey()).getUsedByGroups()
                        .subList((int) first, (int) first + (int) count)) {

                    groups.add(groupRestClient.read(groupId));
                }
            }

            return groups.iterator();
        }

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

        @Override
        public IModel<GroupTO> model(final GroupTO object) {
            return new Model<>(object);
        }
    };
    final AjaxFallbackDefaultDataTable<GroupTO, String> groups = new AjaxFallbackDefaultDataTable<>("groups",
            groupColumns, groupDataProvider, 10);
    form.add(groups);

    mwindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {

        private static final long serialVersionUID = 8804221891699487139L;

        @Override
        public void onClose(final AjaxRequestTarget target) {
            target.add(resources);
            target.add(groups);
            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.getKey() > 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.client.console.pages.ReportModalPage.java

License:Apache License

private void setupProfile() {
    final WebMarkupContainer profile = new WebMarkupContainer("profile");
    profile.setOutputMarkupId(true);/*from   www .  ja va  2 s.com*/
    form.add(profile);

    final ModalWindow reportletConfWin = new ModalWindow("reportletConfWin");
    reportletConfWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    reportletConfWin.setCookieName("reportlet-conf-win-modal");
    reportletConfWin.setInitialHeight(REPORTLET_CONF_WIN_HEIGHT);
    reportletConfWin.setInitialWidth(REPORTLET_CONF_WIN_WIDTH);
    reportletConfWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {

        private static final long serialVersionUID = 8804221891699487139L;

        @Override
        public void onClose(final AjaxRequestTarget target) {
            int foundIdx = -1;
            if (modalReportletConfOldName != null) {
                for (int i = 0; i < reportTO.getReportletConfs().size() && foundIdx == -1; i++) {
                    if (reportTO.getReportletConfs().get(i).getName().equals(modalReportletConfOldName)) {
                        foundIdx = i;
                    }
                }
            }
            if (modalReportletConf != null) {
                if (foundIdx == -1) {
                    reportTO.getReportletConfs().add(modalReportletConf);
                } else {
                    reportTO.getReportletConfs().set(foundIdx, modalReportletConf);
                }
            }

            target.add(reportlets);
        }
    });
    add(reportletConfWin);

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

    final AjaxTextFieldPanel key = new AjaxTextFieldPanel("key", getString("key"),
            new PropertyModel<String>(reportTO, "key"));
    key.setEnabled(false);
    profile.add(key);

    final Label nameLabel = new Label("nameLabel", new ResourceModel("name"));
    profile.add(nameLabel);

    final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", getString("name"),
            new PropertyModel<String>(reportTO, "name"));
    profile.add(name);

    final AjaxTextFieldPanel lastExec = new AjaxTextFieldPanel("lastExec", getString("lastExec"),
            new DateFormatROModel(new PropertyModel<String>(reportTO, "lastExec")));
    lastExec.setEnabled(false);
    profile.add(lastExec);

    final AjaxTextFieldPanel nextExec = new AjaxTextFieldPanel("nextExec", getString("nextExec"),
            new DateFormatROModel(new PropertyModel<String>(reportTO, "nextExec")));
    nextExec.setEnabled(false);
    profile.add(nextExec);

    reportlets = new ListChoice<AbstractReportletConf>("reportletConfs", new Model<AbstractReportletConf>(),
            reportTO.getReportletConfs(), new IChoiceRenderer<ReportletConf>() {

                private static final long serialVersionUID = 1048000918946220007L;

                @Override
                public Object getDisplayValue(final ReportletConf object) {
                    return object.getName();
                }

                @Override
                public String getIdValue(final ReportletConf object, final int index) {
                    return object.getName();
                }
            }) {

        private static final long serialVersionUID = 4022366881854379834L;

        @Override
        protected CharSequence getDefaultChoice(final String selectedValue) {
            return null;
        }
    };

    reportlets.setNullValid(true);
    profile.add(reportlets);
    reportlets.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

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

    profile.add(new AjaxLink<Void>(ADD_BUTTON_ID) {

        private static final long serialVersionUID = -7978723352517770644L;

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

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    modalReportletConfOldName = null;
                    modalReportletConf = null;
                    return new ReportletConfModalPage(null, reportletConfWin,
                            ReportModalPage.this.getPageReference());
                }
            });
            reportletConfWin.show(target);
        }
    });

    profile.add(new AjaxLink<Void>(EDIT_BUTTON_ID) {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            if (reportlets.getModelObject() != null) {
                reportletConfWin.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = -7834632442532690940L;

                    @Override
                    public Page createPage() {
                        modalReportletConfOldName = reportlets.getModelObject().getName();
                        modalReportletConf = null;
                        return new ReportletConfModalPage(reportlets.getModelObject(), reportletConfWin,
                                ReportModalPage.this.getPageReference());
                    }
                });
                reportletConfWin.show(target);
            }
        }
    });

    profile.add(new AjaxLink<Void>(REMOVE_BUTTON_ID) {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            reportTO.getReportletConfs().remove(reportlets.getModelObject());
            reportlets.setModelObject(null);
            target.add(reportlets);
        }

        @Override
        protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
            if (reportlets.getModelObject() != null) {

                super.updateAjaxAttributes(attributes);

                final AjaxCallListener ajaxCallListener = new AjaxCallListener() {

                    private static final long serialVersionUID = 7160235486520935153L;

                    @Override
                    public CharSequence getPrecondition(final Component component) {
                        return "if (!confirm('" + getString("confirmDelete") + "')) {return false;}";
                    }
                };
                attributes.getAjaxCallListeners().add(ajaxCallListener);
            }
        }
    });

    profile.add(new AjaxLink<Void>(UP_BUTTON_ID) {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            if (reportlets.getModelObject() != null) {
                moveUp(reportlets.getModelObject());
                target.add(reportlets);
            }
        }
    });

    profile.add(new AjaxLink<Void>(DOWN_BUTTON_ID) {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            if (reportlets.getModelObject() != null) {
                moveDown(reportlets.getModelObject());
                target.add(reportlets);
            }
        }
    });
}

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

License:Apache License

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

    add(createResourceWin = new ModalWindow("createResourceWin"));
    add(editResourceWin = new ModalWindow("editResourceWin"));
    add(createConnectorWin = new ModalWindow("createConnectorWin"));
    add(editConnectorWin = new ModalWindow("editConnectorWin"));

    statusmodal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    statusmodal.setInitialHeight(STATUS_MODAL_WIN_HEIGHT);
    statusmodal.setInitialWidth(STATUS_MODAL_WIN_WIDTH);
    statusmodal.setCookieName("status-modal");
    add(statusmodal);//from  w  w w . j  a  v  a 2s  .co  m

    AjaxLink<Void> reloadLink = new ClearIndicatingAjaxLink<Void>("reloadLink", getPageReference()) {

        private static final long serialVersionUID = 3109256773218160485L;

        @Override
        protected void onClickInternal(final AjaxRequestTarget target) {
            try {
                connectorRestClient.reload();
                info(getString(Constants.OPERATION_SUCCEEDED));
            } catch (Exception e) {
                error(getString(Constants.ERROR) + ": " + e.getMessage());
            }
            feedbackPanel.refresh(target);
            target.add(connectorContainer);
        }

        @Override
        protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);

            final AjaxCallListener ajaxCallListener = new AjaxCallListener() {

                private static final long serialVersionUID = 7160235486520935153L;

                @Override
                public CharSequence getPrecondition(final Component component) {
                    return "if (!confirm('" + getString("confirmReloadConnectors") + "')) "
                            + "{return false;} else {return true;}";
                }
            };
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(reloadLink, ENABLE,
            xmlRolesReader.getEntitlement("Connectors", "reload"));
    add(reloadLink);

    resourcePaginatorRows = prefMan.getPaginatorRows(getRequest(), Constants.PREF_RESOURCES_PAGINATOR_ROWS);
    connectorPaginatorRows = prefMan.getPaginatorRows(getRequest(), Constants.PREF_CONNECTORS_PAGINATOR_ROWS);

    setupResources();
    setupConnectors();
}

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

License:Apache License

private ResultStatusModalPage(final Builder builder) {
    super();//www.  ja v  a2  s  . com
    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);//  ww w.  j  a v  a2s  .  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.Todo.java

License:Apache License

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

    add(window = new ModalWindow("editApprovalWin"));

    container = new WebMarkupContainer("approvalContainer");

    MetaDataRoleAuthorizationStrategy.authorize(container, RENDER,
            xmlRolesReader.getEntitlement("Approval", "list"));

    paginatorRows = prefMan.getPaginatorRows(getRequest(), Constants.PREF_TODO_PAGINATOR_ROWS);

    List<IColumn<WorkflowFormTO, String>> columns = new ArrayList<IColumn<WorkflowFormTO, String>>();
    columns.add(new PropertyColumn<WorkflowFormTO, String>(new ResourceModel("taskId"), "taskId", "taskId"));
    columns.add(new PropertyColumn<WorkflowFormTO, String>(new ResourceModel("key"), "key", "key"));
    columns.add(new PropertyColumn<WorkflowFormTO, String>(new ResourceModel("description"), "description",
            "description"));
    columns.add(new DatePropertyColumn<WorkflowFormTO>(new ResourceModel("createTime"), "createTime",
            "createTime"));
    columns.add(new DatePropertyColumn<WorkflowFormTO>(new ResourceModel("dueDate"), "dueDate", "dueDate"));
    columns.add(new PropertyColumn<WorkflowFormTO, String>(new ResourceModel("owner"), "owner", "owner"));
    columns.add(new AbstractColumn<WorkflowFormTO, String>(new ResourceModel("actions", "")) {

        private static final long serialVersionUID = 2054811145491901166L;

        @Override//from  ww w  .  j  a va2 s .  com
        public String getCssClass() {
            return "action";
        }

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

            final WorkflowFormTO formTO = 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) {
                    try {
                        restClient.claimForm(formTO.getTaskId());
                        info(getString(Constants.OPERATION_SUCCEEDED));
                    } catch (SyncopeClientException scee) {
                        error(getString(Constants.ERROR) + ": " + scee.getMessage());
                    }
                    feedbackPanel.refresh(target);
                    target.add(container);
                }
            }, ActionLink.ActionType.CLAIM, "Approval");

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

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

                        private static final long serialVersionUID = -7834632442532690940L;

                        @Override
                        public Page createPage() {
                            return new ApprovalModalPage(Todo.this.getPageReference(), window, formTO);
                        }
                    });

                    window.show(target);
                }
            }, ActionLink.ActionType.EDIT, "Approval",
                    SyncopeSession.get().getUsername().equals(formTO.getOwner()));

            cellItem.add(panel);
        }
    });

    final AjaxFallbackDefaultDataTable<WorkflowFormTO, String> approvalTable = new AjaxFallbackDefaultDataTable<WorkflowFormTO, String>(
            "approvalTable", columns, new ApprovalProvider(), paginatorRows);
    container.add(approvalTable);

    container.setOutputMarkupId(true);
    add(container);

    @SuppressWarnings("rawtypes")
    Form approvalPaginatorForm = new Form("paginatorForm");

    MetaDataRoleAuthorizationStrategy.authorize(approvalPaginatorForm, RENDER,
            xmlRolesReader.getEntitlement("Approval", "list"));

    @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(getRequest(), getResponse(), Constants.PREF_TODO_PAGINATOR_ROWS,
                    String.valueOf(paginatorRows));
            approvalTable.setItemsPerPage(paginatorRows);

            target.add(container);
        }
    });

    approvalPaginatorForm.add(rowsChooser);
    add(approvalPaginatorForm);

    window.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    window.setInitialHeight(WIN_HEIGHT);
    window.setInitialWidth(WIN_WIDTH);
    window.setCookieName("edit-approval-modal");

    setWindowClosedCallback(window, container);
}

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);// www . ja v a 2s .c  o m

    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);
}