Search in sources :

Example 46 with TextElement

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

the class FormUIFactory method addInlineTextElement.

public TextElement addInlineTextElement(String name, String value, FormItemContainer formLayout, FormBasicController listener) {
    TextElement ie = new TextElementImpl(null, name, value, TextElementImpl.HTML_INPUT_TYPE_TEXT, true);
    ie.addActionListener(FormEvent.ONCLICK);
    if (listener != null) {
        formLayout.add(ie);
    }
    return ie;
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) RichTextElementImpl(org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextElementImpl) StaticTextElementImpl(org.olat.core.gui.components.form.flexible.impl.elements.StaticTextElementImpl) TextElementImpl(org.olat.core.gui.components.form.flexible.impl.elements.TextElementImpl)

Example 47 with TextElement

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

the class PreviewSettingsForm method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    sdate = uifactory.addDateChooser("sdate", "form.sdate", null, formLayout);
    sdate.setExampleKey("form.easy.example.bdate", null);
    sdate.setDateChooserTimeEnabled(true);
    sdate.setMandatory(true);
    sdate.setValidDateCheck("form.sdate.invalid");
    // setDate must be called after the DataChooser was configured
    sdate.setDate(new Date());
    List<BusinessGroup> groups = courseGroupManager.getAllBusinessGroups();
    String[] groupNames = new String[groups.size()];
    String[] groupKeys = new String[groups.size()];
    for (int i = groups.size(); i-- > 0; ) {
        groupNames[i] = groups.get(i).getName();
        groupKeys[i] = groups.get(i).getKey().toString();
    }
    groupSelector = uifactory.addCheckboxesVertical("details.groups", formLayout, groupKeys, groupNames, 1);
    groupSelector.setVisible(groups.size() > 0);
    List<BGArea> areas = courseGroupManager.getAllAreas();
    String[] areaNames = new String[areas.size()];
    String[] areaKeys = new String[areas.size()];
    for (int i = areas.size(); i-- > 0; ) {
        areaNames[i] = areas.get(i).getName();
        areaKeys[i] = areas.get(i).getKey().toString();
    }
    areaSelector = uifactory.addCheckboxesVertical("details.areas", formLayout, areaKeys, areaNames, 1);
    areaSelector.setVisible(areas.size() > 0);
    String[] keys = { ROLE_STUDENT, ROLE_GUEST, ROLE_COURSECOACH, ROLE_COURSEADMIN, ROLE_GLOBALAUTHOR };
    String[] values = new String[keys.length];
    for (int i = 0; i < keys.length; i++) {
        values[i] = translate(keys[i]);
    }
    roles = uifactory.addRadiosVertical("roles", "form.roles", formLayout, keys, values);
    roles.select(ROLE_STUDENT, true);
    String page = velocity_root + "/attributes.html";
    FormLayoutContainer attrlayout = FormLayoutContainer.createCustomFormLayout("attributes", getTranslator(), page);
    formLayout.add(attrlayout);
    attrlayout.setLabel("form.attributes", null);
    for (int i = 0; i < NUMATTR; i++) {
        TextElement name = uifactory.addTextElement("attrname" + i, null, 255, "", attrlayout);
        ((AbstractComponent) name.getComponent()).setDomReplacementWrapperRequired(false);
        name.setDisplaySize(12);
        TextElement value = uifactory.addTextElement("attrvalue" + i, "form.equals", 255, "", attrlayout);
        ((AbstractComponent) value.getComponent()).setDomReplacementWrapperRequired(false);
        value.setDisplaySize(12);
        attrNames.add(name);
        attrValues.add(value);
    }
    uifactory.addFormSubmitButton("submit", "command.preview", formLayout);
}
Also used : AbstractComponent(org.olat.core.gui.components.AbstractComponent) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Date(java.util.Date)

Example 48 with TextElement

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

the class LecturesSearchFormController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    login = uifactory.addTextElement("login", "search.form.login", 128, "", formLayout);
    login.setVisible(adminProps);
    userPropertyHandlers = userManager.getUserPropertyHandlersFor(PROPS_IDENTIFIER, adminProps);
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler != null) {
            FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, PROPS_IDENTIFIER, false, formLayout);
            fi.setMandatory(false);
            // DO NOT validate email field => see OLAT-3324, OO-155, OO-222
            if (userPropertyHandler instanceof EmailProperty && fi instanceof TextElement) {
                TextElement textElement = (TextElement) fi;
                textElement.setItemValidatorProvider(null);
            }
            propFormItems.put(userPropertyHandler.getName(), fi);
        }
    }
    bulkEl = uifactory.addTextAreaElement("bulk", 4, 72, "", formLayout);
    bulkEl.setHelpText(translate("bulk.hint"));
    bulkEl.setExampleKey("bulk.example", null);
    List<RepositoryEntryLifecycle> cycles = lifecycleDao.loadPublicLifecycle();
    String[] dateKeys;
    String[] dateValues;
    if (cycles.isEmpty()) {
        dateKeys = new String[] { "none", "private" };
        dateValues = new String[] { translate("dates.none"), translate("dates.private") };
    } else {
        dateKeys = new String[] { "none", "private", "public" };
        dateValues = new String[] { translate("dates.none"), translate("dates.private"), translate("dates.public") };
    }
    dateTypesEl = uifactory.addRadiosVertical("dates", formLayout, dateKeys, dateValues);
    dateTypesEl.select(dateKeys[0], true);
    dateTypesEl.addActionListener(FormEvent.ONCHANGE);
    List<RepositoryEntryLifecycle> filteredCycles = new ArrayList<>();
    for (RepositoryEntryLifecycle cycle : cycles) {
        if (cycle.getValidTo() == null) {
            filteredCycles.add(cycle);
        }
    }
    String[] publicKeys = new String[filteredCycles.size()];
    String[] publicValues = new String[filteredCycles.size()];
    int count = 0;
    for (RepositoryEntryLifecycle cycle : filteredCycles) {
        publicKeys[count] = cycle.getKey().toString();
        StringBuilder sb = new StringBuilder(32);
        boolean labelAvailable = StringHelper.containsNonWhitespace(cycle.getLabel());
        if (labelAvailable) {
            sb.append(cycle.getLabel());
        }
        if (StringHelper.containsNonWhitespace(cycle.getSoftKey())) {
            if (labelAvailable)
                sb.append(" - ");
            sb.append(cycle.getSoftKey());
        }
        publicValues[count++] = sb.toString();
    }
    publicDatesEl = uifactory.addDropdownSingleselect("public.dates", formLayout, publicKeys, publicValues, null);
    String privateDatePage = velocity_root + "/cycle_dates.html";
    privateDatesCont = FormLayoutContainer.createCustomFormLayout("private.date", getTranslator(), privateDatePage);
    privateDatesCont.setRootForm(mainForm);
    privateDatesCont.setLabel("private.dates", null);
    formLayout.add("private.date", privateDatesCont);
    startDateEl = uifactory.addDateChooser("date.start", "date.start", null, privateDatesCont);
    startDateEl.setElementCssClass("o_sel_repo_lifecycle_validfrom");
    endDateEl = uifactory.addDateChooser("date.end", "date.end", null, privateDatesCont);
    endDateEl.setElementCssClass("o_sel_repo_lifecycle_validto");
    FormLayoutContainer buttonCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonCont);
    uifactory.addFormSubmitButton("search", buttonCont);
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) EmailProperty(org.olat.user.propertyhandlers.EmailProperty) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 49 with TextElement

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

the class TextElementTriggerdDependencyRule method doesTrigger.

/**
 * @see org.olat.core.gui.components.form.flexible.rules.FormItemDependencyRuleImpl#doesTrigger()
 */
@Override
protected boolean doesTrigger() {
    TextElement te = (TextElement) this.triggerElement;
    String val = te.getValue();
    // 
    if (val == null && triggerVal == null) {
        // triggerVal and val are NULL -> true
        return true;
    } else if (triggerVal != null) {
        // triggerVal can be compared
        return triggerVal.equals(val);
    } else {
        // triggerVal is null but val is not null -> false
        return false;
    }
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement)

Example 50 with TextElement

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

the class AttributeEasyRowAdderController method updateValueElementForAttribute.

/**
 * Internal method to update a row's value element. This can be a text input box or a selection drop down depending on the shibboleth module configuration and the selected attribute. The method
 * will set the given value as the users selected / inputed value
 *
 * @param attribute The attribute key. Must not be NULL
 * @param row the row ID
 * @param value The value that should be selected / used in the text input field. Can be NULL.
 */
private void updateValueElementForAttribute(final String attribute, final int row, final String value) {
    String[] selectableKeys = getSelectableKeys(attribute);
    // Get the value text input and selection drop down form elements for this
    // row. Don't use the element name since there we have the global row
    // counter in the name and _not_ the current row id!
    final SingleSelection iselect = (SingleSelection) flc.getFormComponent(columnValueSelection.get(row));
    final TextElement tei = (TextElement) flc.getFormComponent(columnValueText.get(row));
    if (selectableKeys.length > 0) {
        attributeAsSelectBox(attribute, value, selectableKeys, iselect, tei);
    } else {
        attributeAsTextField(value, iselect, tei);
    }
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection)

Aggregations

TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)146 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)40 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)36 FormItem (org.olat.core.gui.components.form.flexible.FormItem)34 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)30 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)26 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)24 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)18 ArrayList (java.util.ArrayList)16 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)16 Identity (org.olat.core.id.Identity)12 HashMap (java.util.HashMap)8 FormLinkImpl (org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)8 EmailProperty (org.olat.user.propertyhandlers.EmailProperty)8 Date (java.util.Date)6 DateChooser (org.olat.core.gui.components.form.flexible.elements.DateChooser)6 StaticTextElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.StaticTextElementImpl)6 TextElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.TextElementImpl)6 RichTextElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextElementImpl)6 File (java.io.File)4