Search in sources :

Example 11 with FormUIFactory

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

the class AbstractLayoutAttribute method getFormItem.

// as per default attaches a dropdown and selects what is given
public FormItem getFormItem(String compName, FormItemContainer formLayout) {
    FormUIFactory uifact = FormUIFactory.getInstance();
    SingleSelection fi = uifact.addDropdownSingleselect(compName, null, formLayout, availKeys, availValues, availCSS);
    if (attributeValue != null && Arrays.asList(availKeys).contains(attributeValue)) {
        fi.select(attributeValue, true);
        fi.showLabel(false);
    }
    return fi;
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormUIFactory(org.olat.core.gui.components.form.flexible.FormUIFactory)

Example 12 with FormUIFactory

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

the class ColorLA method getFormItem.

/**
 * @see org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute#getFormItem(java.lang.String, org.olat.core.gui.components.form.flexible.FormItemContainer)
 * get a dropdown and an input field wrapped in a FormLayoutContainer
 */
@Override
public FormItem getFormItem(String compName, FormItemContainer formLayout) {
    FormUIFactory uifact = FormUIFactory.getInstance();
    FormLayoutContainer colorFLC = FormLayoutContainer.createVerticalFormLayout(compName, formLayout.getTranslator());
    formLayout.add(compName, colorFLC);
    FormItem dropDown = super.getFormItem(compName + "sel", formLayout);
    dropDown.addActionListener(FormEvent.ONCHANGE);
    colorFLC.add(dropDown);
    String inputValue = "";
    if (getAttributeValue() != null && !((SingleSelection) dropDown).isOneSelected()) {
        inputValue = getAttributeValue();
    }
    TextElement inputEl = uifact.addTextElement(compName + "value", null, 7, inputValue, colorFLC);
    inputEl.setDisplaySize(7);
    colorFLC.setUserObject(new ColorSpecialHandler(colorFLC));
    return colorFLC;
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormItem(org.olat.core.gui.components.form.flexible.FormItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FormUIFactory(org.olat.core.gui.components.form.flexible.FormUIFactory)

Example 13 with FormUIFactory

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

the class PreviewLA method getFormItem.

/**
 * @see org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute#getFormItem(java.lang.String, org.olat.core.gui.components.form.flexible.FormItemContainer)
 */
@Override
public FormItem getFormItem(String compName, FormItemContainer formLayout) {
    FormUIFactory uifact = FormUIFactory.getInstance();
    String textEl = new String("<span style=\"" + getAttributeValue() + "\">" + formLayout.getTranslator().translate("preview.sample") + "</span>");
    StaticTextElement fi = uifact.addStaticTextElement(compName, null, textEl, formLayout);
    return fi;
}
Also used : StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) FormUIFactory(org.olat.core.gui.components.form.flexible.FormUIFactory)

Example 14 with FormUIFactory

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

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)

Aggregations

FormUIFactory (org.olat.core.gui.components.form.flexible.FormUIFactory)14 FormItem (org.olat.core.gui.components.form.flexible.FormItem)4 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)4 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 SpacerElement (org.olat.core.gui.components.form.flexible.elements.SpacerElement)2 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)2