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