Search in sources :

Example 1 with OmOrderByBorder

use of org.apache.openmeetings.web.data.OmOrderByBorder in project openmeetings by apache.

the class OAuthPanel method onInitialize.

@Override
protected void onInitialize() {
    SearchableDataView<OAuthServer> dataView = new SearchableDataView<OAuthServer>("oauthServersList", new SearchableDataProvider<>(OAuth2Dao.class)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(Item<OAuthServer> item) {
            final OAuthServer server = item.getModelObject();
            item.add(new Label("id"));
            item.add(new Label("name"));
            item.add(new AjaxEventBehavior(EVT_CLICK) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    form.setModelObject(server);
                    form.hideNewRecord();
                    target.add(form, listContainer);
                    reinitJs(target);
                }
            });
            item.add(AttributeModifier.replace(ATTR_CLASS, getRowClass(server.getId(), form.getModelObject().getId())));
        }
    };
    add(listContainer.add(dataView).setOutputMarkupId(true));
    PagedEntityListPanel navigator = new PagedEntityListPanel("navigator", dataView) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            target.add(listContainer);
        }
    };
    DataViewContainer<OAuthServer> container = new DataViewContainer<>(listContainer, dataView, navigator);
    container.addLink(new OmOrderByBorder<>("orderById", "id", container)).addLink(new OmOrderByBorder<>("orderByName", "name", container));
    add(container.getLinks());
    add(navigator);
    form = new OAuthForm("form", listContainer, new OAuthServer());
    form.showNewRecord();
    add(form);
    super.onInitialize();
}
Also used : AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) Label(org.apache.wicket.markup.html.basic.Label) OAuthServer(org.apache.openmeetings.db.entity.server.OAuthServer) OAuth2Dao(org.apache.openmeetings.db.dao.server.OAuth2Dao) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SearchableDataView(org.apache.openmeetings.web.admin.SearchableDataView) Item(org.apache.wicket.markup.repeater.Item) PagedEntityListPanel(org.apache.openmeetings.web.common.PagedEntityListPanel) OmOrderByBorder(org.apache.openmeetings.web.data.OmOrderByBorder) DataViewContainer(org.apache.openmeetings.web.data.DataViewContainer)

Example 2 with OmOrderByBorder

use of org.apache.openmeetings.web.data.OmOrderByBorder in project openmeetings by apache.

the class LangPanel method onInitialize.

@Override
protected void onInitialize() {
    // Create feedback panels
    add(feedback.setOutputMarkupId(true));
    language = new AbstractMap.SimpleEntry<>(1L, Locale.ENGLISH);
    final LabelsForm form = new LabelsForm("form", this, new StringLabel(null, null));
    form.showNewRecord();
    add(form);
    final SearchableDataView<StringLabel> dataView = new SearchableDataView<StringLabel>("langList", new SearchableDataProvider<StringLabel>(LabelDao.class) {

        private static final long serialVersionUID = 1L;

        @Override
        public long size() {
            return LabelDao.count(language.getValue(), search);
        }

        @Override
        public Iterator<? extends StringLabel> iterator(long first, long count) {
            return LabelDao.get(language.getValue(), search, (int) first, (int) count, getSort()).iterator();
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<StringLabel> item) {
            final StringLabel fv = item.getModelObject();
            item.add(new Label("key"));
            item.add(new Label("value"));
            item.add(new AjaxEventBehavior(EVT_CLICK) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    form.setModelObject(fv);
                    form.hideNewRecord();
                    target.add(form, listContainer);
                    reinitJs(target);
                }
            });
            item.add(AttributeModifier.append(ATTR_CLASS, getRowClass(fv.getId(), form.getModelObject().getId())));
        }
    };
    add(listContainer.add(dataView).setOutputMarkupId(true));
    PagedEntityListPanel navigator = new PagedEntityListPanel("navigator", dataView) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            dataView.modelChanging();
            target.add(listContainer);
        }
    };
    DataViewContainer<StringLabel> container = new DataViewContainer<>(listContainer, dataView, navigator);
    container.addLink(new OmOrderByBorder<>("orderByName", "key", container)).addLink(new OmOrderByBorder<>("orderByValue", "value", container));
    add(container.getLinks());
    add(navigator);
    langForm = new LangForm("langForm", listContainer, this);
    langForm.add(fileUploadField);
    langForm.add(new UploadProgressBar("progress", langForm, fileUploadField));
    fileUploadField.add(new AjaxFormSubmitBehavior(langForm, "change") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            FileUpload download = fileUploadField.getFileUpload();
            try {
                if (download == null || download.getInputStream() == null) {
                    feedback.error("File is empty");
                    return;
                }
                LabelDao.upload(language.getValue(), download.getInputStream());
            } catch (Exception e) {
                log.error("Exception on panel language editor import ", e);
                feedback.error(e);
            }
            // repaint the feedback panel so that it is hidden
            target.add(listContainer, feedback);
        }
    });
    // Add a component to download a file without page refresh
    final AjaxDownloadBehavior download = new AjaxDownloadBehavior(new ResourceStreamResource() {

        private static final long serialVersionUID = 1L;

        {
            setContentDisposition(ATTACHMENT);
            setCacheDuration(NONE);
        }

        @Override
        protected IResourceStream getResourceStream(Attributes attributes) {
            final String name = LabelDao.getLabelFileName(language.getValue());
            setFileName(name);
            return new AbstractResourceStream() {

                private static final long serialVersionUID = 1L;

                private transient InputStream is;

                @Override
                public InputStream getInputStream() throws ResourceStreamNotFoundException {
                    try {
                        is = Application.class.getResourceAsStream(name);
                        return is;
                    } catch (Exception e) {
                        throw new ResourceStreamNotFoundException(e);
                    }
                }

                @Override
                public void close() throws IOException {
                    if (is != null) {
                        is.close();
                        is = null;
                    }
                }
            };
        }
    });
    langForm.add(download);
    langForm.add(new AjaxButton("export") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            download.initiate(target);
            // repaint the feedback panel so that it is hidden
            target.add(feedback);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            // repaint the feedback panel so errors are shown
            target.add(feedback);
        }
    });
    add(langForm);
    final AddLanguageDialog addLang = new AddLanguageDialog("addLang", this);
    add(addLang, new AjaxLink<Void>("addLangBtn") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addLang.open(target);
        }
    });
    add(BootstrapFileUploadBehavior.INSTANCE);
    add(new ConfirmableAjaxBorder("deleteLangBtn", getString("80"), getString("833")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            LabelDao.delete(language.getValue());
            List<Map.Entry<Long, Locale>> langs = LangForm.getLanguages();
            language = langs.isEmpty() ? null : langs.get(0);
            langForm.updateLanguages(target);
            target.add(listContainer);
        }
    });
    super.onInitialize();
}
Also used : Locale(java.util.Locale) StringLabel(org.apache.openmeetings.db.entity.label.StringLabel) Label(org.apache.wicket.markup.html.basic.Label) StringLabel(org.apache.openmeetings.db.entity.label.StringLabel) LabelDao(org.apache.openmeetings.db.dao.label.LabelDao) AbstractMap(java.util.AbstractMap) SearchableDataView(org.apache.openmeetings.web.admin.SearchableDataView) Item(org.apache.wicket.markup.repeater.Item) AjaxFormSubmitBehavior(org.apache.wicket.ajax.form.AjaxFormSubmitBehavior) AjaxButton(com.googlecode.wicket.jquery.ui.form.button.AjaxButton) ResourceStreamResource(org.apache.wicket.request.resource.ResourceStreamResource) Iterator(java.util.Iterator) List(java.util.List) ResourceStreamNotFoundException(org.apache.wicket.util.resource.ResourceStreamNotFoundException) UploadProgressBar(org.apache.wicket.extensions.ajax.markup.html.form.upload.UploadProgressBar) FileUpload(org.apache.wicket.markup.html.form.upload.FileUpload) AbstractResourceStream(org.apache.wicket.util.resource.AbstractResourceStream) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) IResourceStream(org.apache.wicket.util.resource.IResourceStream) InputStream(java.io.InputStream) ConfirmableAjaxBorder(org.apache.openmeetings.web.common.ConfirmableAjaxBorder) IOException(java.io.IOException) IOException(java.io.IOException) ResourceStreamNotFoundException(org.apache.wicket.util.resource.ResourceStreamNotFoundException) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PagedEntityListPanel(org.apache.openmeetings.web.common.PagedEntityListPanel) OmOrderByBorder(org.apache.openmeetings.web.data.OmOrderByBorder) Map(java.util.Map) AbstractMap(java.util.AbstractMap) DataViewContainer(org.apache.openmeetings.web.data.DataViewContainer) AjaxDownloadBehavior(org.apache.wicket.extensions.ajax.AjaxDownloadBehavior)

Example 3 with OmOrderByBorder

use of org.apache.openmeetings.web.data.OmOrderByBorder in project openmeetings by apache.

the class ConfigsPanel method onInitialize.

@Override
protected void onInitialize() {
    SearchableDataView<Configuration> dataView = new SearchableDataView<Configuration>("configList", new SearchableDataProvider<>(ConfigurationDao.class)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<Configuration> item) {
            final Configuration c = item.getModelObject();
            item.add(new Label("id"));
            item.add(new Label("key"));
            item.add(new Label("value"));
            item.add(new AjaxEventBehavior(EVT_CLICK) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    form.hideNewRecord();
                    form.setModelObject(c);
                    target.add(form, listContainer);
                    reinitJs(target);
                }
            });
            item.add(AttributeModifier.replace(ATTR_CLASS, getRowClass(c.getId(), form.getModelObject().getId())));
        }
    };
    add(listContainer.add(dataView).setOutputMarkupId(true));
    PagedEntityListPanel navigator = new PagedEntityListPanel("navigator", dataView) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            target.add(listContainer);
        }
    };
    DataViewContainer<Configuration> container = new DataViewContainer<>(listContainer, dataView, navigator);
    container.addLink(new OmOrderByBorder<>("orderById", "id", container)).addLink(new OmOrderByBorder<>("orderByKey", "key", container)).addLink(new OmOrderByBorder<>("orderByValue", "value", container));
    add(container.getLinks());
    add(navigator);
    form = new ConfigForm("form", listContainer, new Configuration());
    form.showNewRecord();
    add(form);
    super.onInitialize();
}
Also used : ConfigurationDao(org.apache.openmeetings.db.dao.basic.ConfigurationDao) Configuration(org.apache.openmeetings.db.entity.basic.Configuration) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) Label(org.apache.wicket.markup.html.basic.Label) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SearchableDataView(org.apache.openmeetings.web.admin.SearchableDataView) Item(org.apache.wicket.markup.repeater.Item) PagedEntityListPanel(org.apache.openmeetings.web.common.PagedEntityListPanel) OmOrderByBorder(org.apache.openmeetings.web.data.OmOrderByBorder) DataViewContainer(org.apache.openmeetings.web.data.DataViewContainer)

Example 4 with OmOrderByBorder

use of org.apache.openmeetings.web.data.OmOrderByBorder in project openmeetings by apache.

the class LdapsPanel method onInitialize.

@Override
protected void onInitialize() {
    SearchableDataView<LdapConfig> dataView = new SearchableDataView<LdapConfig>("ldapList", new SearchableDataProvider<>(LdapConfigDao.class)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<LdapConfig> item) {
            final LdapConfig lc = item.getModelObject();
            item.add(new Label("id"));
            item.add(new Label("name"));
            item.add(new Label("configFileName"));
            item.add(new AjaxEventBehavior(EVT_CLICK) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    form.setModelObject(lc);
                    form.hideNewRecord();
                    target.add(form, listContainer);
                    reinitJs(target);
                }
            });
            item.add(AttributeModifier.replace(ATTR_CLASS, getRowClass(lc.getId(), form.getModelObject().getId())));
        }
    };
    add(listContainer.add(dataView).setOutputMarkupId(true));
    PagedEntityListPanel navigator = new PagedEntityListPanel("navigator", dataView) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            target.add(listContainer);
        }
    };
    DataViewContainer<LdapConfig> container = new DataViewContainer<>(listContainer, dataView, navigator);
    container.addLink(new OmOrderByBorder<>("orderById", "id", container)).addLink(new OmOrderByBorder<>("orderByName", "name", container)).addLink(new OmOrderByBorder<>("orderByFile", "configFileName", container));
    add(container.getLinks());
    add(navigator);
    form = new LdapForm("form", listContainer, new LdapConfig());
    form.showNewRecord();
    add(form);
    super.onInitialize();
}
Also used : AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) Label(org.apache.wicket.markup.html.basic.Label) LdapConfig(org.apache.openmeetings.db.entity.server.LdapConfig) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SearchableDataView(org.apache.openmeetings.web.admin.SearchableDataView) Item(org.apache.wicket.markup.repeater.Item) PagedEntityListPanel(org.apache.openmeetings.web.common.PagedEntityListPanel) OmOrderByBorder(org.apache.openmeetings.web.data.OmOrderByBorder) LdapConfigDao(org.apache.openmeetings.db.dao.server.LdapConfigDao) DataViewContainer(org.apache.openmeetings.web.data.DataViewContainer)

Aggregations

SearchableDataView (org.apache.openmeetings.web.admin.SearchableDataView)4 PagedEntityListPanel (org.apache.openmeetings.web.common.PagedEntityListPanel)4 DataViewContainer (org.apache.openmeetings.web.data.DataViewContainer)4 OmOrderByBorder (org.apache.openmeetings.web.data.OmOrderByBorder)4 AjaxEventBehavior (org.apache.wicket.ajax.AjaxEventBehavior)4 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)4 Label (org.apache.wicket.markup.html.basic.Label)4 Item (org.apache.wicket.markup.repeater.Item)4 AjaxButton (com.googlecode.wicket.jquery.ui.form.button.AjaxButton)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 AbstractMap (java.util.AbstractMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 ConfigurationDao (org.apache.openmeetings.db.dao.basic.ConfigurationDao)1 LabelDao (org.apache.openmeetings.db.dao.label.LabelDao)1 LdapConfigDao (org.apache.openmeetings.db.dao.server.LdapConfigDao)1 OAuth2Dao (org.apache.openmeetings.db.dao.server.OAuth2Dao)1