Search in sources :

Example 56 with TextElement

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

the class EvaluationFormController method forgeTextInput.

private EvaluationFormElementWrapper forgeTextInput(TextInput element) {
    String initialValue = "";
    EvaluationFormResponse response = identifierToResponses.get(element.getId());
    if (response != null && StringHelper.containsNonWhitespace(response.getStringuifiedResponse())) {
        initialValue = response.getStringuifiedResponse();
    }
    int rows = 12;
    if (element.getRows() > 0) {
        rows = element.getRows();
    }
    TextElement textEl = uifactory.addTextAreaElement("textinput_" + (count++), null, Integer.MAX_VALUE, rows, 72, false, initialValue, flc);
    textEl.setEnabled(!readOnly);
    FormLink saveButton = uifactory.addFormLink("save_" + (count++), "save", null, flc, Link.BUTTON);
    saveButton.setVisible(!readOnly);
    TextInputWrapper textInputWrapper = new TextInputWrapper(element, textEl, saveButton);
    saveButton.setUserObject(textInputWrapper);
    textEl.setUserObject(textInputWrapper);
    EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
    wrapper.setTextInputWrapper(textInputWrapper);
    return wrapper;
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) TextInputWrapper(org.olat.modules.forms.ui.model.TextInputWrapper) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 57 with TextElement

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

the class RubricEditorController method updateSteps.

private void updateSteps() {
    List<StepLabelColumn> stepLabelColumns = new ArrayList<>();
    if (stepsEl.isVisible() && stepsEl.isOneSelected() && (typeEl.isSelected(0) || typeEl.isSelected(1))) {
        int steps = Integer.parseInt(stepsEl.getSelectedKey());
        for (int i = 0; i < steps; i++) {
            Integer step = new Integer(i);
            StepLabelColumn col = stepToColumns.get(step);
            if (col == null) {
                String label = "";
                if (rubric.getStepLabels() != null && i < rubric.getStepLabels().size()) {
                    label = rubric.getStepLabels().get(i).getLabel();
                }
                TextElement textEl = uifactory.addTextElement("steplabel_" + count.incrementAndGet(), "steplabel_" + count.incrementAndGet(), null, 256, label, flc);
                textEl.setDomReplacementWrapperRequired(false);
                textEl.setDisplaySize(4);
                col = new StepLabelColumn(i, textEl);
            }
            stepLabelColumns.add(col);
        }
        // 90 is empirically choose to not make a second line
        int stepInPercent = Math.round(90.0f / steps);
        flc.contextPut("stepInPercent", stepInPercent);
    }
    stepLabels = stepLabelColumns;
    flc.contextPut("stepLabels", stepLabelColumns);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) ArrayList(java.util.ArrayList)

Example 58 with TextElement

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

the class ExternalLinksController method addNewFormLink.

private void addNewFormLink(LinkWrapper link, FormLayoutContainer layoutContainer) {
    // add link target
    String id = link.getId();
    String uri = link.getLink().getURI();
    if (!StringHelper.containsNonWhitespace(uri)) {
        uri = "http://";
    }
    TextElement url = uifactory.addTextElement("url_" + id, null, -1, uri, layoutContainer);
    url.clearError();
    url.setDisplaySize(60);
    url.setMandatory(true);
    link.setUrl(url);
    // add link description
    TextElement name = uifactory.addTextElement("displayName_" + id, null, -1, link.getLink().getDisplayName(), layoutContainer);
    name.clearError();
    name.setDisplaySize(40);
    name.setMandatory(true);
    link.setName(name);
    // add link add action button
    FormLink addButton = uifactory.addFormLink("add_" + id, "table.add", "table.add", layoutContainer, Link.BUTTON);
    addButton.setUserObject(link);
    link.setAddButton(addButton);
    // add link deletion action button
    FormLink delButton = uifactory.addFormLink("del_" + id, "table.delete", "table.delete", layoutContainer, Link.BUTTON);
    delButton.setUserObject(link);
    link.setDelButton(delButton);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 59 with TextElement

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

the class UserSearchForm method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_user_search_form");
    login = uifactory.addTextElement("login", "search.form.login", 128, "", formLayout);
    login.setVisible(isAdminProps);
    login.setElementCssClass("o_sel_user_search_username");
    Translator tr = Util.createPackageTranslator(UserPropertyHandler.class, getLocale(), getTranslator());
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null)
            continue;
        FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, getClass().getCanonicalName(), false, formLayout);
        fi.setTranslator(tr);
        // 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);
        }
        fi.setElementCssClass("o_sel_user_search_".concat(userPropertyHandler.getName().toLowerCase()));
        propFormItems.put(userPropertyHandler.getName(), fi);
    }
    FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
    formLayout.add(buttonGroupLayout);
    // Don't use submit button, form should not be marked as dirty since this is
    // not a configuration form but only a search form (OLAT-5626)
    searchButton = uifactory.addFormLink("submit.search", buttonGroupLayout, Link.BUTTON);
    searchButton.setElementCssClass("o_sel_user_search_button");
    if (cancelButton) {
        uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
    }
}
Also used : EmailProperty(org.olat.user.propertyhandlers.EmailProperty) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) Translator(org.olat.core.gui.translator.Translator) FormItem(org.olat.core.gui.components.form.flexible.FormItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 60 with TextElement

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

the class LLEditForm method addNewFormLink.

/**
 * Add a new form link line to the list of link elements.
 *
 * @param link the link model object
 */
private void addNewFormLink(int index, final LLModel link) {
    // add link target
    TextElement lTarget = uifactory.addTextElement("target" + counter, null, -1, link.getTarget(), flc);
    lTarget.setPlaceholderKey("target.example", null);
    lTarget.clearError();
    lTarget.setEnabled(!link.isIntern());
    lTarget.setDisplaySize(40);
    lTarget.setMandatory(true);
    lTarget.setNotEmptyCheck("ll.table.target.error");
    lTarget.setItemValidatorProvider(new ItemValidatorProvider() {

        public boolean isValidValue(String value, ValidationError validationError, Locale locale) {
            try {
                if (!value.contains("://")) {
                    value = "http://".concat(value);
                }
                new URL(value);
            } catch (MalformedURLException e) {
                validationError.setErrorKey("ll.table.target.error.format");
                return false;
            }
            return true;
        }
    });
    lTarget.addActionListener(FormEvent.ONCHANGE);
    lTarget.setUserObject(link);
    lTargetInputList.add(index, lTarget);
    // add html target
    SingleSelection htmlTargetSelection = uifactory.addDropdownSingleselect("html_target" + counter, flc, new String[] { BLANK_KEY, SELF_KEY }, new String[] { translate("ll.table.html_target"), translate("ll.table.html_target.self") }, null);
    htmlTargetSelection.setUserObject(link);
    htmlTargetSelection.select((SELF_KEY.equals(link.getHtmlTarget()) ? SELF_KEY : BLANK_KEY), true);
    lHtmlTargetInputList.add(index, htmlTargetSelection);
    // add link description
    TextElement lDescription = uifactory.addTextElement("description" + counter, null, -1, link.getDescription(), flc);
    lDescription.clearError();
    lDescription.setDisplaySize(20);
    lDescription.setNotEmptyCheck("ll.table.description.error");
    lDescription.setMandatory(true);
    lDescription.setPlaceholderKey("ll.table.description", null);
    lDescription.setUserObject(link);
    lDescriptionInputList.add(index, lDescription);
    // add link comment
    TextElement lComment = uifactory.addTextAreaElement("comment" + counter, null, -1, 2, 50, true, link.getComment(), flc);
    lComment.setPlaceholderKey("ll.table.comment", null);
    lComment.setDisplaySize(20);
    lComment.setUserObject(link);
    lCommentInputList.add(index, lComment);
    // add link add action button
    FormLink addButton = new FormLinkImpl("add" + counter, "add" + counter, "", Link.BUTTON_SMALL + Link.NONTRANSLATED);
    addButton.setUserObject(link);
    addButton.setDomReplacementWrapperRequired(false);
    addButton.setIconLeftCSS("o_icon o_icon-lg o_icon-fw o_icon_add");
    flc.add(addButton);
    lAddButtonList.add(index, addButton);
    // add link deletion action button
    FormLink delButton = new FormLinkImpl("delete" + counter, "delete" + counter, "", Link.BUTTON_SMALL + Link.NONTRANSLATED);
    delButton.setUserObject(link);
    delButton.setDomReplacementWrapperRequired(false);
    delButton.setIconLeftCSS("o_icon o_icon-lg o_icon-fw o_icon_delete_item");
    flc.add(delButton);
    lDelButtonList.add(index, delButton);
    // custom media action button
    FormLink mediaButton = new FormLinkImpl("media" + counter, "media" + counter, "  ", Link.NONTRANSLATED);
    mediaButton.setIconLeftCSS("o_icon o_icon_browse o_icon-lg");
    mediaButton.setDomReplacementWrapperRequired(false);
    mediaButton.setUserObject(link);
    flc.add(mediaButton);
    lCustomMediaButtonList.add(index, mediaButton);
    // increase the counter to enable unique component names
    counter++;
}
Also used : Locale(java.util.Locale) MalformedURLException(java.net.MalformedURLException) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) ItemValidatorProvider(org.olat.core.gui.components.form.flexible.impl.elements.ItemValidatorProvider) FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl) ValidationError(org.olat.core.gui.components.form.ValidationError) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) URL(java.net.URL)

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