use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.
the class UsrPropCfgTableController method buildPropertyHandlerTable.
/**
* builds the userPropertyHandler-Table
*/
private void buildPropertyHandlerTable() {
List<UserPropertyHandler> myHandlerList = usrPropCfgMng.getUserPropertiesConfigObject().getPropertyHandlers();
// first search for all group-values in the propertyHandlers
List<String> allGroupValues = new ArrayList<>();
for (UserPropertyHandler handler : myHandlerList) {
String group = handler.getGroup();
if (!allGroupValues.contains(group))
allGroupValues.add(group);
}
// take the defaults
for (int k = 0; k < GROUP_KEYS.length; k++) {
String group = GROUP_KEYS[k];
if (!allGroupValues.contains(group))
allGroupValues.add(group);
}
final String[] selectableGroups = allGroupValues.toArray(new String[0]);
// the table-rows
String handlerName;
SingleSelection groupDropdown;
FormToggle fi;
FormLink translateLink;
FormLink handlerLink;
String translatedName;
for (UserPropertyHandler handler : myHandlerList) {
handlerName = handler.getName();
// the group field
groupDropdown = uifactory.addDropdownSingleselect(FT_NAME_PREFIX_GRPN + handlerName, propTableFlc, selectableGroups, selectableGroups, null);
if (Arrays.asList(selectableGroups).contains(handler.getGroup())) {
groupDropdown.select(handler.getGroup(), true);
} else {
logWarn("could not set group-select to " + handler.getGroup() + " (" + handler.getName() + ")", null);
}
groupDropdown.setUserObject(handler);
groupDropdown.showLabel(false);
groupDropdown.addActionListener(FormEvent.ONCHANGE);
// the "active"-toggle button
fi = uifactory.addToggleButton(FT_NAME_PREFIX_TGL + handlerName, " ", propTableFlc, null, null);
if (usrPropCfgMng.getUserPropertiesConfigObject().isActiveHandler(handler))
fi.toggleOn();
else
fi.toggleOff();
if (!UsrPropCfgManager.canBeDeactivated(handler))
fi.setEnabled(false);
fi.setUserObject(handler);
rowToggleButtonsMap.put(handlerName, fi);
// the "translate" link
if (isPropertyHandlerTranslated(handler)) {
translateLink = uifactory.addFormLink(FT_NAME_PREFIX_TRANSL + handlerName, "upc.edittranslate", "label", propTableFlc, Link.LINK);
} else {
translateLink = uifactory.addFormLink(FT_NAME_PREFIX_TRANSL + handlerName, "upc.translate", "label", propTableFlc, Link.LINK);
translateLink.setCustomEnabledLinkCSS("o_ochre");
}
translateLink.setUserObject(handler);
// the "handler-config" link
if (handlerConfigCtrlFactory.hasConfig(handler)) {
handlerLink = uifactory.addFormLink(FT_NAME_PREFIX_HDNL + handlerName, "upc.hndlconfig", "label", propTableFlc, Link.LINK);
handlerLink.setUserObject(handler);
}
// put the translation (in the current language) for the property
translatedName = I18nManager.getInstance().getLocalizedString(UserPropertyHandler.class.getPackage().getName(), handler.i18nFormElementLabelKey(), null, getLocale(), true, true);
uifactory.addStaticTextElement(FT_NAME_PREFIX_TRANSNAME + handlerName, (translatedName == null ? "-" : translatedName), propTableFlc);
}
propTableFlc.contextPut("rows", myHandlerList);
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.
the class ExtendedSearchController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == searchButton) {
doSearch(ureq);
} else if (source instanceof SingleSelection) {
SingleSelection attrEl = (SingleSelection) source;
if (attrEl.isOneSelected()) {
Object uObject = attrEl.getUserObject();
if (uObject instanceof ConditionalQuery) {
ConditionalQuery query = (ConditionalQuery) uObject;
query.selectAttributeType(attrEl.getSelectedKey(), null);
}
}
} else if (source instanceof FormLink) {
FormLink button = (FormLink) source;
if (button.getCmd().startsWith("add")) {
ConditionalQuery query = (ConditionalQuery) button.getUserObject();
addParameter(query);
} else if (button.getCmd().startsWith("remove")) {
ConditionalQuery query = (ConditionalQuery) button.getUserObject();
removeParameter(query);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection 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.elements.SingleSelection in project OpenOLAT by OpenOLAT.
the class EPShareListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
// process all form-input fields and update data-model
secureListBox();
// policy might be persisted. check with validateFormLogic()
if (source == addPolicyButton) {
if (validateFormLogic(ureq)) {
addEPSharePolicyWrapper(null);
initPolicyUI();
}
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
Object userObject = link.getUserObject();
if (userObject instanceof EPSharePolicyWrapper) {
EPSharePolicyWrapper wrapper = (EPSharePolicyWrapper) userObject;
if (link.getName().startsWith("map.share.policy.add")) {
if (validateFormLogic(ureq)) {
addEPSharePolicyWrapper(wrapper);
initPolicyUI();
}
} else if (link.getName().startsWith("map.share.policy.delete")) {
removeEPSharePolicyWrapper(wrapper);
initPolicyUI();
} else if (link.getName().startsWith("map.share.policy.invite")) {
if (validateFormLogic(ureq)) {
sendInvitation(ureq, wrapper);
initPolicyUI();
}
} else if (link.getName().startsWith("choose.group")) {
doSelectGroup(ureq, wrapper);
} else if (link.getName().startsWith("choose.identity")) {
doSelectIdentity(ureq, wrapper);
}
} else if (userObject instanceof EPShareGroupWrapper) {
EPShareGroupWrapper wrapper = (EPShareGroupWrapper) userObject;
wrapper.remove();
initPolicyUI();
} else if (userObject instanceof EPShareUserWrapper) {
EPShareUserWrapper wrapper = (EPShareUserWrapper) userObject;
wrapper.remove();
initPolicyUI();
}
} else if (source instanceof SingleSelection && source.getUserObject() instanceof EPSharePolicyWrapper) {
SingleSelection selection = (SingleSelection) source;
if (selection.isOneSelected()) {
String type = selection.getSelectedKey();
EPSharePolicyWrapper wrapper = (EPSharePolicyWrapper) selection.getUserObject();
changeType(wrapper, type);
}
initPolicyUI();
}
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.
the class EPStructureDetailsController method formOK.
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#formOK(org.olat.core.gui.UserRequest)
*/
@Override
protected void formOK(final UserRequest ureq) {
editStructure = ePFMgr.reloadPortfolioStructure(editStructure);
editStructure.setTitle(titleEl.getValue());
editStructure.setDescription(descriptionEl.getValue());
editStructure.setArtefactRepresentationMode(viewRadio.getSelectedKey());
if (rootStructure instanceof EPStructuredMapTemplate && restrictionElements != null) {
clearErrors();
editStructure.getCollectRestrictions().clear();
setCollectRestrictions();
for (final SingleSelection restrictionElement : restrictionElements) {
final CollectRestriction restriction = (CollectRestriction) restrictionElement.getUserObject();
if (restriction.isValid()) {
final CollectRestriction cr = new CollectRestriction(restriction);
editStructure.getCollectRestrictions().add(cr);
}
}
}
ePFMgr.savePortfolioStructure(editStructure);
fireEvent(ureq, new EPStructureEvent(EPStructureEvent.CHANGE, editStructure));
}
Aggregations