Search in sources :

Example 1 with FormItemContainer

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

the class CPMetadataEditController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_cp_metadata");
    // title-field
    String titleString = page.getTitle();
    title = uifactory.addTextElement("title", "cpmd.flexi.title", 256, titleString, formLayout);
    title.setElementCssClass("o_sel_cp_title");
    title.setDisplaySize(32);
    title.setMandatory(true);
    title.setNotEmptyCheck("cpmd.flexi.mustbefilled");
    FormItemContainer buttonContainer = FormLayoutContainer.createButtonLayout("buttonContainer", getTranslator());
    formLayout.add(buttonContainer);
    uifactory.addFormSubmitButton("save", buttonContainer);
    uifactory.addFormCancelButton("cancel", buttonContainer, ureq, getWindowControl());
}
Also used : FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer)

Example 2 with FormItemContainer

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

the class OAuthAdminController method initCustomProviders.

private void initCustomProviders() {
    // remove old ones
    for (ConfigurableProviderWrapper providerWrapper : providerWrappers) {
        FormItemContainer layoutCont = providerWrapper.getLayoutCont();
        customProvidersCont.remove(layoutCont);
    }
    providerWrappers.clear();
    List<OAuthSPI> configurableSpies = oauthModule.getAllConfigurableSPIs();
    for (OAuthSPI configurableSpi : configurableSpies) {
        if (configurableSpi instanceof OpenIdConnectFullConfigurableProvider) {
            ConfigurableProviderWrapper wrapper = initOpenIDConnectIFFullConfigurableProviders(customProvidersCont, (OpenIdConnectFullConfigurableProvider) configurableSpi);
            if (wrapper != null) {
                providerWrappers.add(wrapper);
            }
        }
    }
}
Also used : OpenIdConnectFullConfigurableProvider(org.olat.login.oauth.spi.OpenIdConnectFullConfigurableProvider) OAuthSPI(org.olat.login.oauth.OAuthSPI) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer)

Example 3 with FormItemContainer

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

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

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

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

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

the class TranslationToolStartCrumbController method initSearchItemsElements.

private void initSearchItemsElements(FormUIFactory formFactory, FormItemContainer formLayout, String[] bundlesKeys, String[] bundlesValues) {
    FormItemContainer searchLayoutContainer = FormLayoutContainer.createDefaultFormLayout("searchLayoutContainer", getTranslator());
    formLayout.add(searchLayoutContainer);
    // Add search input field
    searchInput = formFactory.addTextElement("searchInput", "start.search.input", 100, "", searchLayoutContainer);
    // Add search selecton for searching in keys or values
    String[] searchKeyValueKeys = new String[] { KEYS_KEY, KEYS_VALUE };
    String[] searchKeyValueValues = new String[] { translate("generic.key"), translate("generic.value") };
    searchKeyValueSelection = formFactory.addRadiosHorizontal("searchKeyValueSelection", "start.search.in", searchLayoutContainer, searchKeyValueKeys, searchKeyValueValues);
    searchKeyValueSelection.select(KEYS_VALUE, true);
    // Add search selecton for reference or target search
    String[] searchReferenceTargetKeys = new String[] { KEYS_REFERENCE, KEYS_TARGET };
    String[] searchReferenceTargetValues;
    if (customizingMode) {
        searchReferenceTargetValues = new String[] { translate("generic.customize.lang.reference"), translate("generic.customize.lang.target") };
    } else {
        searchReferenceTargetValues = new String[] { translate("generic.lang.reference"), translate("generic.lang.target") };
    }
    searchReferenceTargetSelection = formFactory.addRadiosHorizontal("searchReferenceTargetSelection", "start.search.in", searchLayoutContainer, searchReferenceTargetKeys, searchReferenceTargetValues);
    searchReferenceTargetSelection.select(KEYS_TARGET, true);
    // Add search bundles selector : reuse keys from above
    searchBundlesSelection = formFactory.addDropdownSingleselect("searchBundlesSelection", searchLayoutContainer, bundlesKeys, bundlesValues, null);
    searchBundlesSelection.setLabel("generic.limit.bundles", null);
    searchBundlesSelection.addActionListener(FormEvent.ONCHANGE);
    searchBundlesSelection.select(ALL_BUNDLES_IDENTIFYER, true);
    // Add search bundles children switch
    searchBundlesIncludeBundlesChildrenSwitch = formFactory.addCheckboxesHorizontal("searchBundlesIncludeBundlesChildrenSwitch", "generic.limit.bundles.includeChildren", searchLayoutContainer, new String[] { KEYS_ENABLED }, new String[] { KEYS_EMPTY });
    searchBundlesIncludeBundlesChildrenSwitch.select(KEYS_ENABLED, true);
    searchBundlesIncludeBundlesChildrenSwitch.addActionListener(FormEvent.ONCLICK);
    searchBundlesIncludeBundlesChildrenSwitch.setEnabled(false);
    // Add priority sort switch
    searchBundlesPrioritySortSwitch = formFactory.addCheckboxesHorizontal("searchBundlesPrioritySortSwitch", "generic.sort.by.priority", searchLayoutContainer, new String[] { KEYS_ENABLED }, new String[] { KEYS_EMPTY });
    searchBundlesPrioritySortSwitch.select(KEYS_ENABLED, true);
    searchBundlesPrioritySortSwitch.addActionListener(FormEvent.ONCLICK);
    formLayout.add(searchBundlesPrioritySortSwitch);
    // Add button to trigger search
    FormItemContainer searchButtonLayoutContainer = FormLayoutContainer.createButtonLayout("searchButtonLayoutContainer", getTranslator());
    searchLayoutContainer.add(searchButtonLayoutContainer);
    searchListButton = uifactory.addFormLink("searchListButton", "generic.listButton", null, searchButtonLayoutContainer, Link.BUTTON);
    searchTranslateButton = uifactory.addFormLink("searchTranslateButton", "generic.translateButton", null, searchButtonLayoutContainer, Link.BUTTON);
}
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