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);
}
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);
}
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);
}
}
}
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);
}
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;
}
}
Aggregations