use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.
the class ShibbolethRegistrationUserPropertiesFrom method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// Add all available user fields to this form
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler != null) {
FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, USERPROPERTIES_FORM_IDENTIFIER, false, formLayout);
propFormItems.put(userPropertyHandler.getName(), fi);
if (fi instanceof TextElement) {
String value = shibbolethAttributes.getValueForUserPropertyName(userPropertyHandler.getName());
if (StringHelper.containsNonWhitespace(value)) {
TextElement formElement = (TextElement) fi;
formElement.setValue(value);
formElement.setEnabled(false);
}
}
}
}
FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
formLayout.add(buttonLayout);
uifactory.addFormSubmitButton("save", buttonLayout);
}
use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.
the class PortfolioConfigForm method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("pane.tab.portfolio_config.title");
String name = getName(mapEntry);
mapNameElement = uifactory.addStaticTextElement("map-name", "selected.map", name, formLayout);
mapNameElement.setVisible(map == null && binder == null);
previewMapLink = uifactory.addFormLink("preview", "selected.map", "selected.map", formLayout, Link.LINK);
previewMapLink.setCustomEnabledLinkCSS("o_preview");
previewMapLink.setIconLeftCSS("o_icon o_icon-fw o_icon_preview");
previewMapLink.getComponent().setCustomDisplayText(name);
previewMapLink.setVisible(map != null || binder != null);
previewMapLink.setElementCssClass("o_sel_preview_map");
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutContainer = (FormLayoutContainer) formLayout;
FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonGroupLayout.setRootForm(mainForm);
layoutContainer.add(buttonGroupLayout);
chooseMapLink = uifactory.addFormLink("select_or_import.map", buttonGroupLayout, Link.BUTTON);
chooseMapLink.setElementCssClass("o_sel_map_choose_repofile");
changeMapLink = uifactory.addFormLink("select.map", buttonGroupLayout, Link.BUTTON);
changeMapLink.setElementCssClass("o_sel_map_change_repofile");
editMapLink = uifactory.addFormLink("edit.map", buttonGroupLayout, Link.BUTTON);
editMapLink.setElementCssClass("o_sel_edit_map");
editMapLink.setTitle("Hello world edit");
chooseMapLink.setVisible(map == null && binder == null);
chooseMapLink.setEnabled(!inUse);
chooseMapLink.setTextReasonForDisabling(translate("select.map.disabled.msg"));
changeMapLink.setVisible(map != null || binder != null);
changeMapLink.setEnabled(!inUse);
changeMapLink.setTextReasonForDisabling(translate("select.map.disabled.msg"));
editMapLink.setVisible(map != null || binder != null);
}
}
use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.
the class CheckListAssessmentController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormDescription("coach.desc");
setFormContextHelp("Assessment#_checklist_manage");
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
if (dueDate != null) {
layoutCont.contextPut("dueDate", dueDate);
}
}
FlexiTableSortOptions options = new FlexiTableSortOptions();
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
if (isAdministrativeUser) {
options.setDefaultOrderBy(new SortKey(Cols.username.name(), true));
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(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);
if (options.getDefaultOrderBy() == null) {
options.setDefaultOrderBy(new SortKey(propName, true));
}
}
}
int numOfCheckbox = checkboxList.getNumOfCheckbox();
List<Checkbox> boxList = checkboxList.getList();
int j = 0;
for (Checkbox box : boxList) {
int colIndex = CheckListAssessmentDataModel.CHECKBOX_OFFSET + j++;
String colName = "checkbox_" + colIndex;
DefaultFlexiColumnModel column = new DefaultFlexiColumnModel(true, colName, colIndex, true, colName);
column.setHeaderLabel(StringHelper.escapeHtml(box.getTitle()));
columnsModel.addFlexiColumnModel(column);
}
if (withScore) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.totalPoints.i18nKey(), Cols.totalPoints.ordinal(), true, "points"));
}
if (coachCourseEnv.isCourseReadOnly()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.view.checkbox", translate("table.header.view.checkbox"), "view"));
} else {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.edit.checkbox", translate("table.header.edit.checkbox"), "edit"));
}
model = new CheckListAssessmentDataModel(checkboxList, new ArrayList<>(), columnsModel, getLocale());
table = uifactory.addTableElement(getWindowControl(), "checkbox-list", model, getTranslator(), formLayout);
if (coachCourseEnv instanceof UserCourseEnvironmentImpl) {
UserCourseEnvironmentImpl env = (UserCourseEnvironmentImpl) coachCourseEnv;
List<BusinessGroup> coachedGroups = env.getCoachedGroups();
List<FlexiTableFilter> filters = new ArrayList<>(coachedGroups.size() + 1);
filters.add(new FlexiTableFilter(translate("filter.all"), "all"));
for (int k = 0; k < coachedGroups.size(); k++) {
BusinessGroup group = coachedGroups.get(k);
String groupName = StringHelper.escapeHtml(group.getName());
filters.add(new FlexiTableFilter(groupName, group.getKey().toString()));
}
table.setFilters("participants", filters, false);
}
table.setExportEnabled(true);
table.setCustomizeColumns(true);
FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
table.setSortSettings(sortOptions);
table.setAndLoadPersistedPreferences(ureq, "checklist-assessment");
pdfExportButton = uifactory.addFormLink("pdf.export", formLayout, Link.BUTTON);
pdfExportButton.setEnabled(numOfCheckbox > 0);
checkedPdfExportButton = uifactory.addFormLink("pdf.export.checked", formLayout, Link.BUTTON);
checkedPdfExportButton.setEnabled(numOfCheckbox > 0);
editButton = uifactory.addFormLink("edit", formLayout, Link.BUTTON);
editButton.setEnabled(numOfCheckbox > 0);
editButton.setVisible(!coachCourseEnv.isCourseReadOnly());
saveButton = uifactory.addFormSubmitButton("save", formLayout);
saveButton.getComponent().setSpanAsDomReplaceable(true);
saveButton.setVisible(false);
cancelButton = uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
cancelButton.setVisible(false);
boxAssessmentButton = uifactory.addFormLink("box.assessment", formLayout, Link.BUTTON);
boxAssessmentButton.setEnabled(numOfCheckbox > 0);
boxAssessmentButton.setVisible(!coachCourseEnv.isCourseReadOnly());
}
use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.
the class CheckListRunController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
boolean readOnly = isReadOnly();
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("readOnly", Boolean.valueOf(readOnly));
if (dueDate != null) {
layoutCont.contextPut("dueDate", dueDate);
layoutCont.contextPut("in-due-date", isPanelOpen(ureq, "due-date", true));
if (dueDate.compareTo(new Date()) < 0) {
layoutCont.contextPut("afterDueDate", Boolean.TRUE);
}
}
layoutCont.contextPut("withScore", new Boolean(withScore));
if (courseNode.getModuleConfiguration().getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD, false)) {
HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, courseNode, this.mainForm);
if (highScoreCtr.isViewHighscore()) {
Component highScoreComponent = highScoreCtr.getInitialComponent();
layoutCont.put("highScore", highScoreComponent);
}
}
List<DBCheck> checks = checkboxManager.loadCheck(getIdentity(), courseOres, courseNode.getIdent());
Map<String, DBCheck> uuidToCheckMap = new HashMap<>();
for (DBCheck check : checks) {
uuidToCheckMap.put(check.getCheckbox().getCheckboxId(), check);
}
List<Checkbox> list = checkboxList.getList();
List<CheckboxWrapper> wrappers = new ArrayList<>(list.size());
for (Checkbox checkbox : list) {
DBCheck check = uuidToCheckMap.get(checkbox.getCheckboxId());
CheckboxWrapper wrapper = forgeCheckboxWrapper(checkbox, check, readOnly, formLayout);
layoutCont.add(wrapper.getCheckboxEl());
wrappers.add(wrapper);
}
layoutCont.contextPut("checkboxList", wrappers);
if (withScore || withPassed) {
layoutCont.contextPut("enableScoreInfo", Boolean.TRUE);
exposeConfigToVC(ureq, layoutCont);
exposeUserDataToVC(ureq, layoutCont);
} else {
layoutCont.contextPut("enableScoreInfo", Boolean.FALSE);
}
}
}
use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.
the class CheckboxEditController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String title = checkbox.getTitle();
titleEl = uifactory.addTextElement("checkbox.title", "checkbox.title", 255, title, formLayout);
String[] releaseKeys = new String[] { CheckboxReleaseEnum.userAndCoach.name(), CheckboxReleaseEnum.coachOnly.name() };
String[] releaseValues = new String[] { translate("release.userAndCoach"), translate("release.coachOnly") };
releaseEl = uifactory.addDropdownSingleselect("release", formLayout, releaseKeys, releaseValues, null);
if (checkbox.getRelease() != null) {
releaseEl.select(checkbox.getRelease().name(), true);
}
String[] labelKeys = new String[CheckboxLabelEnum.values().length];
String[] labelValues = new String[CheckboxLabelEnum.values().length];
for (int i = CheckboxLabelEnum.values().length; i-- > 0; ) {
labelKeys[i] = CheckboxLabelEnum.values()[i].name();
labelValues[i] = translate(CheckboxLabelEnum.values()[i].i18nKey());
}
labelEl = uifactory.addDropdownSingleselect("label", formLayout, labelKeys, labelValues, null);
if (checkbox.getLabel() != null) {
labelEl.select(checkbox.getLabel().name(), true);
}
String[] onKeys = new String[] { "on" };
String[] onValues = new String[] { translate("award.point.on") };
awardPointEl = uifactory.addCheckboxesHorizontal("points", formLayout, onKeys, onValues);
awardPointEl.setVisible(withScore);
awardPointEl.addActionListener(FormEvent.ONCHANGE);
if (checkbox.getPoints() != null) {
awardPointEl.select(onKeys[0], true);
}
String points = checkbox.getPoints() == null ? null : Float.toString(checkbox.getPoints().floatValue());
pointsEl = uifactory.addTextElement("numofpoints", null, 10, points, formLayout);
pointsEl.setVisible(withScore && awardPointEl.isAtLeastSelected(1));
pointsEl.setDisplaySize(5);
String desc = checkbox.getDescription();
descriptionEl = uifactory.addRichTextElementForStringDataMinimalistic("description", "description", desc, 5, -1, formLayout, getWindowControl());
fileEl = uifactory.addFileElement(getWindowControl(), "file", formLayout);
fileEl.addActionListener(FormEvent.ONCHANGE);
String template = velocity_root + "/delete_file.html";
deleteFileCont = FormLayoutContainer.createCustomFormLayout("delete", getTranslator(), template);
formLayout.add(deleteFileCont);
downloadFileLink = uifactory.addFormLink("download", checkbox.getFilename(), null, deleteFileCont, Link.NONTRANSLATED);
deleteFileLink = uifactory.addFormLink("deleteFile", "delete", null, deleteFileCont, Link.BUTTON);
deleteFileCont.setVisible(StringHelper.containsNonWhitespace(checkbox.getFilename()));
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonsCont);
uifactory.addFormSubmitButton("save", buttonsCont);
deleteLink = uifactory.addFormLink("delete", buttonsCont, Link.BUTTON);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
}
Aggregations