Search in sources :

Example 6 with LicenseHandler

use of org.olat.core.commons.services.license.LicenseHandler in project OpenOLAT by OpenOLAT.

the class LicenseAdminConfigController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (enabledEl == source) {
        doEnableHandlers();
    } else if (addLicenseTypeButton == source) {
        doAddLicenseType(ureq);
    } else if (tableEl == source) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            String cmd = se.getCommand();
            LicenseTypeRow licenseTypeRow = dataModel.getObject(se.getIndex());
            if (CMD_UP.equals(cmd)) {
                doUp(se.getIndex());
            } else if (CMD_DOWN.equals(cmd)) {
                doDown(se.getIndex());
            } else if (CMD_TRANSLATE.equals(cmd)) {
                doOpenTranslator(ureq, licenseTypeRow.getLicenseType());
            } else if (CMD_EDIT.equals(cmd)) {
                doEditLicenseType(ureq, licenseTypeRow.getLicenseType());
            }
        }
    } else if (source instanceof MultipleSelectionElement) {
        MultipleSelectionElement multipleSelectionElement = (MultipleSelectionElement) source;
        doActivateLicenseType(multipleSelectionElement);
    } else if (source instanceof SingleSelection) {
        SingleSelection singleSelection = (SingleSelection) source;
        String name = singleSelection.getName();
        if (name.startsWith(DEFAULT_LICENSE_TYPE_PREFIX)) {
            doSetDefaultLicenceType(source, singleSelection);
        } else if (name.startsWith(LICENSOR_CREATOR_TYPE_PREFIX)) {
            doSetLicensorCreator(source, singleSelection);
        }
    } else if (source instanceof FormLink) {
        Object userObject = source.getUserObject();
        if (userObject instanceof LicenseHandler) {
            LicenseHandler handler = (LicenseHandler) userObject;
            doEditLicensorConstant(ureq, handler);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 7 with LicenseHandler

use of org.olat.core.commons.services.license.LicenseHandler in project openolat by klemens.

the class LicenseAdminConfigController method initLicenseTypesTable.

private void initLicenseTypesTable() {
    addLicenseTypeButton = uifactory.addFormLink("add.license.type", flc, Link.BUTTON);
    addLicenseTypeButton.setIconLeftCSS("o_icon o_icon_lic_add");
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(LicenseTypeCols.up, CMD_UP, new BooleanCellRenderer(new StaticFlexiCellRenderer("", CMD_UP, "o_icon o_icon-lg o_icon_move_up"), null)));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(LicenseTypeCols.down, CMD_DOWN, new BooleanCellRenderer(new StaticFlexiCellRenderer("", CMD_DOWN, "o_icon o_icon-lg o_icon_move_down"), null)));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(LicenseTypeCols.name));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(LicenseTypeCols.nameTranslation, CMD_TRANSLATE, new StaticFlexiCellRenderer(CMD_TRANSLATE, new TextFlexiCellRenderer())));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(LicenseTypeCols.text));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(LicenseTypeCols.cssClass));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(LicenseTypeCols.edit, CMD_EDIT, new BooleanCellRenderer(null, new StaticFlexiCellRenderer("", CMD_EDIT, "o_icon o_icon-lg o_icon_edit"))));
    // add a checkbox for every enabled license handler
    int index = LicenseTypeCols.values().length;
    for (LicenseHandler handler : licenseHandlers) {
        boolean handlerEnabled = licenseModule.isEnabled(handler);
        if (handlerEnabled) {
            DefaultFlexiColumnModel columnModel = new DefaultFlexiColumnModel(handler.getType(), index++);
            columnModel.setHeaderLabel(handler.getTitle(getLocale()));
            columnsModel.addFlexiColumnModel(columnModel);
        }
    }
    dataModel = new LicenseTypeDataModel(columnsModel, getLocale());
    tableEl = uifactory.addTableElement(getWindowControl(), "license.types", dataModel, getTranslator(), flc);
}
Also used : StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) BooleanCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Example 8 with LicenseHandler

use of org.olat.core.commons.services.license.LicenseHandler in project openolat by klemens.

the class LicenseAdminConfigController method doSaveLicensorConstant.

private void doSaveLicensorConstant() {
    LicenseHandler handler = licensorConstantCtrl.getHandler();
    String licensor = licensorConstantCtrl.getLicensor();
    licenseModule.setConstantLicensor(handler, licensor);
    initHandlerConfigs();
}
Also used : LicenseHandler(org.olat.core.commons.services.license.LicenseHandler)

Example 9 with LicenseHandler

use of org.olat.core.commons.services.license.LicenseHandler in project openolat by klemens.

the class LicenseAdminConfigController method doSetDefaultLicenceType.

private void doSetDefaultLicenceType(FormItem source, SingleSelection singleSelection) {
    if (singleSelection.isOneSelected()) {
        String selectedKey = singleSelection.getSelectedKey();
        LicenseHandler handler = (LicenseHandler) source.getUserObject();
        LicenseType licenseType = licenseService.loadLicenseTypeByKey(selectedKey);
        licenseModule.setDefaultLicenseTypeKey(handler, String.valueOf(licenseType.getKey()));
    }
}
Also used : LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 10 with LicenseHandler

use of org.olat.core.commons.services.license.LicenseHandler in project openolat by klemens.

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);
}
Also used : FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement) Arrays(java.util.Arrays) LicenseModule(org.olat.core.commons.services.license.LicenseModule) LicenseService(org.olat.core.commons.services.license.LicenseService) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) BooleanCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormItem(org.olat.core.gui.components.form.flexible.FormItem) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) ArrayList(java.util.ArrayList) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) Event(org.olat.core.gui.control.Event) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) SingleKeyTranslatorController(org.olat.core.util.i18n.ui.SingleKeyTranslatorController) Map(java.util.Map) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) FlexiTableDataModelFactory(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModelFactory) CONSTANT_CREATOR_TYPE(org.olat.core.commons.services.license.manager.LicensorConstantCreator.CONSTANT_CREATOR_TYPE) LicenseTypeCols(org.olat.core.commons.services.license.ui.LicenseTypeDataModel.LicenseTypeCols) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) Link(org.olat.core.gui.components.link.Link) WindowControl(org.olat.core.gui.control.WindowControl) Collection(java.util.Collection) Controller(org.olat.core.gui.control.Controller) SpacerElement(org.olat.core.gui.components.form.flexible.elements.SpacerElement) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) List(java.util.List) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) LicensorCreator(org.olat.core.commons.services.license.manager.LicensorCreator) UserRequest(org.olat.core.gui.UserRequest) LicenseType(org.olat.core.commons.services.license.LicenseType) Collections(java.util.Collections) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) SpacerElement(org.olat.core.gui.components.form.flexible.elements.SpacerElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Aggregations

LicenseHandler (org.olat.core.commons.services.license.LicenseHandler)24 LicenseType (org.olat.core.commons.services.license.LicenseType)8 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)8 ArrayList (java.util.ArrayList)6 LicenseModule (org.olat.core.commons.services.license.LicenseModule)6 LicenseService (org.olat.core.commons.services.license.LicenseService)6 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)6 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)6 BooleanCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer)6 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)6 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)6 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)6 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)6 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)6 Arrays (java.util.Arrays)4 Collection (java.util.Collection)4 Collections (java.util.Collections)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4