use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class HomePageSettingsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
boolean firstGroup = true;
List<UserPropertyHandler> homepagePropertyHanders = userManager.getUserPropertyHandlersFor(HomePageConfig.class.getCanonicalName(), isAdministrativeUser);
Map<String, FormLayoutContainer> groupContainerMap = new HashMap<>();
HomePageConfig conf = hpcm.loadConfigFor(identityToModify.getName());
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null) {
continue;
}
// add spacer if necessary (i.e. when group name changes)
String group = userPropertyHandler.getGroup();
FormLayoutContainer groupContainer;
if (groupContainerMap.containsKey(group)) {
groupContainer = groupContainerMap.get(group);
} else {
groupContainer = FormLayoutContainer.createDefaultFormLayout("group." + group, getTranslator());
groupContainer.setFormTitle(translate("form.group." + group));
formLayout.add(groupContainer);
groupContainerMap.put(group, groupContainer);
if (firstGroup) {
groupContainer.setFormContextHelp("Configuration");
firstGroup = false;
}
}
if (homepagePropertyHanders.contains(userPropertyHandler)) {
// add checkbox to container if configured for homepage usage identifier
String checkboxName = userPropertyHandler.getName();
MultipleSelectionElement publishCheckbox = uifactory.addCheckboxesHorizontal(checkboxName, userPropertyHandler.i18nFormElementLabelKey(), groupContainer, checkKeys, checkValues);
boolean isEnabled = conf.isEnabled(userPropertyHandler.getName());
publishCheckbox.select(checkKeys[0], isEnabled);
publishCheckbox.setUserObject(userPropertyHandler.getName());
// Mandatory homepage properties can not be changed by user
if (userManager.isMandatoryUserProperty(HomePageConfig.class.getCanonicalName(), userPropertyHandler)) {
publishCheckbox.select(checkKeys[0], true);
publishCheckbox.setEnabled(false);
} else {
publishCheckbox.addActionListener(FormEvent.ONCHANGE);
}
}
}
String previewPage = velocity_root + "/homepage_preview.html";
previewContainer = FormLayoutContainer.createCustomFormLayout("preview", getTranslator(), previewPage);
previewContainer.setFormTitle(translate("tab.preview"));
previewContainer.setRootForm(mainForm);
formLayout.add(previewContainer);
updatePreview(ureq);
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class HomePageSettingsController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source instanceof MultipleSelectionElement) {
MultipleSelectionElement publishCheckbox = (MultipleSelectionElement) source;
if (publishCheckbox.isEnabled()) {
boolean enabled = publishCheckbox.isAtLeastSelected(1);
String propName = (String) publishCheckbox.getUserObject();
// load and update config
HomePageConfig conf = hpcm.loadConfigFor(identityToModify.getName());
conf.setEnabled(propName, enabled);
hpcm.saveConfigTo(identityToModify.getName(), conf);
updatePreview(ureq, conf);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class BGConfigToolsStepController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
boolean first = true;
String containerPage = velocity_root + "/tool_config_container.html";
String[] availableTools = CollaborationToolsFactory.getInstance().getAvailableTools().clone();
for (String k : availableTools) {
if (k.equals(CollaborationTools.TOOL_CHAT) || k.equals(CollaborationTools.TOOL_NEWS)) {
continue;
}
String[] keys = new String[] { "on" };
String[] values = new String[] { translate("collabtools.named." + k) };
String i18n = first ? "config.tools.desc" : null;
MultipleSelectionElement selectEl = uifactory.addCheckboxesHorizontal(k, i18n, formLayout, keys, values);
selectEl.addActionListener(FormEvent.ONCHANGE);
toolList.add(selectEl);
ToolConfig config = new ToolConfig(k);
config.configContainer = FormLayoutContainer.createCustomFormLayout("config.container." + k, getTranslator(), containerPage);
config.configContainer.contextPut("tool", k);
config.configContainer.setVisible(false);
config.configContainer.setRootForm(mainForm);
formLayout.add(config.configContainer);
config.enableEl = uifactory.addRadiosHorizontal("config.enable." + k, null, config.configContainer, enableKeys, enableValues);
config.enableEl.addActionListener(FormEvent.ONCHANGE);
config.enableEl.select("off", true);
enableList.add(config.enableEl);
config.enableEl.setUserObject(config);
if (k.equals(CollaborationTools.TOOL_CALENDAR)) {
config.calendarCtrl = new CalendarToolSettingsController(ureq, getWindowControl(), mainForm, CollaborationTools.CALENDAR_ACCESS_OWNERS);
config.configContainer.add("calendar", config.calendarCtrl.getInitialFormItem());
config.calendarCtrl.getInitialFormItem().setVisible(false);
} else if (k.equals(CollaborationTools.TOOL_FOLDER)) {
// add folder access configuration
config.folderCtrl = new FolderToolSettingsController(ureq, getWindowControl(), mainForm, CollaborationTools.FOLDER_ACCESS_OWNERS);
config.configContainer.add("folder", config.folderCtrl.getInitialFormItem());
config.folderCtrl.getInitialFormItem().setVisible(false);
// add quota configuration for admin only
if (ureq.getUserSession().getRoles().isOLATAdmin()) {
Quota quota = quotaManager.createQuota(null, null, null);
config.quotaCtrl = new BGConfigQuotaController(ureq, getWindowControl(), quota, mainForm);
config.configContainer.add("quota", config.quotaCtrl.getInitialFormItem());
config.quotaCtrl.getInitialFormItem().setVisible(false);
}
}
selectEl.setUserObject(config);
first = false;
}
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class TeacherRollCallController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == tableEl) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
String cmd = se.getCommand();
TeacherRollCallRow row = tableModel.getObject(se.getIndex());
if ("all".equals(cmd)) {
doCheckAllRow(row);
}
}
} else if (source instanceof MultipleSelectionElement) {
MultipleSelectionElement check = (MultipleSelectionElement) source;
TeacherRollCallRow row = (TeacherRollCallRow) check.getUserObject();
if (row.getAuthorizedAbsence() == check) {
doAuthorizedAbsence(row, check);
if (check.isAtLeastSelected(1)) {
doCalloutReasonAbsence(ureq, check.getFormDispatchId() + "_C_0", row);
}
} else {
doCheckRow(row, check);
}
} else if (reopenButton == source) {
doReopen(ureq);
} else if (closeLectureBlocksButton == source) {
if (validateFormLogic(ureq)) {
saveLectureBlocks();
doConfirmCloseLectureBlock(ureq);
}
} else if (cancelLectureBlockButton == source) {
saveLectureBlocks();
doConfirmCancelLectureBlock(ureq);
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if (cmd != null && cmd.startsWith("abs_reason_")) {
TeacherRollCallRow row = (TeacherRollCallRow) link.getUserObject();
doCalloutReasonAbsence(ureq, link.getFormDispatchId(), row);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.
the class EPArtefactTypeSelectionController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormDescription("filter.type.intro");
String[] keys = new String[] { "onoff" };
String[] values = new String[] { translate("filter.type.enabled") };
List<EPArtefactHandler<?>> handlers = portfolioModule.getAllAvailableArtefactHandlers();
typeCmpList = new ArrayList<MultipleSelectionElement>();
for (EPArtefactHandler<?> handler : handlers) {
Translator handlerTrans = handler.getHandlerTranslator(getTranslator());
this.flc.setTranslator(handlerTrans);
String handlerClass = PortfolioFilterController.HANDLER_PREFIX + handler.getClass().getSimpleName() + PortfolioFilterController.HANDLER_TITLE_SUFFIX;
MultipleSelectionElement chkBox = uifactory.addCheckboxesHorizontal(handlerClass, formLayout, keys, values);
if (selectedTypeList != null && selectedTypeList.contains(handler.getType())) {
chkBox.select(keys[0], true);
}
chkBox.addActionListener(FormEvent.ONCHANGE);
chkBox.setUserObject(handler.getType());
typeCmpList.add(chkBox);
}
uifactory.addFormSubmitButton("filter.type.submit", formLayout);
}
Aggregations