use of org.olat.core.commons.services.license.LicenseHandler in project openolat by klemens.
the class LicenseAdminConfigController method doEnableHandlers.
private void doEnableHandlers() {
Collection<String> selectedKeys = enabledEl.getSelectedKeys();
for (LicenseHandler handler : licenseHandlers) {
boolean enabled = selectedKeys.contains(handler.getType());
licenseModule.setEnabled(handler.getType(), enabled);
}
initLicenseTypesTable();
loadModel();
initHandlerConfigs();
showInfo("admin.start.indexer");
}
use of org.olat.core.commons.services.license.LicenseHandler in project openolat by klemens.
the class LicenseAdminConfigController method doActivateLicenseType.
private void doActivateLicenseType(MultipleSelectionElement multipleSelectionElement) {
boolean doActivate = multipleSelectionElement.isAtLeastSelected(1) ? true : false;
HandlerLicenseType handlerLicenseType = (HandlerLicenseType) multipleSelectionElement.getUserObject();
LicenseHandler handler = handlerLicenseType.getHandler();
LicenseType licenseType = handlerLicenseType.getLicenseType();
if (doActivate) {
licenseService.activate(handler, licenseType);
reloadDefaultLicenseTypeEl(handler);
} else {
if (isDefaultLicenseType(handler, licenseType)) {
showWarning("error.is.default.license.type");
loadModel();
} else {
licenseService.deactivate(handler, licenseType);
reloadDefaultLicenseTypeEl(handler);
}
}
// checkboxes of enabled handlers was deactivated after deactivating a license type.
initGeneralElements();
}
use of org.olat.core.commons.services.license.LicenseHandler in project openolat by klemens.
the class LicenseAdminConfigController method createActivationCheckBoxes.
private List<MultipleSelectionElement> createActivationCheckBoxes(LicenseType licenseType, List<LicenseHandler> handlers) {
List<MultipleSelectionElement> formItems = new ArrayList<>();
for (LicenseHandler handler : handlers) {
boolean handlerEnabled = licenseModule.isEnabled(handler);
if (handlerEnabled) {
String toggleName = "toggle-" + licenseType.getKey() + handler.getType();
MultipleSelectionElement toggle = uifactory.addCheckboxesHorizontal(toggleName, null, flc, keys, values);
toggle.setUserObject(new HandlerLicenseType(licenseType, handler));
toggle.addActionListener(FormEvent.ONCHANGE);
toggle.setAjaxOnly(true);
toggle.select(keys[0], licenseService.isActive(handler, licenseType));
formItems.add(toggle);
}
}
return formItems;
}
use of org.olat.core.commons.services.license.LicenseHandler in project OpenOLAT by OpenOLAT.
the class LicenseAdminConfigController method initHandlerConfigs.
private void initHandlerConfigs() {
List<FormLayoutContainer> handlerConfigs = new ArrayList<>(licenseHandlers.size());
for (LicenseHandler handler : licenseHandlers) {
boolean handlerEnabled = licenseModule.isEnabled(handler);
if (handlerEnabled) {
String handlerType = handler.getType();
FormLayoutContainer handlerCont = FormLayoutContainer.createDefaultFormLayout("handler-" + handlerType, getTranslator());
handlerCont.setRootForm(mainForm);
flc.add("handler-" + handlerType, handlerCont);
uifactory.addSpacerElement("spacer-" + handlerType, handlerCont, false);
SpacerElement handlerName = uifactory.addSpacerElement("name-" + handlerType, handlerCont, true);
handlerName.setLabel(handler.getTitle(getLocale()), null, false);
SingleSelection defaultLicenseTypeEl = uifactory.addDropdownSingleselect(DEFAULT_LICENSE_TYPE_PREFIX + handlerType, "admin.default.license.type", handlerCont, new String[0], new String[0], null);
defaultLicenseTypeEl.setUserObject(handler);
defaultLicenseTypeEl.addActionListener(FormEvent.ONCHANGE);
defaultLicenseTypeEls.put(handlerType, defaultLicenseTypeEl);
reloadDefaultLicenseTypeEl(handler);
String[] licensorCreatorKeys = licensorCreators.stream().map(LicensorCreator::getType).toArray(String[]::new);
String[] licensorCreatorValues = licensorCreators.stream().map(creator -> creator.getName(getLocale())).toArray(String[]::new);
SingleSelection licensorCreatorEl = uifactory.addDropdownSingleselect(LICENSOR_CREATOR_TYPE_PREFIX + handlerType, "admin.licensor.creator", handlerCont, licensorCreatorKeys, licensorCreatorValues, null);
licensorCreatorEl.setUserObject(handler);
String creatorType = licenseModule.getLicensorCreatorType(handler);
if (creatorType != null) {
licensorCreatorEl.select(creatorType, true);
}
licensorCreatorEl.addActionListener(FormEvent.ONCHANGE);
if (CONSTANT_CREATOR_TYPE.equals(creatorType)) {
String licensorConstant = licenseModule.getConstantLicensor(handler);
uifactory.addStaticTextElement("lgc-" + handlerType, "admin.licensor.constant", licensorConstant, handlerCont);
FormLink editLicensorConstantLink = uifactory.addFormLink("lgb-", "admin.licensor.constant.edit", "", handlerCont, Link.BUTTON);
editLicensorConstantLink.setUserObject(handler);
}
handlerConfigs.add(handlerCont);
}
}
flc.getFormItemComponent().contextPut("handlerConfigs", handlerConfigs);
}
use of org.olat.core.commons.services.license.LicenseHandler in project OpenOLAT by OpenOLAT.
the class LicenseAdminConfigController method createActivationCheckBoxes.
private List<MultipleSelectionElement> createActivationCheckBoxes(LicenseType licenseType, List<LicenseHandler> handlers) {
List<MultipleSelectionElement> formItems = new ArrayList<>();
for (LicenseHandler handler : handlers) {
boolean handlerEnabled = licenseModule.isEnabled(handler);
if (handlerEnabled) {
String toggleName = "toggle-" + licenseType.getKey() + handler.getType();
MultipleSelectionElement toggle = uifactory.addCheckboxesHorizontal(toggleName, null, flc, keys, values);
toggle.setUserObject(new HandlerLicenseType(licenseType, handler));
toggle.addActionListener(FormEvent.ONCHANGE);
toggle.setAjaxOnly(true);
toggle.select(keys[0], licenseService.isActive(handler, licenseType));
formItems.add(toggle);
}
}
return formItems;
}
Aggregations