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

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

Introduction

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

Prototype

public ModalWindow setPageCreator(final PageCreator creator) 

Source Link

Document

Sets the PageCreator instance.

Usage

From source file:edu.wfu.inotado.tool.pages.SchoolChaptersPage.java

License:Apache License

public SchoolChaptersPage() {
    disableLink(schoolChaptersLink);//from  w w w  . j  a  v  a  2  s  .  c o  m

    // gets the authStore object
    AuthStore authStore = inotadoService.getAuthStoreForCurrentUser(Constants.SCHOOL_CHAPTERS);
    if (authStore == null) {
        authStore = new AuthStore();
    }

    final Notification notification = new Notification("scNotification");
    this.add(notification);

    // Form
    Form<?> authForm = new Form("authenticationForm");
    this.add(authForm);

    final SchoolChaptersAuthWindow settingWindow = new SchoolChaptersAuthWindow("settingWindow", "Settings",
            authStore);
    this.add(settingWindow);

    final AjaxButton editAuthButton = new AjaxButton("editAuthButton") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            settingWindow.setAuthStore(inotadoService.getAuthStoreForCurrentUser(Constants.SCHOOL_CHAPTERS));
            settingWindow.open(target);
        }
    };
    authForm.add(editAuthButton);

    final ModalWindow authWindow = new ModalWindow("authWindow");
    this.add(authWindow);

    final AjaxButton authButton = new AjaxButton("authButton") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            // retrieve the url for OAuth authentication
            AuthStore authStore = inotadoService.getAuthStoreForCurrentUser(Constants.SCHOOL_CHAPTERS);
            final String authUrl = inotadoService.getSchoolChaptersAuthUrl(authStore);

            if (!StringUtils.isBlank(authUrl)) {
                notification.success(target, "Key and secret have been accepted");
                authWindow.setPageCreator(new ModalWindow.PageCreator() {
                    @Override
                    public Page createPage() {
                        return new RedirectPage(authUrl);
                    }
                });
                authWindow.show(target);
            } else {
                notification.error(target, "Invalid key or secret!");
            }
        }
    };

    authForm.add(authButton);

    final AjaxButton sendRequestButton = new AjaxButton("sendRequestButton") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            try {
                syncResourcesService.syncAssignments();
                notification.success(target, "Data retrived successfully");
            } catch (Exception e) {
                notification.error(target, "Unable to process request. " + e.getMessage());
            }
        }
    };

    authForm.add(sendRequestButton);

}

From source file:net.unit8.longadeseo.page.plugin.PluginListPage.java

License:Apache License

public PluginListPage() {
    add(new Label("pageTitle", "?"));
    pluginRegistryList = pluginRegistryService.findAll();

    final ModalWindow window = new ModalWindow("testWindow");
    window.setTitle("test");
    add(window);/*from  w ww  . j a  v a 2 s . c o  m*/

    add(new ListView<PluginRegistry>("pluginRegistryList", pluginRegistryList) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<PluginRegistry> item) {
            final PluginRegistry pluginRegistry = item.getModelObject();
            Form<PluginRegistry> pluginUpdateForm = new Form<PluginRegistry>("pluginUpdateForm",
                    new CompoundPropertyModel<PluginRegistry>(pluginRegistry));
            item.add(pluginUpdateForm);

            final Model<String> includes = new Model<String>(
                    StringUtils.join(pluginRegistry.getIncludes(), "\n"));
            pluginUpdateForm.add(new Label("name"))
                    .add(new AjaxEditableMultiLineLabel<PluginRegistry>("description") {
                        private static final long serialVersionUID = 1L;

                        @Override
                        protected void onSubmit(AjaxRequestTarget target) {
                            pluginRegistryService.update(pluginRegistry);
                            super.onSubmit(target);
                        }
                    }).add(new Label("pluginClass", pluginRegistry.getPluginClass().getName()))
                    .add(new AjaxEditableMultiLineLabel<String>("pluginIncludes", includes) {
                        private static final long serialVersionUID = 1L;

                        @Override
                        protected void onSubmit(AjaxRequestTarget target) {
                            pluginRegistry.setIncludes(includes.getObject().split("\n"));
                            pluginRegistryService.update(pluginRegistry);
                            super.onSubmit(target);
                        }
                    }).add(new Button("deleteButton") {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onSubmit() {
                            pluginRegistryService.delete(pluginRegistry);
                            pluginRegistryList.remove(pluginRegistry);
                            super.onSubmit();
                        }
                    }).add(new AjaxButton("activeButton",
                            new Model<String>(activeButtonLabel(pluginRegistry.isActive()))) {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onSubmit(AjaxRequestTarget target, Form<?> form) {
                            pluginRegistry.setActive(!pluginRegistry.isActive());
                            this.setModelObject(activeButtonLabel(pluginRegistry.isActive()));
                            pluginRegistryService.update(pluginRegistry);
                            PluginManager pluginManager = (PluginManager) WebApplication.get()
                                    .getServletContext().getAttribute(WebdavServlet.PLUGIN_MANAGER_KEY);
                            pluginManager.loadPlugins();
                            target.add(this);
                        }
                    }.setOutputMarkupId(true)).add(new AjaxButton("testButton") {
                        private static final long serialVersionUID = 1L;

                        @Override
                        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                            window.setPageCreator(new ModalWindow.PageCreator() {
                                private static final long serialVersionUID = 1L;

                                public Page createPage() {
                                    return new PluginTestPage(pluginRegistry);
                                }
                            });
                            window.show(target);
                        }
                    });
            final WebMarkupContainer optionsContainer = new WebMarkupContainer("optionsContainer");
            final ListView<PluginOptionEntry> options = new ListView<PluginOptionEntry>("options",
                    pluginRegistry.getPlugin().getOptions()) {
                private static final long serialVersionUID = 1L;

                @Override
                protected void populateItem(final ListItem<PluginOptionEntry> item) {
                    final PluginOptionEntry option = item.getModelObject();
                    item.add(new Label("name", option.getLabel()));
                    switch (option.getFormType()) {
                    case TEXTAREA:
                        item.add(new AjaxEditableMultiLineLabel<PluginOptionEntry>("value",
                                new PropertyModel<PluginOptionEntry>(option, "value")) {
                            private static final long serialVersionUID = 1L;

                            @Override
                            public void onEdit(AjaxRequestTarget target) {
                                String selector = ".codemirror:eq(" + (item.getIndex() - 1) + ") textarea";
                                target.appendJavaScript("CodeMirror.fromTextArea($('" + selector
                                        + "')[0], {mode: 'text/x-ruby', lineNumbers: true,indentUnit: 2,tabMode: 'shift',matchBrackets: true})"
                                        + ".on('blur', function(cm) { cm.save(); $('" + selector
                                        + "').trigger('blur') });");
                                super.onEdit(target);
                            }

                            @Override
                            protected void onSubmit(AjaxRequestTarget target) {
                                pluginRegistry.getPlugin().setOption(option.getName(),
                                        ValueFactoryImpl.getInstance().createValue(option.getStringValue()));
                                pluginRegistryService.update(pluginRegistry);
                                super.onSubmit(target);
                            }
                        }.add(new AttributeModifier("class", "codemirror")));
                        break;
                    default:
                        item.add(new AjaxEditableLabel<PluginOptionEntry>("value",
                                new PropertyModel<PluginOptionEntry>(option, "value")) {
                            private static final long serialVersionUID = 1L;

                            @Override
                            protected void onSubmit(AjaxRequestTarget target) {
                                pluginRegistry.getPlugin().setOption(option.getName(),
                                        ValueFactoryImpl.getInstance().createValue(option.getStringValue()));
                                pluginRegistryService.update(pluginRegistry);
                                super.onSubmit(target);
                            }
                        });
                        break;
                    }
                }
            };
            optionsContainer.add(options);
            pluginUpdateForm.add(optionsContainer);

        }

    });

    Form<ValueMap> form = new PluginRegistryForm("pluginRegistryForm");
    add(form);
}

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 a va2 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 w  w  w.  j  a v a2  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 ava 2 s . c o m
    form.add(executions);

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

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

        private static final long serialVersionUID = 8804221891699487139L;

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

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

        private static final long serialVersionUID = 2054811145491901166L;

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

            final ReportExecTO taskExecutionTO = model.getObject();

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

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

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

                        private static final long serialVersionUID = -7834632442532690940L;

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

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

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

                        private static final long serialVersionUID = -7834632442532690940L;

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

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

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

                        reportTO.getExecutions().remove(taskExecutionTO);

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

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

            return panel;
        }

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

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -7978723352517770644L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    if (target != null) {
                        final ReportTO currentReportTO = reportTO.getKey() == 0 ? reportTO
                                : reportRestClient.read(reportTO.getKey());
                        reportTO.getExecutions().clear();
                        reportTO.getExecutions().addAll(currentReportTO.getExecutions());
                        final AjaxFallbackDefaultDataTable currentTable = new AjaxFallbackDefaultDataTable(
                                "executionsTable", columns, new ReportExecutionsProvider(reportTO), 10);
                        currentTable.setOutputMarkupId(true);
                        target.add(currentTable);
                        executions.addOrReplace(currentTable);
                    }
                }
            }, ActionLink.ActionType.RELOAD, TASKS, "list");

            return panel;
        }
    });

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

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

License:Apache License

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

    final BaseModalPage page = this;

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

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

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

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

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

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

            private static final long serialVersionUID = -1020475259727720708L;

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

                final ListView attributes = getConnObjectView(propTO);

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

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

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

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

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

                    private static final long serialVersionUID = -7978723352517770644L;

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

                switch (propTO.getStatus()) {

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

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

                image.add(new Behavior() {

                    private static final long serialVersionUID = 1469628524240283489L;

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

                failureWindow.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = -7834632442532690940L;

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

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

        private static final long serialVersionUID = -7978723352517770644L;

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

    setOutputMarkupId(true);
}

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

License:Apache License

private <T extends AbstractSchemaModalPage> List<IColumn> getColumns(final WebMarkupContainer webContainer,
        final ModalWindow modalWindow, final AttributableType attributableType, final SchemaType schemaType,
        final Collection<String> fields) {

    List<IColumn> columns = new ArrayList<IColumn>();

    for (final String field : fields) {
        final Field clazzField = ReflectionUtils.findField(schemaType.getToClass(), field);

        if (clazzField != null) {
            if (clazzField.getType().equals(Boolean.class) || clazzField.getType().equals(boolean.class)) {
                columns.add(new AbstractColumn<AbstractSchemaTO, String>(new ResourceModel(field)) {

                    private static final long serialVersionUID = 8263694778917279290L;

                    @Override/*from w  w w.  j av  a 2 s . co  m*/
                    public void populateItem(final Item<ICellPopulator<AbstractSchemaTO>> item,
                            final String componentId, final IModel<AbstractSchemaTO> model) {

                        BeanWrapper bwi = new BeanWrapperImpl(model.getObject());
                        Object obj = bwi.getPropertyValue(field);

                        item.add(new Label(componentId, ""));
                        item.add(new AttributeModifier("class", new Model<String>(obj.toString())));
                    }

                    @Override
                    public String getCssClass() {
                        return "small_fixedsize";
                    }
                });
            } else {
                IColumn column = new PropertyColumn(new ResourceModel(field), field, field) {

                    private static final long serialVersionUID = 3282547854226892169L;

                    @Override
                    public String getCssClass() {
                        String css = super.getCssClass();
                        if ("key".equals(field)) {
                            css = StringUtils.isBlank(css) ? "medium_fixedsize" : css + " medium_fixedsize";
                        }
                        return css;
                    }
                };
                columns.add(column);
            }
        }
    }

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

        private static final long serialVersionUID = 2054811145491901166L;

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

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

            final AbstractSchemaTO schemaTO = model.getObject();

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

            panel.addWithRoles(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

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

                        private static final long serialVersionUID = -7834632442532690940L;

                        @Override
                        public Page createPage() {
                            AbstractSchemaModalPage page = SchemaModalPageFactory
                                    .getSchemaModalPage(attributableType, schemaType);

                            page.setSchemaModalPage(Schema.this.getPageReference(), modalWindow, schemaTO,
                                    false);

                            return page;
                        }
                    });

                    modalWindow.show(target);
                }
            }, ActionType.EDIT, allowedReadRoles);

            panel.addWithRoles(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

                @Override
                public void onClick(final AjaxRequestTarget target) {

                    switch (schemaType) {
                    case DERIVED:
                        restClient.deleteDerSchema(attributableType, schemaTO.getKey());
                        break;

                    case VIRTUAL:
                        restClient.deleteVirSchema(attributableType, schemaTO.getKey());
                        break;

                    default:
                        restClient.deletePlainSchema(attributableType, schemaTO.getKey());
                        break;
                    }

                    info(getString(Constants.OPERATION_SUCCEEDED));
                    feedbackPanel.refresh(target);

                    target.add(webContainer);
                }
            }, ActionType.DELETE, allowedDeleteRoles);

            item.add(panel);
        }
    });

    return columns;
}

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

License:Apache License

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

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

        private static final long serialVersionUID = -7978723352517770644L;

        @Override//www.j ava2  s.  c  o  m
        protected void onClickInternal(final AjaxRequestTarget target) {
            modalWindow.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

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

                    return page;
                }
            });

            modalWindow.show(target);
        }
    };

    MetaDataRoleAuthorizationStrategy.authorize(link, ENABLE, allowedCreateRoles);

    return link;

}

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

License:Apache License

public TaskModalPage(final AbstractTaskTO taskTO) {
    final ModalWindow taskExecMessageWin = new ModalWindow("taskExecMessageWin");
    taskExecMessageWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    taskExecMessageWin.setCookieName("task-exec-message-win-modal");
    add(taskExecMessageWin);/*from   w w w  .  j av  a2  s  .c  o  m*/

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

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

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

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

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

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

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

    final int paginatorRows = 10;

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

        private static final long serialVersionUID = 2054811145491901166L;

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

            final TaskExecTO taskExecutionTO = model.getObject();

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

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

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

                        private static final long serialVersionUID = -7834632442532690940L;

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

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

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

                        taskTO.getExecutions().remove(taskExecutionTO);

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

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

            return panel;
        }

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

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -7978723352517770644L;

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

            return panel;
        }
    });

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

    executions.add(table);
}

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

License:Apache License

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

    // Modal window for editing user attributes
    final ModalWindow editModalWin = new ModalWindow("editModal");
    editModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editModalWin.setInitialHeight(EDIT_MODAL_WIN_HEIGHT);
    editModalWin.setInitialWidth(EDIT_MODAL_WIN_WIDTH);
    editModalWin.setCookieName("edit-modal");
    add(editModalWin);/*from  w ww .j  ava 2  s.  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);
}