use of org.olat.core.gui.components.form.flexible.elements.TextElement in project OpenOLAT by OpenOLAT.
the class GlossaryTermAndSynonymController method createOrUpdateSynonymLayout.
private void createOrUpdateSynonymLayout(FormItemContainer formLayout, ArrayList<String> glossItemSynonymsToUse) {
FormUIFactory formUIf = FormUIFactory.getInstance();
FormItem synLay = formLayout.getFormComponent("synonymLayout");
if (synLay != null) {
formLayout.remove("synonymLayout");
}
FormLayoutContainer tmpLayout = FormLayoutContainer.createCustomFormLayout("synonymLayout", getTranslator(), velocity_root + "/editSynonym.html");
formLayout.add(tmpLayout);
tmpLayout.setLabel("glossary.term.synonym", null);
Collections.sort(glossItemSynonymsToUse);
tmpLayout.contextPut("glossItemSynonyms", glossItemSynonymsToUse);
// add input fields with existing synonyms
synonymTextElementList = new ArrayList<TextElement>(glossItemSynonymsToUse.size());
for (int synNum = 1; synNum < glossItemSynonymsToUse.size() + 1; synNum++) {
TextElement tmpSynonymTE = formUIf.addTextElement(SYNONYM_TEXT_ELEMENT + synNum, null, 100, glossItemSynonymsToUse.get(synNum - 1), tmpLayout);
synonymTextElementList.add(tmpSynonymTE);
}
// add delete-links for existing synonyms
for (int linkNum = 1; linkNum < glossItemSynonymsToUse.size() + 1; linkNum++) {
FormLink tmpRemoveButton = formUIf.addFormLink(CMD_DELETE_SYNONYM + linkNum, tmpLayout, Link.BUTTON_XSMALL);
tmpRemoveButton.setUserObject(glossItemSynonymsToUse.get(linkNum - 1));
tmpRemoveButton.setI18nKey("synonym.link.delete");
}
// add input field for new synonym
newSynonymField = formUIf.addTextElement("synonym.inputfield", "glossary.term.synonym", 100, "", tmpLayout);
newSynonymField.setVisible(true);
newSynonymField.setLabel("synonym.inputfield", null);
formUIf.addFormSubmitButton("form.submit", tmpLayout);
}
use of org.olat.core.gui.components.form.flexible.elements.TextElement in project OpenOLAT by OpenOLAT.
the class PreviewSettingsForm method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
sdate = uifactory.addDateChooser("sdate", "form.sdate", null, formLayout);
sdate.setExampleKey("form.easy.example.bdate", null);
sdate.setDateChooserTimeEnabled(true);
sdate.setMandatory(true);
sdate.setValidDateCheck("form.sdate.invalid");
// setDate must be called after the DataChooser was configured
sdate.setDate(new Date());
List<BusinessGroup> groups = courseGroupManager.getAllBusinessGroups();
String[] groupNames = new String[groups.size()];
String[] groupKeys = new String[groups.size()];
for (int i = groups.size(); i-- > 0; ) {
groupNames[i] = groups.get(i).getName();
groupKeys[i] = groups.get(i).getKey().toString();
}
groupSelector = uifactory.addCheckboxesVertical("details.groups", formLayout, groupKeys, groupNames, 1);
groupSelector.setVisible(groups.size() > 0);
List<BGArea> areas = courseGroupManager.getAllAreas();
String[] areaNames = new String[areas.size()];
String[] areaKeys = new String[areas.size()];
for (int i = areas.size(); i-- > 0; ) {
areaNames[i] = areas.get(i).getName();
areaKeys[i] = areas.get(i).getKey().toString();
}
areaSelector = uifactory.addCheckboxesVertical("details.areas", formLayout, areaKeys, areaNames, 1);
areaSelector.setVisible(areas.size() > 0);
String[] keys = { ROLE_STUDENT, ROLE_GUEST, ROLE_COURSECOACH, ROLE_COURSEADMIN, ROLE_GLOBALAUTHOR };
String[] values = new String[keys.length];
for (int i = 0; i < keys.length; i++) {
values[i] = translate(keys[i]);
}
roles = uifactory.addRadiosVertical("roles", "form.roles", formLayout, keys, values);
roles.select(ROLE_STUDENT, true);
String page = velocity_root + "/attributes.html";
FormLayoutContainer attrlayout = FormLayoutContainer.createCustomFormLayout("attributes", getTranslator(), page);
formLayout.add(attrlayout);
attrlayout.setLabel("form.attributes", null);
for (int i = 0; i < NUMATTR; i++) {
TextElement name = uifactory.addTextElement("attrname" + i, null, 255, "", attrlayout);
((AbstractComponent) name.getComponent()).setDomReplacementWrapperRequired(false);
name.setDisplaySize(12);
TextElement value = uifactory.addTextElement("attrvalue" + i, "form.equals", 255, "", attrlayout);
((AbstractComponent) value.getComponent()).setDomReplacementWrapperRequired(false);
value.setDisplaySize(12);
attrNames.add(name);
attrValues.add(value);
}
uifactory.addFormSubmitButton("submit", "command.preview", formLayout);
}
use of org.olat.core.gui.components.form.flexible.elements.TextElement in project OpenOLAT by OpenOLAT.
the class CheckboxAssessmentController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormDescription("assessment.checkbox.description");
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
if (isAdministrativeUser) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.username.i18nKey(), Cols.username.ordinal(), true, Cols.username.name()));
}
int i = 0;
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
int colIndex = CheckListAssessmentDataModel.USER_PROPS_OFFSET + i++;
if (userPropertyHandler == null)
continue;
String propName = userPropertyHandler.getName();
boolean visible = userManager.isMandatoryUserProperty(CheckListAssessmentController.USER_PROPS_ID, userPropertyHandler);
if (visible) {
FlexiColumnModel col;
if (UserConstants.FIRSTNAME.equals(propName) || UserConstants.LASTNAME.equals(propName)) {
col = new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, userPropertyHandler.getName(), true, propName, new StaticFlexiCellRenderer(userPropertyHandler.getName(), new TextFlexiCellRenderer()));
} else {
col = new DefaultFlexiColumnModel(true, userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, true, propName);
}
columnsModel.addFlexiColumnModel(col);
}
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.check.i18nKey(), Cols.check.ordinal(), true, Cols.check.name()));
if (withScore) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.points.i18nKey(), Cols.points.ordinal(), true, Cols.points.name()));
}
int numOfCheckbox = checkboxList.getList().size();
String[] keys = new String[numOfCheckbox];
String[] values = new String[numOfCheckbox];
List<Checkbox> checkbox = checkboxList.getList();
for (int j = 0; j < numOfCheckbox; j++) {
keys[j] = checkbox.get(j).getCheckboxId();
values[j] = checkbox.get(j).getTitle();
}
FormLayoutContainer selectCont = FormLayoutContainer.createDefaultFormLayout("checkbox_sel_cont", getTranslator());
formLayout.add(selectCont);
checkboxEl = uifactory.addDropdownSingleselect("checkbox", "select.checkbox", selectCont, keys, values, null);
checkboxEl.addActionListener(FormEvent.ONCHANGE);
checkboxEl.select(keys[0], true);
Checkbox box = checkboxList.getList().get(currentCheckboxIndex);
boolean hasPoints = box.getPoints() != null && box.getPoints().floatValue() > 0f;
boxRows = new ArrayList<CheckboxAssessmentRow>(initialRows.size());
for (CheckListAssessmentRow initialRow : initialRows) {
Boolean[] checked = new Boolean[numOfCheckbox];
if (initialRow.getChecked() != null) {
System.arraycopy(initialRow.getChecked(), 0, checked, 0, initialRow.getChecked().length);
}
Float[] scores = new Float[numOfCheckbox];
if (initialRow.getScores() != null) {
System.arraycopy(initialRow.getScores(), 0, scores, 0, initialRow.getScores().length);
}
CheckboxAssessmentRow row = new CheckboxAssessmentRow(initialRow, checked, scores);
String name = "box_" + boxRows.size() + "_";
String pointVal = "";
if (scores != null && scores.length > currentCheckboxIndex && scores[currentCheckboxIndex] != null) {
pointVal = AssessmentHelper.getRoundedScore(scores[currentCheckboxIndex]);
}
TextElement pointEl = uifactory.addTextElement(name + "point", null, 5, pointVal, formLayout);
pointEl.setDisplaySize(5);
MultipleSelectionElement checkEl = uifactory.addCheckboxesHorizontal(name + "check", null, formLayout, onKeys, onValues);
checkEl.setDomReplacementWrapperRequired(false);
checkEl.addActionListener(FormEvent.ONCHANGE);
checkEl.setUserObject(row);
if (checked != null && checked.length > currentCheckboxIndex && checked[currentCheckboxIndex] != null && checked[currentCheckboxIndex].booleanValue()) {
checkEl.select(onKeys[0], true);
}
pointEl.setVisible(hasPoints);
row.setCheckedEl(checkEl);
row.setPointEl(pointEl);
boxRows.add(row);
}
model = new CheckboxAssessmentDataModel(boxRows, columnsModel, getLocale());
table = uifactory.addTableElement(getWindowControl(), "checkbox-list", model, getTranslator(), formLayout);
table.setCustomizeColumns(true);
table.setEditMode(true);
table.setAndLoadPersistedPreferences(ureq, "checkbox-assessment");
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonsCont);
uifactory.addFormSubmitButton("save", buttonsCont);
selectAllBoxButton = uifactory.addFormLink("selectall", buttonsCont, Link.BUTTON);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
}
use of org.olat.core.gui.components.form.flexible.elements.TextElement in project OpenOLAT by OpenOLAT.
the class AssessedIdentityCheckListController method forgeCheckboxWrapper.
private CheckboxWrapper forgeCheckboxWrapper(Checkbox checkbox, DBCheck check, boolean readOnly, FormItemContainer formLayout) {
String[] values = new String[] { translate(checkbox.getLabel().i18nKey()) };
String boxId = "box_" + checkbox.getCheckboxId();
MultipleSelectionElement boxEl = uifactory.addCheckboxesHorizontal(boxId, null, formLayout, onKeys, values);
boxEl.setEnabled(!readOnly && !coachCourseEnv.isCourseReadOnly());
boxEl.setLabel(checkbox.getTitle(), null, false);
boxEl.showLabel(true);
boxEl.addActionListener(FormEvent.ONCHANGE);
TextElement pointEl = null;
if (withScore && checkbox.getPoints() != null) {
String pointId = "point_" + checkbox.getCheckboxId();
String points;
if (check != null && check.getChecked() != null && check.getChecked().booleanValue()) {
points = AssessmentHelper.getRoundedScore(check.getScore());
} else {
points = null;
}
pointEl = uifactory.addTextElement(pointId, null, 16, points, formLayout);
pointEl.setDisplaySize(5);
pointEl.setEnabled(!coachCourseEnv.isCourseReadOnly());
Float maxScore = checkbox.getPoints();
if (maxScore != null) {
String maxValue = AssessmentHelper.getRoundedScore(maxScore);
pointEl.setExampleKey("checklist.point.example", new String[] { "0", maxValue });
}
// hide when not yet checked
if (check != null) {
pointEl.setVisible(check.getChecked());
} else {
pointEl.setVisible(false);
}
}
CheckboxWrapper wrapper = new CheckboxWrapper(checkbox, check, boxEl, pointEl);
boxEl.setUserObject(wrapper);
if (check != null && check.getChecked() != null && check.getChecked().booleanValue()) {
boxEl.select(onKeys[0], true);
wrapper.setDbCheckbox(check.getCheckbox());
}
return wrapper;
}
use of org.olat.core.gui.components.form.flexible.elements.TextElement in project OpenOLAT by OpenOLAT.
the class MetadatasStepController method validateFormLogic.
@Override
protected boolean validateFormLogic(UserRequest ureq) {
boolean allOk = true;
for (DueDateWrapper wrapper : wrappers) {
TextElement titleEl = wrapper.getTitleEl();
titleEl.clearError();
if (!StringHelper.containsNonWhitespace(titleEl.getValue())) {
titleEl.setErrorKey("form.legende.mandatory", null);
allOk &= false;
}
}
return allOk &= super.validateFormLogic(ureq);
}
Aggregations