Search in sources :

Example 1 with UserTool

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

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 2 with UserTool

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

the class UserToolsMenuController method loadPersonalTools.

private void loadPersonalTools(UserRequest ureq) {
    List<String> linksName = new ArrayList<>();
    List<String> configLinksName = new ArrayList<>();
    List<String> searchLinksName = new ArrayList<>();
    List<String> systemLinksName = new ArrayList<>();
    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
        UserTool tool = toolExtension.createUserTool(ureq, getWindowControl(), getLocale());
        if (tool != null) {
            UserToolCategory category = toolExtension.getUserToolCategory();
            boolean shortCutOnly = toolExtension.isShortCutOnly();
            if (!shortCutOnly && !selectedToolSet.contains(toolExtension.getUniqueExtensionID())) {
                Component link = tool.getMenuComponent(ureq, menuVC);
                String linkName = link.getComponentName();
                switch(category) {
                    case search:
                        searchLinksName.add(linkName);
                        break;
                    case personal:
                        linksName.add(linkName);
                        break;
                    case config:
                        configLinksName.add(linkName);
                        break;
                    case system:
                        systemLinksName.add(linkName);
                        break;
                }
                disposableTools.add(tool);
            }
        }
    }
    menuVC.contextPut("personalTools", linksName);
    menuVC.contextPut("configs", configLinksName);
    menuVC.contextPut("systems", systemLinksName);
    menuVC.contextPut("searchs", searchLinksName);
    menuVC.contextPut("locked", Boolean.FALSE);
}
Also used : UserToolCategory(org.olat.admin.user.tools.UserToolCategory) 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) HashSet(java.util.HashSet)

Example 3 with UserTool

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

the class UserToolsMenuController method loadPersonalTools.

private void loadPersonalTools(UserRequest ureq) {
    List<String> linksName = new ArrayList<>();
    List<String> configLinksName = new ArrayList<>();
    List<String> searchLinksName = new ArrayList<>();
    List<String> systemLinksName = new ArrayList<>();
    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
        UserTool tool = toolExtension.createUserTool(ureq, getWindowControl(), getLocale());
        if (tool != null) {
            UserToolCategory category = toolExtension.getUserToolCategory();
            boolean shortCutOnly = toolExtension.isShortCutOnly();
            if (!shortCutOnly && !selectedToolSet.contains(toolExtension.getUniqueExtensionID())) {
                Component link = tool.getMenuComponent(ureq, menuVC);
                String linkName = link.getComponentName();
                switch(category) {
                    case search:
                        searchLinksName.add(linkName);
                        break;
                    case personal:
                        linksName.add(linkName);
                        break;
                    case config:
                        configLinksName.add(linkName);
                        break;
                    case system:
                        systemLinksName.add(linkName);
                        break;
                }
                disposableTools.add(tool);
            }
        }
    }
    menuVC.contextPut("personalTools", linksName);
    menuVC.contextPut("configs", configLinksName);
    menuVC.contextPut("systems", systemLinksName);
    menuVC.contextPut("searchs", searchLinksName);
    menuVC.contextPut("locked", Boolean.FALSE);
}
Also used : UserToolCategory(org.olat.admin.user.tools.UserToolCategory) 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) HashSet(java.util.HashSet)

Example 4 with UserTool

use of org.olat.admin.user.tools.UserTool 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)

Aggregations

ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 UserTool (org.olat.admin.user.tools.UserTool)4 UserToolExtension (org.olat.admin.user.tools.UserToolExtension)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