Search in sources :

Example 1 with SpacerElement

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

the class STCourseNodeDisplayConfigFormController method initForm.

/**
 * @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
 */
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("config.fieldset.view");
    setFormContextHelp("Knowledge Transfer#_struktur");
    FormUIFactory formFact = FormUIFactory.getInstance();
    // Display type
    String[] values_displayType = new String[] { translate("form.system"), translate("form.peekview"), translate("form.self"), translate("form.delegate") };
    displayTypeRadios = formFact.addRadiosVertical("selforsystemoverview", formLayout, keys_displayType, values_displayType);
    displayTypeRadios.addActionListener(FormEvent.ONCLICK);
    if (displayConfig.equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_FILE)) {
        displayTypeRadios.select("file", true);
    } else if (displayConfig.equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_PEEKVIEW)) {
        displayTypeRadios.select("peekview", true);
    } else if (displayConfig.equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_DELEGATE)) {
        displayTypeRadios.select("delegate", true);
    } else {
        displayTypeRadios.select("system", true);
    }
    // peekviews to be selected
    if (selectedPeekviewChildKeys.length > 0) {
        SpacerElement spacerChild = formFact.addSpacerElement("spacerChild", formLayout, true);
        selectedPeekviewChildren = formFact.addCheckboxesVertical("selectedPeekviewChildren", formLayout, selectedPeekviewChildKeys, selectedPeekviewChildValues, selectedPeekviewChildCssClasses, 1);
        selectedPeekviewChildren.setLabel("selectedPeekviewChildren", new String[] { STCourseNodeConfiguration.MAX_PEEKVIEW_CHILD_NODES + "" });
        // visibility rules for peekview children selection
        RulesFactory.createHideRule(displayTypeRadios, "file", selectedPeekviewChildren, formLayout);
        RulesFactory.createHideRule(displayTypeRadios, "system", selectedPeekviewChildren, formLayout);
        RulesFactory.createShowRule(displayTypeRadios, "peekview", selectedPeekviewChildren, formLayout);
        RulesFactory.createHideRule(displayTypeRadios, "delegate", selectedPeekviewChildren, formLayout);
        RulesFactory.createHideRule(displayTypeRadios, "file", spacerChild, formLayout);
        RulesFactory.createHideRule(displayTypeRadios, "system", spacerChild, formLayout);
        RulesFactory.createShowRule(displayTypeRadios, "peekview", spacerChild, formLayout);
        RulesFactory.createHideRule(displayTypeRadios, "delegate", spacerChild, formLayout);
        // Pre-select the first MAX_PEEKVIEW_CHILD_NODES child nodes if none is
        // selected to reflect meaningfull default configuration
        preselectConfiguredOrMaxChildNodes();
        // Add as listener for any changes
        selectedPeekviewChildren.addActionListener(FormEvent.ONCLICK);
    }
    // 
    // Number of rows (only available in system or peekview type)
    SpacerElement spacerCols = formFact.addSpacerElement("spacerCols", formLayout, true);
    displayTwoColumns = formFact.addCheckboxesHorizontal("displayTwoColumns", formLayout, new String[] { "on" }, new String[] { "" });
    displayTwoColumns.setLabel("displayTwoColumns", null);
    displayTwoColumns.addActionListener(FormEvent.ONCLICK);
    if (columnsConfig == 2) {
        displayTwoColumns.selectAll();
    }
    if (displayConfig.equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_FILE) || displayConfig.equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_DELEGATE)) {
        displayTwoColumns.setVisible(false);
    }
    // 
    // Visibility rules for display columns switch
    RulesFactory.createHideRule(displayTypeRadios, "file", displayTwoColumns, formLayout);
    RulesFactory.createShowRule(displayTypeRadios, "peekview", displayTwoColumns, formLayout);
    RulesFactory.createShowRule(displayTypeRadios, "system", displayTwoColumns, formLayout);
    RulesFactory.createHideRule(displayTypeRadios, "delegate", displayTwoColumns, formLayout);
    RulesFactory.createHideRule(displayTypeRadios, "file", spacerCols, formLayout);
    RulesFactory.createShowRule(displayTypeRadios, "peekview", spacerCols, formLayout);
    RulesFactory.createShowRule(displayTypeRadios, "system", spacerCols, formLayout);
    RulesFactory.createHideRule(displayTypeRadios, "delegate", spacerCols, formLayout);
}
Also used : SpacerElement(org.olat.core.gui.components.form.flexible.elements.SpacerElement) FormUIFactory(org.olat.core.gui.components.form.flexible.FormUIFactory)

Example 2 with SpacerElement

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

the class LicenseAdminConfigController method initHandlerConfigs.

private void initHandlerConfigs() {
    List<FormLayoutContainer> handlerConfigs = new ArrayList<>(licenseHandlers.size());
    for (LicenseHandler handler : licenseHandlers) {
        boolean handlerEnabled = licenseModule.isEnabled(handler);
        if (handlerEnabled) {
            String handlerType = handler.getType();
            FormLayoutContainer handlerCont = FormLayoutContainer.createDefaultFormLayout("handler-" + handlerType, getTranslator());
            handlerCont.setRootForm(mainForm);
            flc.add("handler-" + handlerType, handlerCont);
            uifactory.addSpacerElement("spacer-" + handlerType, handlerCont, false);
            SpacerElement handlerName = uifactory.addSpacerElement("name-" + handlerType, handlerCont, true);
            handlerName.setLabel(handler.getTitle(getLocale()), null, false);
            SingleSelection defaultLicenseTypeEl = uifactory.addDropdownSingleselect(DEFAULT_LICENSE_TYPE_PREFIX + handlerType, "admin.default.license.type", handlerCont, new String[0], new String[0], null);
            defaultLicenseTypeEl.setUserObject(handler);
            defaultLicenseTypeEl.addActionListener(FormEvent.ONCHANGE);
            defaultLicenseTypeEls.put(handlerType, defaultLicenseTypeEl);
            reloadDefaultLicenseTypeEl(handler);
            String[] licensorCreatorKeys = licensorCreators.stream().map(LicensorCreator::getType).toArray(String[]::new);
            String[] licensorCreatorValues = licensorCreators.stream().map(creator -> creator.getName(getLocale())).toArray(String[]::new);
            SingleSelection licensorCreatorEl = uifactory.addDropdownSingleselect(LICENSOR_CREATOR_TYPE_PREFIX + handlerType, "admin.licensor.creator", handlerCont, licensorCreatorKeys, licensorCreatorValues, null);
            licensorCreatorEl.setUserObject(handler);
            String creatorType = licenseModule.getLicensorCreatorType(handler);
            if (creatorType != null) {
                licensorCreatorEl.select(creatorType, true);
            }
            licensorCreatorEl.addActionListener(FormEvent.ONCHANGE);
            if (CONSTANT_CREATOR_TYPE.equals(creatorType)) {
                String licensorConstant = licenseModule.getConstantLicensor(handler);
                uifactory.addStaticTextElement("lgc-" + handlerType, "admin.licensor.constant", licensorConstant, handlerCont);
                FormLink editLicensorConstantLink = uifactory.addFormLink("lgb-", "admin.licensor.constant.edit", "", handlerCont, Link.BUTTON);
                editLicensorConstantLink.setUserObject(handler);
            }
            handlerConfigs.add(handlerCont);
        }
    }
    flc.getFormItemComponent().contextPut("handlerConfigs", handlerConfigs);
}
Also used : FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement) Arrays(java.util.Arrays) LicenseModule(org.olat.core.commons.services.license.LicenseModule) LicenseService(org.olat.core.commons.services.license.LicenseService) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) BooleanCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormItem(org.olat.core.gui.components.form.flexible.FormItem) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) ArrayList(java.util.ArrayList) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) 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) SingleKeyTranslatorController(org.olat.core.util.i18n.ui.SingleKeyTranslatorController) Map(java.util.Map) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) FlexiTableDataModelFactory(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModelFactory) CONSTANT_CREATOR_TYPE(org.olat.core.commons.services.license.manager.LicensorConstantCreator.CONSTANT_CREATOR_TYPE) LicenseTypeCols(org.olat.core.commons.services.license.ui.LicenseTypeDataModel.LicenseTypeCols) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) Link(org.olat.core.gui.components.link.Link) WindowControl(org.olat.core.gui.control.WindowControl) Collection(java.util.Collection) Controller(org.olat.core.gui.control.Controller) SpacerElement(org.olat.core.gui.components.form.flexible.elements.SpacerElement) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) List(java.util.List) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) LicensorCreator(org.olat.core.commons.services.license.manager.LicensorCreator) UserRequest(org.olat.core.gui.UserRequest) LicenseType(org.olat.core.commons.services.license.LicenseType) Collections(java.util.Collections) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) SpacerElement(org.olat.core.gui.components.form.flexible.elements.SpacerElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 3 with SpacerElement

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

the class CustomfieldsFormController method createFormElemente.

private void createFormElemente(FormItemContainer formLayout, int i, CustomField customField) {
    TextElement nameElement = uifactory.addTextElement("customfield_name_" + i, "-", 50, customField.getName(), formLayout);
    nameElement.setLabel("customfield.name.label", null);
    if (i == 0)
        nameElement.setExampleKey("customfield.example.name", null);
    customFieldNameElementList.add(nameElement);
    TextElement valueElement = uifactory.addTextAreaElement("customfield_value_" + i, "-", 2500, 5, 2, true, customField.getValue(), formLayout);
    valueElement.setLabel("customfield.value.label", null);
    if (i == 0)
        valueElement.setExampleKey("customfield.example.value", null);
    customFieldValueElementList.add(valueElement);
    MultipleSelectionElement tableEnabledElement = uifactory.addCheckboxesHorizontal("customfield.table.enabled." + i, null, formLayout, keys, values);
    tableEnabledElement.select(keys[0], customField.isTableViewEnabled());
    customFieldTableFlagElementList.add(tableEnabledElement);
    FormLink deleteLink = uifactory.addFormLink("customfield.delete.link." + i, formLayout, Link.BUTTON_SMALL);
    deleteLink.setUserObject(new Integer(i));
    customFieldLinkElementList.add(deleteLink);
    SpacerElement spacerElement = uifactory.addSpacerElement("spacer" + i, formLayout, false);
    customFieldSpacerElementList.add(spacerElement);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) SpacerElement(org.olat.core.gui.components.form.flexible.elements.SpacerElement) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 4 with SpacerElement

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

the class CustomfieldsFormController method createFormElemente.

private void createFormElemente(FormItemContainer formLayout, int i, CustomField customField) {
    TextElement nameElement = uifactory.addTextElement("customfield_name_" + i, "-", 50, customField.getName(), formLayout);
    nameElement.setLabel("customfield.name.label", null);
    if (i == 0)
        nameElement.setExampleKey("customfield.example.name", null);
    customFieldNameElementList.add(nameElement);
    TextElement valueElement = uifactory.addTextAreaElement("customfield_value_" + i, "-", 2500, 5, 2, true, customField.getValue(), formLayout);
    valueElement.setLabel("customfield.value.label", null);
    if (i == 0)
        valueElement.setExampleKey("customfield.example.value", null);
    customFieldValueElementList.add(valueElement);
    MultipleSelectionElement tableEnabledElement = uifactory.addCheckboxesHorizontal("customfield.table.enabled." + i, null, formLayout, keys, values);
    tableEnabledElement.select(keys[0], customField.isTableViewEnabled());
    customFieldTableFlagElementList.add(tableEnabledElement);
    FormLink deleteLink = uifactory.addFormLink("customfield.delete.link." + i, formLayout, Link.BUTTON_SMALL);
    deleteLink.setUserObject(new Integer(i));
    customFieldLinkElementList.add(deleteLink);
    SpacerElement spacerElement = uifactory.addSpacerElement("spacer" + i, formLayout, false);
    customFieldSpacerElementList.add(spacerElement);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) SpacerElement(org.olat.core.gui.components.form.flexible.elements.SpacerElement) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 5 with SpacerElement

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

the class LicenseAdminConfigController method initHandlerConfigs.

private void initHandlerConfigs() {
    List<FormLayoutContainer> handlerConfigs = new ArrayList<>(licenseHandlers.size());
    for (LicenseHandler handler : licenseHandlers) {
        boolean handlerEnabled = licenseModule.isEnabled(handler);
        if (handlerEnabled) {
            String handlerType = handler.getType();
            FormLayoutContainer handlerCont = FormLayoutContainer.createDefaultFormLayout("handler-" + handlerType, getTranslator());
            handlerCont.setRootForm(mainForm);
            flc.add("handler-" + handlerType, handlerCont);
            uifactory.addSpacerElement("spacer-" + handlerType, handlerCont, false);
            SpacerElement handlerName = uifactory.addSpacerElement("name-" + handlerType, handlerCont, true);
            handlerName.setLabel(handler.getTitle(getLocale()), null, false);
            SingleSelection defaultLicenseTypeEl = uifactory.addDropdownSingleselect(DEFAULT_LICENSE_TYPE_PREFIX + handlerType, "admin.default.license.type", handlerCont, new String[0], new String[0], null);
            defaultLicenseTypeEl.setUserObject(handler);
            defaultLicenseTypeEl.addActionListener(FormEvent.ONCHANGE);
            defaultLicenseTypeEls.put(handlerType, defaultLicenseTypeEl);
            reloadDefaultLicenseTypeEl(handler);
            String[] licensorCreatorKeys = licensorCreators.stream().map(LicensorCreator::getType).toArray(String[]::new);
            String[] licensorCreatorValues = licensorCreators.stream().map(creator -> creator.getName(getLocale())).toArray(String[]::new);
            SingleSelection licensorCreatorEl = uifactory.addDropdownSingleselect(LICENSOR_CREATOR_TYPE_PREFIX + handlerType, "admin.licensor.creator", handlerCont, licensorCreatorKeys, licensorCreatorValues, null);
            licensorCreatorEl.setUserObject(handler);
            String creatorType = licenseModule.getLicensorCreatorType(handler);
            if (creatorType != null) {
                licensorCreatorEl.select(creatorType, true);
            }
            licensorCreatorEl.addActionListener(FormEvent.ONCHANGE);
            if (CONSTANT_CREATOR_TYPE.equals(creatorType)) {
                String licensorConstant = licenseModule.getConstantLicensor(handler);
                uifactory.addStaticTextElement("lgc-" + handlerType, "admin.licensor.constant", licensorConstant, handlerCont);
                FormLink editLicensorConstantLink = uifactory.addFormLink("lgb-", "admin.licensor.constant.edit", "", handlerCont, Link.BUTTON);
                editLicensorConstantLink.setUserObject(handler);
            }
            handlerConfigs.add(handlerCont);
        }
    }
    flc.getFormItemComponent().contextPut("handlerConfigs", handlerConfigs);
}
Also used : FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement) Arrays(java.util.Arrays) LicenseModule(org.olat.core.commons.services.license.LicenseModule) LicenseService(org.olat.core.commons.services.license.LicenseService) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) BooleanCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormItem(org.olat.core.gui.components.form.flexible.FormItem) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) ArrayList(java.util.ArrayList) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) 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) SingleKeyTranslatorController(org.olat.core.util.i18n.ui.SingleKeyTranslatorController) Map(java.util.Map) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) FlexiTableDataModelFactory(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModelFactory) CONSTANT_CREATOR_TYPE(org.olat.core.commons.services.license.manager.LicensorConstantCreator.CONSTANT_CREATOR_TYPE) LicenseTypeCols(org.olat.core.commons.services.license.ui.LicenseTypeDataModel.LicenseTypeCols) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) Link(org.olat.core.gui.components.link.Link) WindowControl(org.olat.core.gui.control.WindowControl) Collection(java.util.Collection) Controller(org.olat.core.gui.control.Controller) SpacerElement(org.olat.core.gui.components.form.flexible.elements.SpacerElement) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) List(java.util.List) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) LicensorCreator(org.olat.core.commons.services.license.manager.LicensorCreator) UserRequest(org.olat.core.gui.UserRequest) LicenseType(org.olat.core.commons.services.license.LicenseType) Collections(java.util.Collections) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) SpacerElement(org.olat.core.gui.components.form.flexible.elements.SpacerElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Aggregations

SpacerElement (org.olat.core.gui.components.form.flexible.elements.SpacerElement)8 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)4 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)4 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 LicenseHandler (org.olat.core.commons.services.license.LicenseHandler)2 LicenseModule (org.olat.core.commons.services.license.LicenseModule)2 LicenseService (org.olat.core.commons.services.license.LicenseService)2 LicenseType (org.olat.core.commons.services.license.LicenseType)2 CONSTANT_CREATOR_TYPE (org.olat.core.commons.services.license.manager.LicensorConstantCreator.CONSTANT_CREATOR_TYPE)2 LicensorCreator (org.olat.core.commons.services.license.manager.LicensorCreator)2 LicenseTypeCols (org.olat.core.commons.services.license.ui.LicenseTypeDataModel.LicenseTypeCols)2 UserRequest (org.olat.core.gui.UserRequest)2 FormItem (org.olat.core.gui.components.form.flexible.FormItem)2 FormItemContainer (org.olat.core.gui.components.form.flexible.FormItemContainer)2