Search in sources :

Example 16 with TextElement

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

the class AssessedIdentityCheckListController method validateFormLogic.

@Override
protected boolean validateFormLogic(UserRequest ureq) {
    boolean allOk = true;
    for (CheckboxWrapper wrapper : wrappers) {
        TextElement pointEl = wrapper.getPointEl();
        if (pointEl != null) {
            pointEl.clearError();
            String val = pointEl.getValue();
            if (StringHelper.containsNonWhitespace(val)) {
                try {
                    Float max = wrapper.getCheckbox().getPoints();
                    float maxScore = max == null ? 0f : max.floatValue();
                    float score = Float.parseFloat(val);
                    if (score < 0f || score > maxScore) {
                        pointEl.setErrorKey("form.error.scoreOutOfRange", null);
                        allOk &= false;
                    }
                } catch (NumberFormatException e) {
                    pointEl.setErrorKey("form.error.wrongFloat", null);
                    allOk &= false;
                }
            }
        }
    }
    return allOk & super.validateFormLogic(ureq);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement)

Example 17 with TextElement

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

the class SendMailController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    String fullName = userManager.getUserDisplayName(getIdentity());
    if (StringHelper.containsNonWhitespace(fullName)) {
        fullName = "[" + fullName + "]";
    }
    TextElement fromEl = uifactory.addTextElement("from", "contact.from", 255, fullName, formLayout);
    fromEl.setEnabled(false);
    String[] contactValues = new String[] { translate("contact.to.owner"), translate("contact.to.coach"), translate("contact.to.participant") };
    contactEl = uifactory.addCheckboxesVertical("to", "contact.to", formLayout, contactKeys, contactValues, 1);
    subjectEl = uifactory.addTextElement("subject", "contact.subject", 255, "", formLayout);
    subjectEl.setDisplaySize(255);
    subjectEl.setMandatory(true);
    bodyEl = uifactory.addRichTextElementForStringDataMinimalistic("body", "contact.body", "", 15, 8, formLayout, getWindowControl());
    bodyEl.setMandatory(true);
    attachmentEl = uifactory.addFileElement(getWindowControl(), "file_upload_1", "contact.attachment", formLayout);
    attachmentEl.addActionListener(FormEvent.ONCHANGE);
    attachmentEl.setExampleKey("contact.attachment.maxsize", new String[] { Integer.toString(contactAttachmentMaxSizeInMb) });
    String attachmentPage = velocity_root + "/attachments.html";
    uploadCont = FormLayoutContainer.createCustomFormLayout("file_upload_inner", getTranslator(), attachmentPage);
    uploadCont.setRootForm(mainForm);
    uploadCont.setVisible(false);
    uploadCont.contextPut("attachments", attachments);
    formLayout.add(uploadCont);
    copyFromEl = uifactory.addCheckboxesHorizontal("copy.from", "contact.cp.from", formLayout, onKeys, new String[] { "" });
    FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
    formLayout.add(buttonGroupLayout);
    uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
    uifactory.addFormSubmitButton("tools.send.mail", buttonGroupLayout);
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 18 with TextElement

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

the class RubricEditorController method forgeSliderRow.

private SliderRow forgeSliderRow(Slider slider) {
    String startLabel = slider.getStartLabel();
    TextElement startLabelEl = uifactory.addTextElement("start.label." + count.incrementAndGet(), "start.label", 256, startLabel, flc);
    startLabelEl.setDomReplacementWrapperRequired(false);
    String endLabel = slider.getEndLabel();
    TextElement endLabelEl = uifactory.addTextElement("end.label." + count.incrementAndGet(), "end.label", 256, endLabel, flc);
    endLabelEl.setDomReplacementWrapperRequired(false);
    SliderRow row = new SliderRow(slider, startLabelEl, endLabelEl);
    if (!restrictedEdit) {
        FormLink deleteButton = uifactory.addFormLink("del." + count.incrementAndGet(), "delete_slider", "", null, flc, Link.BUTTON | Link.NONTRANSLATED);
        deleteButton.setDomReplacementWrapperRequired(false);
        deleteButton.setIconLeftCSS("o_icon o_icon-lg o_icon_delete_item");
        deleteButton.setUserObject(row);
        row.setDeleteButton(deleteButton);
        flc.contextPut("deleteButtons", Boolean.TRUE);
    }
    return row;
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 19 with TextElement

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

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 20 with TextElement

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

the class GenericSelectionPropertyHandlerController method addOptionField.

/**
 * adds an option field to the form (one row in the table)
 *
 * @param val
 */
private void addOptionField(String val) {
    int teNumber = optionFieldNames.size() + 1;
    TextElement te = uifactory.addTextElement(OPTFIELD_PREFIX + teNumber, null, 10, "", hcFlc);
    te.setValue(val);
    if (StringHelper.containsNonWhitespace(val)) {
        uifactory.addStaticTextElement(OPTFIELD_TRSLBL_PREFIX + teNumber, null, "(" + translate(val) + ")", hcFlc);
    }
    FormLink tl = uifactory.addFormLink(OPTFIELD_TRS_PREFIX + teNumber, "gsphc.translate", "label", hcFlc, Link.LINK);
    FormLink re = uifactory.addFormLink(OPTFIELD_RMV_PREFIX + teNumber, "gsphc.remove", "label", hcFlc, Link.BUTTON_XSMALL);
    re.setUserObject(te);
    tl.setUserObject(te);
    optionFieldNames.add(String.valueOf(teNumber));
    hcFlc.contextPut("optionfields", optionFieldNames);
}
Also used : StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

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