Search in sources :

Example 96 with TextElement

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

the class ChoiceScoreController method createChoiceWrapper.

private ChoiceWrapper createChoiceWrapper(Choice choice) {
    String points = "";
    Double score = itemBuilder.getMapping(choice.getIdentifier());
    if (score != null) {
        points = score.toString();
    }
    String pointElId = "points_" + counter++;
    TextElement pointEl = uifactory.addTextElement(pointElId, null, 5, points, scoreCont);
    pointEl.setDisplaySize(5);
    pointEl.setEnabled(!restrictedEdit && !readOnly);
    scoreCont.add(pointElId, pointEl);
    return new ChoiceWrapper(choice, pointEl);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement)

Example 97 with TextElement

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

the class MatchScoreController method validateFormLogic.

@Override
protected boolean validateFormLogic(UserRequest ureq) {
    boolean allOk = true;
    allOk &= validateMinMaxScores(minScoreEl, maxScoreEl);
    if (assessmentModeEl.isOneSelected() && assessmentModeEl.isSelected(1)) {
        for (Map.Entry<DirectedPairValue, MatchScoreWrapper> entry : scoreWrappers.entrySet()) {
            MatchScoreWrapper scoreWrapper = entry.getValue();
            TextElement scoreEl = scoreWrapper.getScoreEl();
            String val = scoreEl.getValue();
            scoreEl.clearError();
            if (StringHelper.containsNonWhitespace(val)) {
                try {
                    Double.parseDouble(val);
                } catch (NumberFormatException e) {
                    scoreEl.setErrorKey("error.double", null);
                    allOk &= false;
                }
            } else {
                scoreEl.setErrorKey("form.legende.mandatory", null);
                allOk &= false;
            }
        }
    }
    return allOk & super.validateFormLogic(ureq);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) HashMap(java.util.HashMap) Map(java.util.Map)

Example 98 with TextElement

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

the class FIBTextEntrySettingsController method appendAlternative.

private void appendAlternative(TextEntryAlternative alternative, AlternativeRow previousRow, boolean focus) {
    String text = alternative.getAlternative();
    TextElement alternativeEl = uifactory.addTextElement("fib.alternative." + count++, "fib.alternative", 256, text, alternativesCont);
    alternativeEl.setDomReplacementWrapperRequired(false);
    alternativeEl.setEnabled(!restrictedEdit && !readOnly);
    if (focus) {
        solutionEl.setFocus(false);
        for (AlternativeRow row : alternativeRows) {
            row.getAlternativeEl().setFocus(false);
        }
        alternativeEl.setFocus(true);
    }
    FormLink addButton = null;
    if (!restrictedEdit && !readOnly) {
        addButton = uifactory.addFormLink("add.alternative." + count++, "add", "", null, alternativesCont, Link.NONTRANSLATED);
        addButton.setIconLeftCSS("o_icon o_icon-lg o_icon_add");
        addButton.setVisible(!restrictedEdit && !readOnly);
        alternativesCont.add(addButton);
    }
    FormLink removeButton = null;
    if (!restrictedEdit && !readOnly) {
        removeButton = uifactory.addFormLink("remove.alternative." + count++, "rm", "", null, alternativesCont, Link.NONTRANSLATED);
        removeButton.setIconLeftCSS("o_icon o_icon-lg o_icon_delete");
        removeButton.setVisible(!restrictedEdit && !readOnly);
        alternativesCont.add(removeButton);
    }
    AlternativeRow row = new AlternativeRow(alternative, alternativeEl, addButton, removeButton);
    if (previousRow == null) {
        alternativeRows.add(row);
    } else {
        int index = alternativeRows.indexOf(previousRow) + 1;
        if (index >= 0 && index < alternativeRows.size()) {
            alternativeRows.add(index, row);
        } else {
            alternativeRows.add(row);
        }
    }
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 99 with TextElement

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

the class FIBScoreController method createTextEntryWrapper.

private FIBEntryWrapper createTextEntryWrapper(AbstractEntry entry) {
    String points = "";
    Double score = entry.getScore();
    if (score != null) {
        points = score.toString();
    }
    String pointElId = "points_" + counter++;
    TextElement pointEl = uifactory.addTextElement(pointElId, null, 5, points, scoreCont);
    pointEl.setDisplaySize(5);
    pointEl.setEnabled(!restrictedEdit && !readOnly);
    scoreCont.add(pointElId, pointEl);
    return new FIBEntryWrapper(entry, pointEl);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement)

Example 100 with TextElement

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

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)

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