use of org.olat.core.gui.components.form.flexible.FormItem in project openolat by klemens.
the class EditHTMLTaskController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
formLayout.setElementCssClass("o_sel_course_gta_edit_task_form");
String title = task.getTitle() == null ? "" : task.getTitle();
titleEl = uifactory.addTextElement("title", "task.title", 128, title, formLayout);
titleEl.setElementCssClass("o_sel_course_gta_upload_task_title");
titleEl.setMandatory(true);
String description = task.getDescription() == null ? "" : task.getDescription();
descriptionEl = uifactory.addTextAreaElement("descr", "task.description", 2048, 10, -1, true, description, formLayout);
contentEditor = new HTMLEditorController(ureq, getWindowControl(), taskContainer, task.getFilename(), null, "media", true, false, false, mainForm);
contentEditor.getRichTextConfiguration().disableMedia();
contentEditor.getRichTextConfiguration().setAllowCustomMediaFactory(false);
listenTo(contentEditor);
FormItem editorItem = contentEditor.getInitialFormItem();
editorItem.setLabel("task.file", null);
formLayout.add(editorItem);
FormLayoutContainer buttonCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonCont.setRootForm(mainForm);
formLayout.add(buttonCont);
uifactory.addFormSubmitButton("save", buttonCont);
uifactory.addFormCancelButton("cancel", buttonCont, ureq, getWindowControl());
}
use of org.olat.core.gui.components.form.flexible.FormItem in project openolat by klemens.
the class LecturesSearchFormController method getSearchProperties.
private Map<String, String> getSearchProperties() {
Map<String, String> userPropertiesSearch = new HashMap<>();
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler != null) {
FormItem ui = propFormItems.get(userPropertyHandler.getName());
String uiValue = userPropertyHandler.getStringValue(ui);
if (userPropertyHandler.getName().startsWith("genericCheckboxProperty")) {
if (!"false".equals(uiValue)) {
userPropertiesSearch.put(userPropertyHandler.getName(), uiValue);
}
} else if (StringHelper.containsNonWhitespace(uiValue) && !uiValue.equals("-")) {
userPropertiesSearch.put(userPropertyHandler.getName(), uiValue);
}
}
}
return userPropertiesSearch;
}
use of org.olat.core.gui.components.form.flexible.FormItem in project openolat by klemens.
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 klemens.
the class LecturesSearchFormController method validate.
private boolean validate() {
boolean atLeastOne = false;
if (login.isVisible()) {
atLeastOne = isNotEmpty(login.getValue());
}
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler != null) {
FormItem ui = propFormItems.get(userPropertyHandler.getName());
String uiValue = userPropertyHandler.getStringValue(ui);
if (isNotEmpty(uiValue)) {
atLeastOne |= true;
}
}
}
if (isNotEmpty(bulkEl.getValue())) {
atLeastOne |= true;
}
if ("public".equals(dateTypesEl.getSelectedKey()) && publicDatesEl.isVisible() && publicDatesEl.isOneSelected()) {
atLeastOne |= true;
}
if ("private".equals(dateTypesEl.getSelectedKey()) && (startDateEl.getDate() != null && endDateEl.getDate() != null)) {
atLeastOne |= true;
}
if (!atLeastOne) {
showWarning("error.search.form.notempty");
}
return atLeastOne;
}
use of org.olat.core.gui.components.form.flexible.FormItem in project openolat by klemens.
the class FlexiTableClassicRenderer method renderCell.
private void renderCell(Renderer renderer, StringOutput target, FlexiTableComponent ftC, FlexiColumnModel fcm, int row, URLBuilder ubu, Translator translator, RenderResult renderResult) {
FlexiTableElementImpl ftE = ftC.getFlexiTableElement();
FlexiTableDataModel<?> dataModel = ftE.getTableDataModel();
int alignment = fcm.getAlignment();
String cssClass = (alignment == FlexiColumnModel.ALIGNMENT_LEFT ? "text-left" : (alignment == FlexiColumnModel.ALIGNMENT_RIGHT ? "text-right" : "text-center"));
target.append("<td class=\"").append(cssClass).append(" ").append("o_dnd_label", ftE.getColumnIndexForDragAndDropLabel() == fcm.getColumnIndex()).append("\">");
int columnIndex = fcm.getColumnIndex();
Object cellValue = columnIndex >= 0 ? dataModel.getValueAt(row, columnIndex) : null;
if (cellValue instanceof FormItem) {
FormItem formItem = (FormItem) cellValue;
formItem.setTranslator(translator);
if (ftE.getRootForm() != formItem.getRootForm()) {
formItem.setRootForm(ftE.getRootForm());
}
ftE.addFormItem(formItem);
if (formItem.isVisible()) {
formItem.getComponent().getHTMLRendererSingleton().render(renderer, target, formItem.getComponent(), ubu, translator, renderResult, null);
}
} else if (cellValue instanceof Component) {
Component cmp = (Component) cellValue;
cmp.setTranslator(translator);
if (cmp.isVisible()) {
cmp.getHTMLRendererSingleton().render(renderer, target, cmp, ubu, translator, renderResult, null);
}
} else {
fcm.getCellRenderer().render(renderer, target, cellValue, row, ftC, ubu, translator);
}
target.append("</td>");
}
Aggregations