Search in sources :

Example 26 with Preferences

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

the class VideoDisplayController method updateGUIPreferences.

/**
 * Update the users preferred resolution in the GUI prefs from the given video URL
 * @param ureq
 * @param src
 */
private void updateGUIPreferences(UserRequest ureq, String src) {
    if (src != null) {
        int start = src.lastIndexOf("/");
        if (start != -1) {
            String video = src.substring(start + 1);
            int end = video.indexOf("video");
            if (end > 0) {
                // dont's save master videos
                String resolution = video.substring(0, end);
                try {
                    int res = Integer.parseInt(resolution.trim());
                    if (userPreferredResolution == null || userPreferredResolution.intValue() != res) {
                        // update GUI prefs, reload first
                        Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
                        userPreferredResolution = (Integer) guiPrefs.get(VideoDisplayController.class, GUIPREF_KEY_PREFERRED_RESOLUTION);
                        guiPrefs.putAndSave(VideoDisplayController.class, GUIPREF_KEY_PREFERRED_RESOLUTION, Integer.valueOf(res));
                    }
                } catch (NumberFormatException e) {
                    // ignore, do nothing
                    logDebug("Error parsing the users preferred resolution from url::" + src, null);
                }
            }
        }
    }
}
Also used : Preferences(org.olat.core.util.prefs.Preferences)

Example 27 with Preferences

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

the class ToggleBoxController method reload.

public void reload(UserRequest ureq) {
    Preferences prefs = ureq.getUserSession().getGuiPreferences();
    toggleStatus = (Boolean) prefs.get(this.getClass(), key, defaultToggleStatus);
    mainVC.put("cmpToToggle", componentToToggle);
    updateUI();
}
Also used : Preferences(org.olat.core.util.prefs.Preferences)

Example 28 with Preferences

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

the class EditLectureBlockController method updateLocationsPrefs.

private void updateLocationsPrefs(UserRequest ureq) {
    String location = lectureBlock.getLocation();
    if (StringHelper.containsNonWhitespace(location)) {
        List<LocationHistory> newLocations = new ArrayList<>(locations);
        LocationHistory newLocation = new LocationHistory(location, new Date());
        if (locations.contains(newLocation)) {
            int index = locations.indexOf(newLocation);
            locations.get(index).setLastUsed(new Date());
        } else {
            newLocations.add(newLocation);
            Collections.sort(newLocations, new LocationDateComparator());
            if (newLocations.size() > 10) {
                // pack it in a new list for XStream
                newLocations = new ArrayList<>(newLocations.subList(0, 10));
            }
        }
        Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
        if (guiPrefs != null) {
            guiPrefs.putAndSave(LectureBlock.class, getLocationsPrefsId(), newLocations);
        }
    }
}
Also used : LocationHistory(org.olat.modules.lecture.model.LocationHistory) ArrayList(java.util.ArrayList) Preferences(org.olat.core.util.prefs.Preferences) Date(java.util.Date)

Example 29 with Preferences

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

the class AbstractTeacherOverviewController method isAllTeachersSwitch.

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

Example 30 with Preferences

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

the class AbstractTeacherOverviewController method saveAllTeachersSwitch.

private void saveAllTeachersSwitch(UserRequest ureq, boolean newValue) {
    Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
    if (guiPrefs != null) {
        guiPrefs.putAndSave(AbstractTeacherOverviewController.class, switchPrefsId, new Boolean(newValue));
    }
    if (newValue) {
        allTeachersSwitch.setIconLeftCSS("o_icon o_icon-lg o_icon_toggle_on");
        allTeachersSwitch.setTooltip(translate("all.teachers.switch.tooltip.on"));
    } else {
        allTeachersSwitch.setIconLeftCSS("o_icon o_icon-lg o_icon_toggle_off");
        allTeachersSwitch.setTooltip(translate("all.teachers.switch.tooltip.off"));
    }
    allTeachersSwitch.setUserObject(newValue);
}
Also used : Preferences(org.olat.core.util.prefs.Preferences)

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