Search in sources :

Example 11 with FormItemContainer

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

the class TrueFalseEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FormLayoutContainer metadata = FormLayoutContainer.createDefaultFormLayout("metadata", getTranslator());
    if (itemBuilder.getQuestionType() == QTI21QuestionType.matchdraganddrop) {
        metadata.setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_draganddrop");
    } else {
        metadata.setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_match");
    }
    metadata.setRootForm(mainForm);
    formLayout.add(metadata);
    formLayout.add("metadata", metadata);
    titleEl = uifactory.addTextElement("title", "form.imd.title", -1, itemBuilder.getTitle(), metadata);
    titleEl.setElementCssClass("o_sel_assessment_item_title");
    titleEl.setMandatory(true);
    titleEl.setEnabled(!readOnly);
    String description = itemBuilder.getQuestion();
    textEl = uifactory.addRichTextElementForQTI21("desc", "form.imd.descr", description, 8, -1, itemContainer, metadata, ureq.getUserSession(), getWindowControl());
    textEl.setEnabled(!readOnly);
    textEl.setVisible(!readOnly);
    if (readOnly) {
        FlowFormItem textReadOnlyEl = new FlowFormItem("descro", itemFile);
        textReadOnlyEl.setLabel("form.imd.descr", null);
        textReadOnlyEl.setBlocks(itemBuilder.getQuestionBlocks());
        textReadOnlyEl.setMapperUri(mapperUri);
        metadata.add(textReadOnlyEl);
    }
    // responses
    String page = velocity_root + "/match_truefalse.html";
    answersCont = FormLayoutContainer.createCustomFormLayout("answers", getTranslator(), page);
    answersCont.setRootForm(mainForm);
    answersCont.contextPut("showHeaders", (itemBuilder.getQuestionType() == QTI21QuestionType.matchdraganddrop));
    formLayout.add(answersCont);
    formLayout.add("answers", answersCont);
    MatchInteraction interaction = itemBuilder.getMatchInteraction();
    if (interaction != null) {
        List<SimpleAssociableChoice> sourceChoices = itemBuilder.getSourceChoices();
        for (SimpleAssociableChoice sourceChoice : sourceChoices) {
            wrapSource(ureq, sourceChoice, sourceWrappers);
        }
        List<TargetWrapper> targetChoices = itemBuilder.getTargetChoices().stream().map(c -> new TargetWrapper(c)).collect(Collectors.toList());
        answersCont.contextPut("targetChoices", targetChoices);
    }
    answersCont.contextPut("sourceChoices", sourceWrappers);
    answersCont.contextPut("restrictedEdit", restrictedEdit || readOnly);
    answersCont.contextPut("responseIdentifier", itemBuilder.getResponseIdentifier());
    int maxAssociations = itemBuilder.getMatchInteraction().getMaxAssociations();
    answersCont.contextPut("interactionMaxAssociations", maxAssociations);
    JSAndCSSFormItem js = new JSAndCSSFormItem("js", new String[] { "js/jquery/qti/jquery.match.js" });
    formLayout.add(js);
    if (!readOnly) {
        uifactory.addFormSubmitButton("submit", answersCont);
    }
    if (!restrictedEdit && !readOnly) {
        addRowButton = uifactory.addFormLink("add.match.row", answersCont, Link.BUTTON);
        addRowButton.setElementCssClass("o_sel_match_add_row");
        addRowButton.setIconLeftCSS("o_icon o_icon_add");
    }
}
Also used : MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) Util(org.olat.core.util.Util) AssessmentItemFactory.createSimpleAssociableChoice(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createSimpleAssociableChoice) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) HashMap(java.util.HashMap) QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType) FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) Map(java.util.Map) JSAndCSSFormItem(org.olat.core.gui.components.htmlheader.jscss.JSAndCSSFormItem) AssessmentTestEditorController(org.olat.ims.qti21.ui.editor.AssessmentTestEditorController) FlowStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic) Link(org.olat.core.gui.components.link.Link) WindowControl(org.olat.core.gui.control.WindowControl) ResourcesMapper(org.olat.ims.qti21.ui.ResourcesMapper) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) FlowFormItem(org.olat.ims.qti21.ui.components.FlowFormItem) Collectors(java.util.stream.Collectors) Controller(org.olat.core.gui.control.Controller) CodeHelper(org.olat.core.util.CodeHelper) File(java.io.File) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) VFSContainer(org.olat.core.util.vfs.VFSContainer) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) List(java.util.List) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) UserRequest(org.olat.core.gui.UserRequest) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FlowFormItem(org.olat.ims.qti21.ui.components.FlowFormItem) AssessmentItemFactory.createSimpleAssociableChoice(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createSimpleAssociableChoice) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) JSAndCSSFormItem(org.olat.core.gui.components.htmlheader.jscss.JSAndCSSFormItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 12 with FormItemContainer

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

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 13 with FormItemContainer

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

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 14 with FormItemContainer

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

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)

Example 15 with FormItemContainer

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

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)

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