use of org.olat.core.gui.components.form.flexible.elements.FormToggle in project openolat by klemens.
the class UsrPropContextEditController method formInnerEvent.
@Override
@SuppressWarnings("unused")
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source instanceof FormToggle) {
int activeCount = 0;
FormToggle sourceToggle = (FormToggle) source;
UserPropertyHandler handler = (UserPropertyHandler) sourceToggle.getUserObject();
if (sourceToggle.getName().startsWith(FT_NAME_PREFIX_MAND)) {
context.setAsMandatoryUserProperty(handler, sourceToggle.isOn());
} else if (sourceToggle.getName().startsWith(FT_NAME_PREFIX_ADMN)) {
context.setAsAdminstrativeUserOnly(handler, sourceToggle.isOn());
} else if (sourceToggle.getName().startsWith(FT_NAME_PREFIX_USR)) {
context.setAsUserViewReadOnly(handler, sourceToggle.isOn());
} else if (sourceToggle.getName().startsWith(FT_NAME_PREFIX_INCL)) {
if (sourceToggle.isOn()) {
// activate the toggles on this row
List<FormItem> rowFormItems = rowToggleButtonsMap.get(handler.getName());
for (FormItem item : rowFormItems) {
item.setEnabled(true);
item.setVisible(true);
}
context.addPropertyHandler(handler);
includedPropertiesCount++;
} else {
// this is removing property from context
// deactivate the toggles on this row
List<FormItem> rowFormItems = rowToggleButtonsMap.get(handler.getName());
for (FormItem item : rowFormItems) {
item.setEnabled(false);
item.setVisible(false);
}
context.removePropertyHandler(handler);
includedPropertiesCount--;
if (!UsrPropCfgManager.canBeOptionalInContext(handler, contextName)) {
showInfo("upc.deact_infotext");
}
}
}
// something was toggled, save changes!
usrPropCfgMng.saveUserPropertiesConfig();
contTableFlc.contextPut("activePropCount", includedPropertiesCount);
} else if (source instanceof FormLink) {
// a link, (up/down)
UserPropertyHandler handler = (UserPropertyHandler) source.getUserObject();
if (source.getName().startsWith(FT_NAME_PREFIX_MUP)) {
context.moveHandlerUp(handler);
usrPropCfgMng.saveUserPropertiesConfig();
buildPropertyHandlerListFromContext();
} else if (source.getName().startsWith(FT_NAME_PREFIX_MDN)) {
context.moveHandlerDown(handler);
usrPropCfgMng.saveUserPropertiesConfig();
buildPropertyHandlerListFromContext();
}
}
}
use of org.olat.core.gui.components.form.flexible.elements.FormToggle in project openolat by klemens.
the class PortfolioFilterController method resetTagLinks.
private void resetTagLinks() {
for (FormToggle link : tagCmpList) {
link.toggleOff();
selectedTagsList.clear();
}
tagEditBtn.toggleOff();
}
use of org.olat.core.gui.components.form.flexible.elements.FormToggle in project OpenOLAT by OpenOLAT.
the class UsrPropContextEditController method formInnerEvent.
@Override
@SuppressWarnings("unused")
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source instanceof FormToggle) {
int activeCount = 0;
FormToggle sourceToggle = (FormToggle) source;
UserPropertyHandler handler = (UserPropertyHandler) sourceToggle.getUserObject();
if (sourceToggle.getName().startsWith(FT_NAME_PREFIX_MAND)) {
context.setAsMandatoryUserProperty(handler, sourceToggle.isOn());
} else if (sourceToggle.getName().startsWith(FT_NAME_PREFIX_ADMN)) {
context.setAsAdminstrativeUserOnly(handler, sourceToggle.isOn());
} else if (sourceToggle.getName().startsWith(FT_NAME_PREFIX_USR)) {
context.setAsUserViewReadOnly(handler, sourceToggle.isOn());
} else if (sourceToggle.getName().startsWith(FT_NAME_PREFIX_INCL)) {
if (sourceToggle.isOn()) {
// activate the toggles on this row
List<FormItem> rowFormItems = rowToggleButtonsMap.get(handler.getName());
for (FormItem item : rowFormItems) {
item.setEnabled(true);
item.setVisible(true);
}
context.addPropertyHandler(handler);
includedPropertiesCount++;
} else {
// this is removing property from context
// deactivate the toggles on this row
List<FormItem> rowFormItems = rowToggleButtonsMap.get(handler.getName());
for (FormItem item : rowFormItems) {
item.setEnabled(false);
item.setVisible(false);
}
context.removePropertyHandler(handler);
includedPropertiesCount--;
if (!UsrPropCfgManager.canBeOptionalInContext(handler, contextName)) {
showInfo("upc.deact_infotext");
}
}
}
// something was toggled, save changes!
usrPropCfgMng.saveUserPropertiesConfig();
contTableFlc.contextPut("activePropCount", includedPropertiesCount);
} else if (source instanceof FormLink) {
// a link, (up/down)
UserPropertyHandler handler = (UserPropertyHandler) source.getUserObject();
if (source.getName().startsWith(FT_NAME_PREFIX_MUP)) {
context.moveHandlerUp(handler);
usrPropCfgMng.saveUserPropertiesConfig();
buildPropertyHandlerListFromContext();
} else if (source.getName().startsWith(FT_NAME_PREFIX_MDN)) {
context.moveHandlerDown(handler);
usrPropCfgMng.saveUserPropertiesConfig();
buildPropertyHandlerListFromContext();
}
}
}
use of org.olat.core.gui.components.form.flexible.elements.FormToggle in project OpenOLAT by OpenOLAT.
the class UsrPropCfgTableController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
UserPropertyHandler handler = (UserPropertyHandler) source.getUserObject();
if (source instanceof FormToggle) {
FormToggle toggle = (FormToggle) source;
if (toggle.isOn()) {
usrPropCfgMng.getUserPropertiesConfigObject().setHandlerAsActive(handler, true);
usrPropCfgMng.saveUserPropertiesConfig();
} else {
deactPropertyYesNoCtrl = activateYesNoDialog(ureq, translate("upc.deact_confirmationtitle"), translate("upc.deact_confirmationtext"), deactPropertyYesNoCtrl);
deactPropertyYesNoCtrl.setUserObject(handler);
}
} else if (source instanceof SingleSelection) {
SingleSelection groupSel = (SingleSelection) source;
handler.setGroup(groupSel.getSelectedKey());
usrPropCfgMng.saveUserPropertiesConfig();
} else if (source instanceof FormLink) {
String itemname = source.getName();
if (itemname.startsWith(FT_NAME_PREFIX_TRANSL)) {
// open the singlekeyTranslator-controller callout
String key2Translate1 = handler.i18nFormElementLabelKey();
String key2Translate2 = handler.i18nColumnDescriptorLabelKey();
String[] keys2Translate = { key2Translate1, key2Translate2 };
singleKeyTrnsCtrl = new SingleKeyTranslatorController(ureq, getWindowControl(), keys2Translate, UserPropertyHandler.class);
listenTo(singleKeyTrnsCtrl);
removeAsListenerAndDispose(translatorCallout);
translatorCallout = new CloseableCalloutWindowController(ureq, getWindowControl(), singleKeyTrnsCtrl.getInitialComponent(), (FormLink) source, "Translate:: " + key2Translate1, false, null);
listenTo(translatorCallout);
translatorCallout.activate();
} else if (itemname.startsWith(FT_NAME_PREFIX_HDNL)) {
handlerConfigCtrl = handlerConfigCtrlFactory.getConfigController(ureq, getWindowControl(), handler);
listenTo(handlerConfigCtrl);
if (handlerConfigCtrl.getInitialComponent() != null) {
handlerPopupCtr = new CloseableModalController(getWindowControl(), "Save", handlerConfigCtrl.getInitialComponent(), true, translate("upc.handlerconfigtitle"), false);
handlerPopupCtr.activate();
}
}
}
}
use of org.olat.core.gui.components.form.flexible.elements.FormToggle in project OpenOLAT by OpenOLAT.
the class PortfolioFilterController method resetTypeLinks.
private void resetTypeLinks() {
for (FormToggle link : typeCmpList) {
link.toggleOff();
selectedTypeList.clear();
}
typeEditBtn.toggleOff();
}
Aggregations