Search in sources :

Example 46 with Preferences

use of org.olat.core.util.prefs.Preferences in project OpenOLAT by OpenOLAT.

the class ShareLinkController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    UserSession usess = ureq.getUserSession();
    if (source == shareLinkVC && "setLandingPage".equals(event.getCommand()) && usess != null && usess.isAuthenticated()) {
        HistoryPoint p = usess.getLastHistoryPoint();
        if (p != null && StringHelper.containsNonWhitespace(p.getBusinessPath())) {
            List<ContextEntry> ces = p.getEntries();
            String landingPage = BusinessControlFactory.getInstance().getAsURIString(ces, true);
            int start = landingPage.indexOf("/url/");
            if (start != -1) {
                // start with / after /url
                landingPage = landingPage.substring(start + 4);
            }
            // update user prefs
            Preferences prefs = usess.getGuiPreferences();
            prefs.put(WindowManager.class, "landing-page", landingPage);
            prefs.save();
            getWindowControl().getWindowBackOffice().sendCommandTo(new JSCommand("showInfoBox(\"" + translate("info.header") + "\",\"" + translate("landingpage.set.message") + "\");"));
        }
    }
}
Also used : UserSession(org.olat.core.util.UserSession) JSCommand(org.olat.core.gui.control.winmgr.JSCommand) Preferences(org.olat.core.util.prefs.Preferences) HistoryPoint(org.olat.core.id.context.HistoryPoint) ContextEntry(org.olat.core.id.context.ContextEntry) HistoryPoint(org.olat.core.id.context.HistoryPoint)

Example 47 with Preferences

use of org.olat.core.util.prefs.Preferences in project OpenOLAT by OpenOLAT.

the class IQRunController method isPanelOpen.

private boolean isPanelOpen(UserRequest ureq, String panelId, boolean def) {
    Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
    Boolean showConfig = (Boolean) guiPrefs.get(IQRunController.class, getOpenPanelId(panelId));
    return showConfig == null ? def : showConfig.booleanValue();
}
Also used : Preferences(org.olat.core.util.prefs.Preferences)

Example 48 with Preferences

use of org.olat.core.util.prefs.Preferences in project OpenOLAT by OpenOLAT.

the class QTI21AssessmentRunController method isPanelOpen.

private boolean isPanelOpen(UserRequest ureq, String panelId, boolean def) {
    Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
    Boolean showConfig = (Boolean) guiPrefs.get(QTI21AssessmentRunController.class, getOpenPanelId(panelId));
    return showConfig == null ? def : showConfig.booleanValue();
}
Also used : Preferences(org.olat.core.util.prefs.Preferences) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

Example 49 with Preferences

use of org.olat.core.util.prefs.Preferences in project OpenOLAT by OpenOLAT.

the class PortfolioCourseNodeRunController method saveOpenPanel.

private void saveOpenPanel(UserRequest ureq, String panelId, boolean newValue) {
    Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
    if (guiPrefs != null) {
        guiPrefs.putAndSave(PortfolioCourseNodeRunController.class, getOpenPanelId(panelId), new Boolean(newValue));
    }
    flc.getFormItemComponent().contextPut("in-" + panelId, new Boolean(newValue));
}
Also used : Preferences(org.olat.core.util.prefs.Preferences)

Example 50 with Preferences

use of org.olat.core.util.prefs.Preferences 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)

Aggregations

Preferences (org.olat.core.util.prefs.Preferences)92 ArrayList (java.util.ArrayList)12 I18nModule (org.olat.core.util.i18n.I18nModule)8 WindowManager (org.olat.core.gui.WindowManager)6 ContextEntry (org.olat.core.id.context.ContextEntry)6 UserSession (org.olat.core.util.UserSession)6 HashSet (java.util.HashSet)4 Locale (java.util.Locale)4 Map (java.util.Map)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)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 FlexiTableSort (org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)4 ProgressBar (org.olat.core.gui.components.progressbar.ProgressBar)4 HistoryPoint (org.olat.core.id.context.HistoryPoint)4 I18nItem (org.olat.core.util.i18n.I18nItem)4 LocationHistory (org.olat.modules.lecture.model.LocationHistory)4 Date (java.util.Date)2 List (java.util.List)2