Search in sources :

Example 6 with UserToolExtension

use of org.olat.admin.user.tools.UserToolExtension in project OpenOLAT by OpenOLAT.

the class OlatTopNavController method loadPersonalTools.

private void loadPersonalTools(UserRequest ureq) {
    List<Tool> toolSetLinksName = new ArrayList<Tool>();
    Preferences prefs = ureq.getUserSession().getGuiPreferences();
    String selectedTools = userToolsModule.getUserTools(prefs);
    if (!StringHelper.containsNonWhitespace(selectedTools)) {
        selectedTools = userToolsModule.getDefaultPresetOfUserTools();
    }
    Set<String> selectedToolSet = new HashSet<>();
    if (StringHelper.containsNonWhitespace(selectedTools)) {
        String[] selectedToolArr = selectedTools.split(",");
        for (String selectedTool : selectedToolArr) {
            selectedToolSet.add(UserToolsModule.stripToolKey(selectedTool));
        }
    }
    List<UserToolExtension> toolExtensions = userToolsModule.getUserToolExtensions(ureq);
    for (UserToolExtension toolExtension : toolExtensions) {
        // check for sites
        if (toolExtension.isShortCutOnly() || selectedToolSet.contains(toolExtension.getUniqueExtensionID())) {
            UserTool tool = toolExtension.createUserTool(ureq, getWindowControl(), getLocale());
            if (tool != null) {
                Component cmp = tool.getMenuComponent(ureq, topNavVC);
                String cssId = toolExtension.getShortCutCssId();
                String cssClass = toolExtension.getShortCutCssClass();
                toolSetLinksName.add(new Tool(cssId, cssClass, cmp.getComponentName()));
                disposableTools.add(tool);
            }
        }
    }
    topNavVC.contextPut("toolSet", toolSetLinksName);
}
Also used : UserToolExtension(org.olat.admin.user.tools.UserToolExtension) ArrayList(java.util.ArrayList) UserTool(org.olat.admin.user.tools.UserTool) Preferences(org.olat.core.util.prefs.Preferences) Component(org.olat.core.gui.components.Component) UserTool(org.olat.admin.user.tools.UserTool) HashSet(java.util.HashSet)

Example 7 with UserToolExtension

use of org.olat.admin.user.tools.UserToolExtension in project openolat by klemens.

the class ToolsPrefsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("usertools.title");
    setFormDescription("usertools.descr");
    setFormContextHelp("Configuration#_tools");
    String[] toolKeys;
    String[] toolValues;
    if (enabled) {
        int numOfTools = userTools.size();
        toolKeys = new String[numOfTools];
        toolValues = new String[numOfTools];
        for (int i = 0; i < numOfTools; i++) {
            UserToolExtension userTool = userTools.get(i);
            toolKeys[i] = userTool.getUniqueExtensionID();
            toolValues[i] = userTool.getLabel(getLocale());
        }
    } else {
        toolKeys = new String[0];
        toolValues = new String[0];
    }
    presetEl = uifactory.addCheckboxesVertical("usertools.set", "usertools.set", formLayout, toolKeys, toolValues, 1);
    presetEl.addActionListener(FormEvent.ONCHANGE);
    presetEl.setEnabled(enabled);
    initPresetElementUserData();
    // Create submit and cancel buttons
    FormLayoutContainer buttonLayoutWrappper = FormLayoutContainer.createButtonLayout("buttonLayoutWrappper", getTranslator());
    formLayout.add(buttonLayoutWrappper);
    FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayoutInner", getTranslator());
    buttonLayoutWrappper.add(buttonLayout);
    uifactory.addFormSubmitButton("save", buttonLayout);
    uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
}
Also used : UserToolExtension(org.olat.admin.user.tools.UserToolExtension) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 8 with UserToolExtension

use of org.olat.admin.user.tools.UserToolExtension in project openolat by klemens.

the class UserToolsAdminController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("usertools");
    setFormDescription("usertools.description");
    int numOfTools = userTools.size();
    String[] toolKeys = new String[numOfTools];
    String[] toolValues = new String[numOfTools];
    for (int i = 0; i < numOfTools; i++) {
        UserToolExtension userTool = userTools.get(i);
        toolKeys[i] = userTool.getUniqueExtensionID();
        toolValues[i] = userTool.getLabel(getLocale());
    }
    availableEl = uifactory.addCheckboxesVertical("available.tools", "available.tools", formLayout, toolKeys, toolValues, 1);
    availableEl.addActionListener(FormEvent.ONCHANGE);
    Set<String> availableTools = userToolsModule.getAvailableUserToolSet();
    if (availableTools.isEmpty()) {
        for (String toolKey : toolKeys) {
            availableEl.select(toolKey, true);
        }
    } else {
        for (String toolKey : toolKeys) {
            if (availableTools.contains(toolKey)) {
                availableEl.select(toolKey, true);
            }
        }
    }
    List<String> presetToolKeyList = new ArrayList<>(numOfTools);
    List<String> presetToolValueList = new ArrayList<>(numOfTools);
    for (int i = 0; i < numOfTools; i++) {
        UserToolExtension userTool = userTools.get(i);
        if (!userTool.isShortCutOnly()) {
            presetToolKeyList.add(userTool.getUniqueExtensionID());
            presetToolValueList.add(userTool.getLabel(getLocale()));
        }
    }
    String[] presetToolKeys = presetToolKeyList.toArray(new String[presetToolKeyList.size()]);
    String[] presetToolValues = presetToolValueList.toArray(new String[presetToolValueList.size()]);
    presetEl = uifactory.addCheckboxesVertical("preset.tools", "preset.tools", formLayout, presetToolKeys, presetToolValues, 1);
    presetEl.addActionListener(FormEvent.ONCHANGE);
    if (userToolsModule.isUserToolsDisabled()) {
        presetEl.setEnabled(false);
    } else {
        Set<String> tools = userToolsModule.getDefaultPresetOfUserToolSet();
        if (tools.size() > 0) {
            for (String toolKey : presetToolKeys) {
                if (tools.contains(toolKey)) {
                    presetEl.select(toolKey, true);
                }
            }
        }
    }
}
Also used : UserToolExtension(org.olat.admin.user.tools.UserToolExtension) ArrayList(java.util.ArrayList)

Aggregations

UserToolExtension (org.olat.admin.user.tools.UserToolExtension)8 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)4 UserTool (org.olat.admin.user.tools.UserTool)4 Component (org.olat.core.gui.components.Component)4 Preferences (org.olat.core.util.prefs.Preferences)4 UserToolCategory (org.olat.admin.user.tools.UserToolCategory)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2