use of org.olat.core.gui.components.form.flexible.elements.TextElement in project OpenOLAT by OpenOLAT.
the class GuiDemoFlexiFormAdvancedController method addTextFields.
/**
* Adds a mandatory and a read-only text field to the provided form.
*
* @param formItemsFactory
* @param form
*/
private void addTextFields(FormItemContainer form) {
// Mandatory text field
final TextElement textField = uifactory.addTextElement("textField", "guidemo.form.text", 256, "", form);
textField.setMandatory(true);
textField.setNotEmptyCheck("guidemo.form.error.notempty");
textField.setExampleKey("advanced_form.text_field.example", null);
// Read-only text field
final TextElement readOnly = uifactory.addTextElement("readOnly", "guidemo.form.readonly", 256, "forever", form);
readOnly.setEnabled(false);
}
use of org.olat.core.gui.components.form.flexible.elements.TextElement in project OpenOLAT by OpenOLAT.
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;
}
use of org.olat.core.gui.components.form.flexible.elements.TextElement in project OpenOLAT by OpenOLAT.
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);
}
use of org.olat.core.gui.components.form.flexible.elements.TextElement in project OpenOLAT by OpenOLAT.
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++;
}
use of org.olat.core.gui.components.form.flexible.elements.TextElement in project OpenOLAT by OpenOLAT.
the class VCEditForm method addRow.
private void addRow(int index, final MeetingDate date) {
// title
TextElement vcTitle = uifactory.addTextElement("title" + counter, null, -1, date.getTitle(), editVC);
vcTitle.setDisplaySize(30);
vcTitle.setMandatory(true);
vcTitle.setNotEmptyCheck("vc.table.title.empty");
vcTitleInputList.add(index, vcTitle);
// description
TextElement vcDescription = uifactory.addTextElement("description" + counter, null, -1, date.getDescription(), editVC);
vcDescription.setDisplaySize(20);
vcDescription.setNotEmptyCheck("vc.table.description.empty");
vcDescription.setMandatory(true);
vcDescriptionInputList.add(index, vcDescription);
// begin
DateChooser vcScheduleDate = uifactory.addDateChooser("begin" + counter, "vc.table.begin", null, editVC);
vcScheduleDate.setNotEmptyCheck("vc.table.begin.empty");
vcScheduleDate.setValidDateCheck("vc.table.begin.error");
vcScheduleDate.setMandatory(true);
vcScheduleDate.setDisplaySize(20);
vcScheduleDate.setDateChooserTimeEnabled(true);
vcScheduleDate.setDate(date.getBegin());
vcCalenderbeginInputList.add(index, vcScheduleDate);
// add date duration
SimpleDateFormat sdDuration = new SimpleDateFormat("HH:mm");
TimeZone tz = TimeZone.getTimeZone("Etc/GMT+0");
sdDuration.setTimeZone(tz);
TextElement vcDuration = uifactory.addTextElement("duration" + counter, "vc.table.duration", 5, String.valueOf(0), editVC);
vcDuration.setDisplaySize(5);
vcDuration.setValue(sdDuration.format(new Date(date.getEnd().getTime() - date.getBegin().getTime())));
vcDuration.setRegexMatchCheck("\\d{1,2}:\\d\\d", "form.error.format");
vcDuration.setExampleKey("vc.table.duration.example", null);
vcDuration.setNotEmptyCheck("vc.table.duration.empty");
vcDuration.setErrorKey("vc.table.duration.error", null);
vcDuration.setMandatory(true);
vcDuration.showExample(true);
vcDuration.showError(false);
this.vcDurationInputList.add(index, vcDuration);
// add row button
FormLink addButton = new FormLinkImpl("add" + counter, "add" + counter, "vc.table.add", Link.BUTTON_SMALL);
editVC.add(addButton);
vcAddButtonList.add(index, addButton);
// remove row button
FormLink delButton = new FormLinkImpl("delete" + counter, "delete" + counter, "vc.table.delete", Link.BUTTON_SMALL);
editVC.add(delButton);
vcDelButtonList.add(index, delButton);
// increase the counter to enable unique component names
counter++;
}
Aggregations