use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class AttributeEasyRowAdderController method removeRowAt.
/**
* Internal method to remove the row at the given position.
*
* @param clickPos The row to be removed
*/
private void removeRowAt(final int clickPos) {
// 1) remove the form elements from the form container
flc.remove(flc.getFormComponent(columnAttribute.get(clickPos)));
columnAttribute.remove(clickPos);
flc.remove(flc.getFormComponent(columnOperator.get(clickPos)));
columnOperator.remove(clickPos);
flc.remove(flc.getFormComponent(columnValueText.get(clickPos)));
columnValueText.remove(clickPos);
flc.remove(flc.getFormComponent(columnValueSelection.get(clickPos)));
columnValueSelection.remove(clickPos);
flc.remove(flc.getFormComponent(columnAddRow.get(clickPos)));
columnAddRow.remove(clickPos);
flc.remove(flc.getFormComponent(columnRemoveRow.get(clickPos)));
columnRemoveRow.remove(clickPos);
// object of the form element and move the element in the element arrays
for (int move = clickPos; move < columnAttribute.size(); move++) {
FormItem oldPos = flc.getFormComponent(columnAttribute.get(move));
oldPos.setUserObject(Integer.valueOf(move));
oldPos = flc.getFormComponent(columnOperator.get(move));
oldPos.setUserObject(Integer.valueOf(move));
oldPos = flc.getFormComponent(columnValueText.get(move));
oldPos.setUserObject(Integer.valueOf(move));
oldPos = flc.getFormComponent(columnValueSelection.get(move));
oldPos.setUserObject(Integer.valueOf(move));
oldPos = flc.getFormComponent(columnAddRow.get(move));
oldPos.setUserObject(Integer.valueOf(move));
oldPos = flc.getFormComponent(columnRemoveRow.get(move));
oldPos.setUserObject(Integer.valueOf(move));
}
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class LecturesSearchFormController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
login = uifactory.addTextElement("login", "search.form.login", 128, "", formLayout);
login.setVisible(adminProps);
userPropertyHandlers = userManager.getUserPropertyHandlersFor(PROPS_IDENTIFIER, adminProps);
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler != null) {
FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, PROPS_IDENTIFIER, false, formLayout);
fi.setMandatory(false);
// DO NOT validate email field => see OLAT-3324, OO-155, OO-222
if (userPropertyHandler instanceof EmailProperty && fi instanceof TextElement) {
TextElement textElement = (TextElement) fi;
textElement.setItemValidatorProvider(null);
}
propFormItems.put(userPropertyHandler.getName(), fi);
}
}
bulkEl = uifactory.addTextAreaElement("bulk", 4, 72, "", formLayout);
bulkEl.setHelpText(translate("bulk.hint"));
bulkEl.setExampleKey("bulk.example", null);
List<RepositoryEntryLifecycle> cycles = lifecycleDao.loadPublicLifecycle();
String[] dateKeys;
String[] dateValues;
if (cycles.isEmpty()) {
dateKeys = new String[] { "none", "private" };
dateValues = new String[] { translate("dates.none"), translate("dates.private") };
} else {
dateKeys = new String[] { "none", "private", "public" };
dateValues = new String[] { translate("dates.none"), translate("dates.private"), translate("dates.public") };
}
dateTypesEl = uifactory.addRadiosVertical("dates", formLayout, dateKeys, dateValues);
dateTypesEl.select(dateKeys[0], true);
dateTypesEl.addActionListener(FormEvent.ONCHANGE);
List<RepositoryEntryLifecycle> filteredCycles = new ArrayList<>();
for (RepositoryEntryLifecycle cycle : cycles) {
if (cycle.getValidTo() == null) {
filteredCycles.add(cycle);
}
}
String[] publicKeys = new String[filteredCycles.size()];
String[] publicValues = new String[filteredCycles.size()];
int count = 0;
for (RepositoryEntryLifecycle cycle : filteredCycles) {
publicKeys[count] = cycle.getKey().toString();
StringBuilder sb = new StringBuilder(32);
boolean labelAvailable = StringHelper.containsNonWhitespace(cycle.getLabel());
if (labelAvailable) {
sb.append(cycle.getLabel());
}
if (StringHelper.containsNonWhitespace(cycle.getSoftKey())) {
if (labelAvailable)
sb.append(" - ");
sb.append(cycle.getSoftKey());
}
publicValues[count++] = sb.toString();
}
publicDatesEl = uifactory.addDropdownSingleselect("public.dates", formLayout, publicKeys, publicValues, null);
String privateDatePage = velocity_root + "/cycle_dates.html";
privateDatesCont = FormLayoutContainer.createCustomFormLayout("private.date", getTranslator(), privateDatePage);
privateDatesCont.setRootForm(mainForm);
privateDatesCont.setLabel("private.dates", null);
formLayout.add("private.date", privateDatesCont);
startDateEl = uifactory.addDateChooser("date.start", "date.start", null, privateDatesCont);
startDateEl.setElementCssClass("o_sel_repo_lifecycle_validfrom");
endDateEl = uifactory.addDateChooser("date.end", "date.end", null, privateDatesCont);
endDateEl.setElementCssClass("o_sel_repo_lifecycle_validto");
FormLayoutContainer buttonCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonCont);
uifactory.addFormSubmitButton("search", buttonCont);
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class CourseReminderEditController method initRuleForm.
protected RuleElement initRuleForm(UserRequest ureq, RuleSPI ruleSpi, ReminderRule rule) {
String id = Integer.toString(counter++);
String type = ruleSpi.getClass().getSimpleName();
SingleSelection typeEl = uifactory.addDropdownSingleselect("rule.type.".concat(id), null, rulesCont, typeKeys, typeValues, null);
typeEl.addActionListener(FormEvent.ONCHANGE);
for (String typeKey : typeKeys) {
if (type.equals(typeKey)) {
typeEl.select(typeKey, true);
}
}
FormLink addRuleButton = uifactory.addFormLink("add.rule.".concat(id), "add", "add.rule", null, rulesCont, Link.BUTTON);
addRuleButton.setIconLeftCSS("o_icon o_icon-fw o_icon_add");
addRuleButton.setElementCssClass("o_sel_course_add_rule");
FormLink deleteRuleButton = uifactory.addFormLink("delete.rule.".concat(id), "delete", "delete.rule", null, rulesCont, Link.BUTTON);
deleteRuleButton.setIconLeftCSS("o_icon o_icon-fw o_icon_delete_item");
deleteRuleButton.setElementCssClass("o_sel_course_delete_rule");
RuleEditorFragment editor = ruleSpi.getEditorFragment(rule, entry);
FormItem customItem = editor.initForm(rulesCont, this, ureq);
RuleElement ruleEl = new RuleElement(typeEl, addRuleButton, deleteRuleButton, editor, customItem);
typeEl.setUserObject(ruleEl);
addRuleButton.setUserObject(ruleEl);
deleteRuleButton.setUserObject(ruleEl);
return ruleEl;
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class CourseReminderEditController method doUpdateRuleForm.
private void doUpdateRuleForm(UserRequest ureq, RuleElement panelToUpdate, RuleSPI ruleSpi) {
// remove old editor
rulesCont.remove(panelToUpdate.getCustomItem());
// add new one
RuleEditorFragment editor = ruleSpi.getEditorFragment(null, entry);
FormItem customItem = editor.initForm(rulesCont, this, ureq);
panelToUpdate.setCustomItem(customItem, editor);
rulesCont.setDirty(true);
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class CustomDBController method updateUI.
public void updateUI() {
FormItem[] items = new FormItem[dbListLayout.getFormComponents().size()];
items = dbListLayout.getFormComponents().values().toArray(items);
for (FormItem item : items) {
dbListLayout.remove(item);
}
initialPanel.setDirty(true);
updateDBList(dbListLayout);
}
Aggregations