Search in sources :

Example 16 with LicenseHandler

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

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 17 with LicenseHandler

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

the class LicenseAdminConfigController method doSetLicensorCreator.

private void doSetLicensorCreator(FormItem source, SingleSelection singleSelection) {
    if (singleSelection.isOneSelected()) {
        String creatorType = singleSelection.getSelectedKey();
        LicenseHandler handler = (LicenseHandler) source.getUserObject();
        licenseModule.setLicensorCreatorType(handler, creatorType);
        initHandlerConfigs();
    }
}
Also used : LicenseHandler(org.olat.core.commons.services.license.LicenseHandler)

Example 18 with LicenseHandler

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

the class LicenseAdminConfigController method initGeneralElements.

private void initGeneralElements() {
    FormLayoutContainer generalCont = FormLayoutContainer.createDefaultFormLayout("general", getTranslator());
    generalCont.setFormTitle(translate("admin.menu.title"));
    generalCont.setRootForm(mainForm);
    generalCont.setElementCssClass("o_sel_license_general");
    flc.add("general", generalCont);
    String[] enabledHandlerKeys = licenseHandlers.stream().map(LicenseHandler::getType).toArray(String[]::new);
    String[] enabledHandlerValues = licenseHandlers.stream().map(handler -> handler.getTitle(getLocale())).toArray(String[]::new);
    enabledEl = uifactory.addCheckboxesVertical("handler.enabled", "admin.enabled", generalCont, enabledHandlerKeys, enabledHandlerValues, 1);
    enabledEl.addActionListener(FormEvent.ONCHANGE);
    for (LicenseHandler handler : licenseHandlers) {
        boolean handlerEnabled = licenseModule.isEnabled(handler);
        enabledEl.select(handler.getType(), handlerEnabled);
    }
}
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) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 19 with LicenseHandler

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

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();
}
Also used : LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 20 with LicenseHandler

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

the class ListRenderer method render.

/**
 * Render contents of directory to a html table.
 *
 * @param dir
 * @param secCallback
 * @param ubu
 * @param translator
 * @param iframePostEnabled
 * @return Render results.
 */
public void render(FolderComponent fc, StringOutput sb, URLBuilder ubu, Translator translator, boolean iframePostEnabled) {
    if (lockManager == null) {
        lockManager = CoreSpringFactory.getImpl(VFSLockManager.class);
    }
    if (userManager == null) {
        userManager = CoreSpringFactory.getImpl(UserManager.class);
    }
    LicenseModule licenseModule = CoreSpringFactory.getImpl(LicenseModule.class);
    LicenseHandler licenseHandler = CoreSpringFactory.getImpl(FolderLicenseHandler.class);
    licensesEnabled = licenseModule.isEnabled(licenseHandler);
    List<VFSItem> children = fc.getCurrentContainerChildren();
    // folder empty?
    if (children.size() == 0) {
        sb.append("<div class=\"o_bc_empty\"><i class='o_icon o_icon_warn'></i> ").append(translator.translate("NoFiles")).append("</div>");
        return;
    }
    boolean canVersion = FolderConfig.versionsEnabled(fc.getCurrentContainer());
    String sortOrder = fc.getCurrentSortOrder();
    boolean sortAsc = fc.isCurrentSortAsc();
    String sortCss = (sortAsc ? "o_orderby_asc" : "o_orderby_desc");
    sb.append("<table class=\"table table-condensed table-striped table-hover o_bc_table\">").append("<thead><tr><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_NAME.equals(sortOrder)).append("' ");
    ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_NAME)).append(">").append(translator.translate("header.Name")).append("</a>").append("</th>");
    sb.append("<th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_SIZE.equals(sortOrder)).append("' ");
    ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_SIZE)).append(">").append(translator.translate("header.Size")).append("</a>").append("</th><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_DATE.equals(sortOrder)).append("' ");
    ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_DATE)).append(">").append(translator.translate("header.Modified")).append("</a>");
    if (licensesEnabled) {
        sb.append("<th>").append(translator.translate("header.license")).append("</th>");
    }
    if (canVersion) {
        sb.append("</th><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_REV.equals(sortOrder)).append("' ");
        // file size column
        ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_REV)).append("><i class=\"o_icon o_icon_version  o_icon-lg\" title=\"").append(translator.translate("versions")).append("\"></i></a>");
    }
    sb.append("</th><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_LOCK.equals(sortOrder)).append("' ");
    ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_LOCK)).append("><i class=\"o_icon o_icon_locked  o_icon-lg\" title=\"").append(translator.translate("lock.title")).append("\"></i></a>").append("</th><th><i class=\"o_icon o_icon_edit_metadata o_icon-lg\" title=\"").append(translator.translate("mf.edit")).append("\"></i></th></tr></thead>");
    // render directory contents
    String currentContainerPath = fc.getCurrentContainerPath();
    if (currentContainerPath.length() > 0 && currentContainerPath.charAt(0) == '/') {
        currentContainerPath = currentContainerPath.substring(1);
    }
    sb.append("<tbody>");
    for (int i = 0; i < children.size(); i++) {
        VFSItem child = children.get(i);
        appendRenderedFile(fc, child, currentContainerPath, sb, ubu, translator, iframePostEnabled, canVersion, i);
    }
    sb.append("</tbody></table>");
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) FolderLicenseHandler(org.olat.core.commons.modules.bc.FolderLicenseHandler) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) UserManager(org.olat.user.UserManager) VFSItem(org.olat.core.util.vfs.VFSItem) VFSLockManager(org.olat.core.util.vfs.VFSLockManager) LicenseModule(org.olat.core.commons.services.license.LicenseModule)

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