Search in sources :

Example 6 with FormItemContainer

use of org.olat.core.gui.components.form.flexible.FormItemContainer in project openolat by klemens.

the class MediaCenterController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (select) {
        newMediaCallout = uifactory.addFormLink("new.medias", formLayout, Link.BUTTON);
        newMediaCallout.setIconRightCSS("o_icon o_icon_caret o_icon-fw");
    }
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, MediaCols.key, "select"));
    Map<String, MediaHandler> handlersMap = portfolioService.getMediaHandlers().stream().collect(Collectors.toMap(h -> h.getType(), h -> h));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MediaCols.type, new MediaTypeCellRenderer(handlersMap)));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MediaCols.title, "select"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MediaCols.collectionDate, "select"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MediaCols.categories, new CategoriesCellRenderer()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("select", translate("select"), "select"));
    model = new MediaDataModel(columnsModel, getLocale());
    tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
    tableEl.setAvailableRendererTypes(FlexiTableRendererType.custom, FlexiTableRendererType.classic);
    tableEl.setRendererType(FlexiTableRendererType.custom);
    tableEl.setSearchEnabled(true);
    tableEl.setCustomizeColumns(true);
    tableEl.setEmtpyTableMessageKey("table.sEmptyTable");
    tableEl.setPageSize(24);
    VelocityContainer row = createVelocityContainer("media_row");
    // sets its own DOM id in velocity container
    row.setDomReplacementWrapperRequired(false);
    tableEl.setRowRenderer(row, this);
    tableEl.setCssDelegate(new MediaCssDelegate());
    tableEl.setAndLoadPersistedPreferences(ureq, "media-list");
    initSorters(tableEl);
    initFilters(tableEl);
    mapperThumbnailUrl = registerCacheableMapper(ureq, "media-thumbnail", new ThumbnailMapper(model));
    row.contextPut("mapperThumbnailUrl", mapperThumbnailUrl);
}
Also used : FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement) EPArtefactListChoosenEvent(org.olat.portfolio.ui.artefacts.view.EPArtefactListChoosenEvent) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) Autowired(org.springframework.beans.factory.annotation.Autowired) MediaResource(org.olat.core.gui.media.MediaResource) OLATResourceable(org.olat.core.id.OLATResourceable) Size(org.olat.core.commons.services.image.Size) Media(org.olat.modules.portfolio.Media) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) OresHelper(org.olat.core.util.resource.OresHelper) MediaRow(org.olat.modules.portfolio.ui.model.MediaRow) Map(java.util.Map) SortKey(org.olat.core.commons.persistence.SortKey) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) CalloutSettings(org.olat.core.gui.control.generic.closablewrapper.CalloutSettings) MediaCols(org.olat.modules.portfolio.ui.MediaDataModel.MediaCols) MediaHandler(org.olat.modules.portfolio.MediaHandler) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort) WindowControl(org.olat.core.gui.control.WindowControl) FlexiTableRendererType(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableRendererType) PortfolioModule(org.olat.portfolio.PortfolioModule) Set(java.util.Set) MediaEvent(org.olat.modules.portfolio.ui.event.MediaEvent) Component(org.olat.core.gui.components.Component) LinkFactory(org.olat.core.gui.components.link.LinkFactory) Collectors(java.util.stream.Collectors) Mapper(org.olat.core.dispatcher.mapper.Mapper) DefaultFlexiTableCssDelegate(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiTableCssDelegate) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) BasicController(org.olat.core.gui.control.controller.BasicController) List(java.util.List) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Align(org.olat.core.gui.components.stack.TooledStackedPanel.Align) TooledController(org.olat.core.gui.components.stack.TooledController) CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController) TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) CategoryLight(org.olat.modules.portfolio.model.CategoryLight) CategoriesCellRenderer(org.olat.modules.portfolio.ui.component.CategoriesCellRenderer) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) CollectCitationMediaController(org.olat.modules.portfolio.ui.media.CollectCitationMediaController) EPArtefactChoosenEvent(org.olat.portfolio.ui.artefacts.view.EPArtefactChoosenEvent) FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Event(org.olat.core.gui.control.Event) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) HttpServletRequest(javax.servlet.http.HttpServletRequest) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) ContextEntry(org.olat.core.id.context.ContextEntry) EPArtefactPoolRunController(org.olat.portfolio.ui.EPArtefactPoolRunController) StringHelper(org.olat.core.util.StringHelper) StateEntry(org.olat.core.id.context.StateEntry) FlexiTableDataModelFactory(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModelFactory) PortfolioService(org.olat.modules.portfolio.PortfolioService) OrderBy(org.olat.repository.model.SearchMyRepositoryEntryViewParams.OrderBy) Link(org.olat.core.gui.components.link.Link) FlexiTableComponentDelegate(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableComponentDelegate) CollectTextMediaController(org.olat.modules.portfolio.ui.media.CollectTextMediaController) FlexiTableSearchEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent) MediaSelectionEvent(org.olat.modules.portfolio.ui.event.MediaSelectionEvent) Controller(org.olat.core.gui.control.Controller) MediaLight(org.olat.modules.portfolio.MediaLight) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager) FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) VFSMediaResource(org.olat.core.util.vfs.VFSMediaResource) MediaTypeCellRenderer(org.olat.modules.portfolio.ui.renderer.MediaTypeCellRenderer) UserRequest(org.olat.core.gui.UserRequest) MediaTypeCellRenderer(org.olat.modules.portfolio.ui.renderer.MediaTypeCellRenderer) MediaHandler(org.olat.modules.portfolio.MediaHandler) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) CategoriesCellRenderer(org.olat.modules.portfolio.ui.component.CategoriesCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 7 with FormItemContainer

use of org.olat.core.gui.components.form.flexible.FormItemContainer in project openolat by klemens.

the class MediaDetailsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("title", StringHelper.escapeHtml(media.getTitle()));
        layoutCont.contextPut("description", StringHelper.xssScan(media.getDescription()));
        layoutCont.contextPut("iconCssClass", handler.getIconCssClass(media));
        mediaCtrl = handler.getMediaController(ureq, getWindowControl(), media, new StandardMediaRenderingHints());
        if (mediaCtrl != null) {
            listenTo(mediaCtrl);
            layoutCont.put("media", mediaCtrl.getInitialComponent());
        }
        String metaPage = velocity_root + "/media_details_metadata.html";
        FormLayoutContainer metaCont = FormLayoutContainer.createCustomFormLayout("meta", getTranslator(), metaPage);
        layoutCont.add("meta", metaCont);
        metaCont.setRootForm(mainForm);
        metaCont.contextPut("media", media);
        String author = userManager.getUserDisplayName(media.getAuthor());
        metaCont.contextPut("author", author);
        if (media.getCollectionDate() != null) {
            String collectionDate = Formatter.getInstance(getLocale()).formatDate(media.getCollectionDate());
            metaCont.contextPut("collectionDate", collectionDate);
        }
        if (media.getBusinessPath() != null) {
            gotoOriginalLink = LinkFactory.createLink("goto.original", metaCont.getFormItemComponent(), this);
        }
        if (StringHelper.containsNonWhitespace(media.getMetadataXml())) {
            Object metadata = MetadataXStream.get().fromXML(media.getMetadataXml());
            metaCont.contextPut("metadata", metadata);
        }
        List<Category> categories = portfolioService.getCategories(media);
        if (categories != null && categories.size() > 0) {
            Map<String, String> categoriesMap = categories.stream().collect(Collectors.toMap(c -> c.getName(), c -> c.getName()));
            TextBoxListElement categoriesEl = uifactory.addTextBoxListElement("categories", "categories", "categories.hint", categoriesMap, metaCont, getTranslator());
            categoriesEl.setHelpText(translate("categories.hint"));
            categoriesEl.setElementCssClass("o_sel_ep_tagsinput");
            categoriesEl.setEnabled(false);
        }
        List<FormLink> binderLinks = new ArrayList<>(usedInList.size());
        Set<Long> binderUniqueKeys = new HashSet<>();
        for (BinderPageUsage binder : usedInList) {
            if (binderUniqueKeys.contains(binder.getBinderKey()))
                continue;
            FormLink link;
            if (binder.getBinderKey() == null) {
                link = uifactory.addFormLink("binder_" + (++counter), "page", binder.getPageTitle(), null, metaCont, Link.LINK | Link.NONTRANSLATED);
                binderUniqueKeys.add(binder.getPageKey());
            } else {
                link = uifactory.addFormLink("binder_" + (++counter), "binder", binder.getBinderTitle(), null, metaCont, Link.LINK | Link.NONTRANSLATED);
                binderUniqueKeys.add(binder.getBinderKey());
            }
            link.setUserObject(binder);
            binderLinks.add(link);
        }
        metaCont.contextPut("binderLinks", binderLinks);
    }
}
Also used : BinderPageUsage(org.olat.modules.portfolio.model.BinderPageUsage) TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) Autowired(org.springframework.beans.factory.annotation.Autowired) FormItem(org.olat.core.gui.components.form.flexible.FormItem) TextBoxListElement(org.olat.core.gui.components.form.flexible.elements.TextBoxListElement) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Event(org.olat.core.gui.control.Event) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) Category(org.olat.modules.portfolio.Category) ContextEntry(org.olat.core.id.context.ContextEntry) Media(org.olat.modules.portfolio.Media) Map(java.util.Map) MediaHandler(org.olat.modules.portfolio.MediaHandler) StringHelper(org.olat.core.util.StringHelper) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) StateEntry(org.olat.core.id.context.StateEntry) Formatter(org.olat.core.util.Formatter) PortfolioService(org.olat.modules.portfolio.PortfolioService) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) Link(org.olat.core.gui.components.link.Link) WindowControl(org.olat.core.gui.control.WindowControl) Set(java.util.Set) MediaEvent(org.olat.modules.portfolio.ui.event.MediaEvent) Component(org.olat.core.gui.components.Component) LinkFactory(org.olat.core.gui.components.link.LinkFactory) Collectors(java.util.stream.Collectors) Controller(org.olat.core.gui.control.Controller) UserManager(org.olat.user.UserManager) List(java.util.List) MetadataXStream(org.olat.modules.portfolio.manager.MetadataXStream) NewControllerFactory(org.olat.NewControllerFactory) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Align(org.olat.core.gui.components.stack.TooledStackedPanel.Align) TooledController(org.olat.core.gui.components.stack.TooledController) DialogBoxUIFactory(org.olat.core.gui.control.generic.modal.DialogBoxUIFactory) UserRequest(org.olat.core.gui.UserRequest) PageStatus(org.olat.modules.portfolio.PageStatus) StandardMediaRenderingHints(org.olat.modules.portfolio.model.StandardMediaRenderingHints) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Category(org.olat.modules.portfolio.Category) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) StandardMediaRenderingHints(org.olat.modules.portfolio.model.StandardMediaRenderingHints) BinderPageUsage(org.olat.modules.portfolio.model.BinderPageUsage) TextBoxListElement(org.olat.core.gui.components.form.flexible.elements.TextBoxListElement) HashSet(java.util.HashSet)

Example 8 with FormItemContainer

use of org.olat.core.gui.components.form.flexible.FormItemContainer in project openolat by klemens.

the class SearchInputController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    searchClient = (SearchClient) CoreSpringFactory.getBean("searchClient");
    FormItemContainer searchLayout = formLayout;
    if (displayOption.equals(DisplayOption.STANDARD) || displayOption.equals(DisplayOption.STANDARD_TEXT)) {
        searchLayout = FormLayoutContainer.createInputGroupLayout("searchWrapper", getTranslator(), null, null);
        formLayout.add(searchLayout);
        searchInput = uifactory.addTextElement("search_input", "search.title", 255, "", searchLayout);
        searchInput.setLabel(null, null);
        searchInput.setPlaceholderKey("search", null);
        searchInput.setFocus(true);
    }
    if (displayOption.equals(DisplayOption.STANDARD) || displayOption.equals(DisplayOption.BUTTON)) {
        searchButton = uifactory.addFormLink("rightAddOn", "", "", searchLayout, Link.NONTRANSLATED);
        searchButton.setIconLeftCSS("o_icon o_icon-fw o_icon_search o_icon-lg");
        String searchLabel = getTranslator().translate("search");
        searchButton.setLinkTitle(searchLabel);
    } else if (displayOption.equals(DisplayOption.BUTTON_WITH_LABEL)) {
        searchButton = uifactory.addFormLink("rightAddOn", searchLayout, Link.BUTTON_SMALL);
    } else if (displayOption.equals(DisplayOption.STANDARD_TEXT)) {
        String searchLabel = getTranslator().translate("search");
        searchButton = uifactory.addFormLink("rightAddOn", searchLabel, "", searchLayout, Link.NONTRANSLATED + Link.BUTTON_SMALL);
        searchButton.setIconLeftCSS("o_icon o_icon-fw o_icon_search o_icon-lg");
    }
    searchButton.setCustomEnabledLinkCSS("o_search");
    searchButton.setEnabled(true);
}
Also used : FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer)

Example 9 with FormItemContainer

use of org.olat.core.gui.components.form.flexible.FormItemContainer in project openolat by klemens.

the class ExportOptionsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    downloadOptionsEl = uifactory.addCheckboxesVertical("setting", "form.title", formLayout, optionKeys, optionVals, 1);
    ExportFormat c = FormatConfigHelper.loadExportFormat(ureq);
    if (c.isResponseCols()) {
        downloadOptionsEl.select(ITEMCOLS, c.isResponseCols());
    }
    if (c.isPositionsOfResponsesCol()) {
        downloadOptionsEl.select(POSCOL, c.isPositionsOfResponsesCol());
    }
    if (c.isPointCol()) {
        downloadOptionsEl.select(POINTCOL, c.isPointCol());
    }
    if (c.isTimeCols()) {
        downloadOptionsEl.select(TIMECOLS, c.isTimeCols());
    }
    if (c.isCommentCol()) {
        downloadOptionsEl.select(COMMENTCOL, c.isCommentCol());
    }
    FormItemContainer buttonContainer = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
    formLayout.add(buttonContainer);
    uifactory.addFormCancelButton("cancel", buttonContainer, ureq, getWindowControl());
    uifactory.addFormSubmitButton("save", buttonContainer);
}
Also used : FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer)

Example 10 with FormItemContainer

use of org.olat.core.gui.components.form.flexible.FormItemContainer in project openolat by klemens.

the class FileUploadController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // Trigger fieldset and title
    if (showTitle) {
        setFormTitle("ul.header");
    }
    flc.contextPut("showMetadata", showMetadata);
    // Add file element
    FormItemContainer fileUpload;
    // shown, align the file upload element
    if (showMetadata) {
        fileUpload = FormLayoutContainer.createDefaultFormLayout("file_upload", getTranslator());
    } else {
        fileUpload = FormLayoutContainer.createVerticalFormLayout("file_upload", getTranslator());
    }
    formLayout.add(fileUpload);
    flc.contextPut("resizeImg", resizeImg);
    // Add path element
    if (showTargetPath) {
        String path = "/ " + StringHelper.escapeHtml(uploadVFSContainer.getName());
        VFSContainer container = uploadVFSContainer.getParentContainer();
        while (container != null) {
            path = "/ " + StringHelper.escapeHtml(container.getName()) + " " + path;
            container = container.getParentContainer();
        }
        pathEl = uifactory.addStaticTextElement("ul.target", path, fileUpload);
        if (subfolderPath != null) {
            targetSubPath = uifactory.addInlineTextElement("ul.target.child", subfolderPath, fileUpload, this);
            targetSubPath.setLabel("ul.target.child", null);
        }
    }
    fileEl = uifactory.addFileElement(getWindowControl(), "fileEl", "ul.file", fileUpload);
    fileEl.addActionListener(FormEvent.ONCHANGE);
    setMaxUploadSizeKB((uploadLimitKB < remainingQuotKB ? uploadLimitKB : remainingQuotKB));
    fileEl.setMandatory(true, "NoFileChoosen");
    if (mimeTypes != null && mimeTypes.size() > 0) {
        fileEl.limitToMimeType(mimeTypes, "WrongMimeType", new String[] { mimeTypes.toString() });
    }
    if (resizeImg) {
        FormLayoutContainer resizeCont;
        if (showMetadata) {
            resizeCont = FormLayoutContainer.createDefaultFormLayout("resize_image_wrapper", getTranslator());
        } else {
            resizeCont = FormLayoutContainer.createVerticalFormLayout("resize_image_wrapper", getTranslator());
        }
        formLayout.add(resizeCont);
        String[] values = new String[] { translate("resize_image") };
        resizeEl = uifactory.addCheckboxesHorizontal("resize_image", resizeCont, resizeKeys, values);
        resizeEl.setLabel(null, null);
        resizeEl.select(resizeKeys[0], true);
        resizeEl.setVisible(false);
    }
    // Check remaining quota
    if (remainingQuotKB == 0) {
        fileEl.setEnabled(false);
        getWindowControl().setError(translate("QuotaExceeded"));
    }
    if (showMetadata) {
        metaDataCtr = new MetaInfoFormController(ureq, getWindowControl(), mainForm);
        formLayout.add("metadata", metaDataCtr.getFormItem());
        listenTo(metaDataCtr);
    }
    // Add cancel and submit in button group layout
    FormItemContainer buttons;
    if (showMetadata) {
        buttons = FormLayoutContainer.createDefaultFormLayout("buttons", getTranslator());
    } else {
        buttons = FormLayoutContainer.createVerticalFormLayout("buttons", getTranslator());
    }
    formLayout.add(buttons);
    FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
    buttons.add(buttonGroupLayout);
    buttonGroupLayout.setElementCssClass("o_sel_upload_buttons");
    uifactory.addFormSubmitButton("ul.upload", buttonGroupLayout);
    if (showCancel) {
        uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
    }
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) MetaInfoFormController(org.olat.core.commons.modules.bc.meta.MetaInfoFormController) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer)

Aggregations

FormItemContainer (org.olat.core.gui.components.form.flexible.FormItemContainer)18 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Map (java.util.Map)6 Collectors (java.util.stream.Collectors)6 UserRequest (org.olat.core.gui.UserRequest)6 FormItem (org.olat.core.gui.components.form.flexible.FormItem)6 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)6 FormBasicController (org.olat.core.gui.components.form.flexible.impl.FormBasicController)6 FormEvent (org.olat.core.gui.components.form.flexible.impl.FormEvent)6 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)6 Link (org.olat.core.gui.components.link.Link)6 Controller (org.olat.core.gui.control.Controller)6 WindowControl (org.olat.core.gui.control.WindowControl)6 HashSet (java.util.HashSet)4 Set (java.util.Set)4 Component (org.olat.core.gui.components.Component)4 LinkFactory (org.olat.core.gui.components.link.LinkFactory)4 TooledController (org.olat.core.gui.components.stack.TooledController)4 TooledStackedPanel (org.olat.core.gui.components.stack.TooledStackedPanel)4