Search in sources :

Example 31 with Preferences

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

the class BaseFullWebappController method initializeBase.

private void initializeBase(UserRequest ureq, WindowManager winman, ComponentCollection mainPanel) {
    // component-id of mainPanel for the window id
    mainVc.contextPut("o_winid", mainPanel.getDispatchID());
    BaseSecurityModule securityModule = CoreSpringFactory.getImpl(BaseSecurityModule.class);
    mainVc.contextPut("enforceTopFrame", securityModule.isForceTopFrame());
    // add optional css classes
    mainVc.contextPut("bodyCssClasses", bodyCssClasses);
    Window w = wbo.getWindow();
    mainVc.put("jsCssRawHtmlHeader", w.getJsCssRawHtmlHeader());
    // control part for ajax-communication. returns an empty panel if ajax
    // is not enabled, so that ajax can be turned on on the fly for
    // development mode
    jsServerC = wbo.createAJAXController(ureq);
    mainVc.put("jsServer", jsServerC.getInitialComponent());
    // init with no bookmark (=empty bc)
    mainVc.contextPut("o_bc", "");
    mainVc.contextPut("o_serverUri", Settings.createServerURI());
    // the current language; used e.g. by screenreaders
    mainVc.contextPut("lang", ureq.getLocale().toString());
    // some user properties
    if (ureq.getUserSession().isAuthenticated()) {
        Identity ident = ureq.getIdentity();
        StringBuilder sb = new StringBuilder();
        sb.append("{ identity : ").append(ident.getKey());
        User user = ident.getUser();
        List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(USER_PROPS_ID, ureq.getUserSession().getRoles().isOLATAdmin());
        for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
            String escapedValue = StringHelper.escapeJavaScript(userPropertyHandler.getUserProperty(user, getLocale()));
            sb.append(", ").append(userPropertyHandler.getName()).append(" : \"").append(escapedValue).append("\"");
        }
        sb.append("}");
        mainVc.contextPut("userJSON", sb);
    }
    // the current GUI theme and the global settings that contains the
    // font-size. both are pushed as objects so that window.dirty always reads
    // out the correct value
    mainVc.contextPut("theme", w.getGuiTheme());
    mainVc.contextPut("globalSettings", winman.getGlobalSettings());
    // also add the optional theme javascript
    addThemeJS();
    // Add JS analytics code, e.g. for google analytics
    if (analyticsModule.isAnalyticsEnabled()) {
        AnalyticsSPI analyticsSPI = analyticsModule.getAnalyticsProvider();
        mainVc.contextPut("analytics", analyticsSPI.analyticsInitPageJavaScript());
    }
    // content panel
    contentPanel = new Panel("olatContentPanel");
    mainVc.put("olatContentPanel", contentPanel);
    mainVc.contextPut("o_winid", w.getDispatchID());
    mainVc.contextPut("buildversion", Settings.getVersion());
    if (wbo.isDebuging()) {
        debugC = wbo.createDebugDispatcherController(ureq, getWindowControl());
        mainVc.put("guidebug", debugC.getInitialComponent());
    }
    // Inline translation interceptor. when the translation tool is enabled it
    // will start the translation tool in translation mode, if the overlay
    // feature is enabled it will start in customizing mode
    // fxdiff: allow user-managers to use the inline translation also.
    UserSession usess = ureq.getUserSession();
    if (usess.isAuthenticated() && (usess.getRoles().isOLATAdmin() || usess.getRoles().isUserManager()) && (i18nModule.isTransToolEnabled() || i18nModule.isOverlayEnabled())) {
        inlineTranslationC = wbo.createInlineTranslationDispatcherController(ureq, getWindowControl());
        Preferences guiPrefs = usess.getGuiPreferences();
        Boolean isInlineTranslationEnabled = (Boolean) guiPrefs.get(I18nModule.class, I18nModule.GUI_PREFS_INLINE_TRANSLATION_ENABLED, Boolean.FALSE);
        i18nManager.setMarkLocalizedStringsEnabled(usess, isInlineTranslationEnabled);
        mainVc.put("inlineTranslation", inlineTranslationC.getInitialComponent());
    }
    // debug info if debugging
    if (wbo.isDebuging()) {
        developmentC = wbo.createDevelopmentController(ureq, getWindowControl());
        mainVc.put("development", developmentC.getInitialComponent());
    }
    // put the global js translator mapper path into the main window
    mainVc.contextPut("jsTranslationMapperPath", BaseChiefController.jsTranslationMapperPath);
    // master window
    // w.addListener(this); // to be able to report "browser reload" to the user
    w.setContentPane(mainPanel);
}
Also used : Window(org.olat.core.gui.components.Window) I18nModule(org.olat.core.util.i18n.I18nModule) User(org.olat.core.id.User) BaseSecurityModule(org.olat.basesecurity.BaseSecurityModule) AnalyticsSPI(org.olat.core.commons.services.analytics.AnalyticsSPI) OncePanel(org.olat.core.gui.components.panel.OncePanel) Panel(org.olat.core.gui.components.panel.Panel) StackedPanel(org.olat.core.gui.components.panel.StackedPanel) UserSession(org.olat.core.util.UserSession) Identity(org.olat.core.id.Identity) Preferences(org.olat.core.util.prefs.Preferences) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 32 with Preferences

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

the class FormatConfigHelper method updateExportFormat.

public static void updateExportFormat(UserRequest ureq, boolean responsecols, boolean poscol, boolean pointcol, boolean timecols, boolean commentcol) {
    // save new config in GUI prefs
    Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
    if (guiPrefs != null) {
        ExportFormat formatConfig = new ExportFormat(responsecols, poscol, pointcol, timecols, commentcol);
        try {
            String formatConfigString = configXstream.toXML(formatConfig);
            guiPrefs.putAndSave(ExportOptionsController.class, QTI_EXPORT_ITEM_FORMAT_CONFIG, formatConfigString);
        } catch (Exception e) {
            log.error("", e);
        }
    }
}
Also used : Preferences(org.olat.core.util.prefs.Preferences)

Example 33 with Preferences

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

the class FlexiTableElementImpl method loadCustomSettings.

private void loadCustomSettings(UserRequest ureq) {
    if (StringHelper.containsNonWhitespace(persistentId)) {
        Preferences prefs = ureq.getUserSession().getGuiPreferences();
        FlexiTablePreferences tablePrefs = (FlexiTablePreferences) prefs.get(FlexiTableElement.class, persistentId);
        if (tablePrefs != null) {
            if (tablePrefs.getPageSize() != getDefaultPageSize() && tablePrefs.getPageSize() != 0) {
                setPageSize(tablePrefs.getPageSize());
            }
            if (tablePrefs.getEnabledColumnKeys() != null) {
                enabledColumnIndex.clear();
                enabledColumnIndex.addAll(convertColumnKeysToIndex(tablePrefs.getEnabledColumnKeys()));
            }
            if (StringHelper.containsNonWhitespace(tablePrefs.getSortedColumnKey())) {
                String sortKey = null;
                String columnKey = tablePrefs.getSortedColumnKey();
                FlexiTableColumnModel colModel = dataModel.getTableColumnModel();
                for (int i = colModel.getColumnCount(); i-- > 0; ) {
                    FlexiColumnModel col = colModel.getColumnModel(i);
                    if (columnKey.equals(col.getColumnKey()) && col.isSortable()) {
                        sortKey = col.getSortKey();
                    }
                }
                if (sortKey == null && sortOptions != null && sortOptions.getSorts() != null) {
                    for (FlexiTableSort sortOption : sortOptions.getSorts()) {
                        if (sortOption.getSortKey().getKey().equals(columnKey)) {
                            sortKey = columnKey;
                        }
                    }
                }
                if (sortKey != null) {
                    orderBy = new SortKey[] { new SortKey(sortKey, tablePrefs.isSortDirection()) };
                    selectSortOption(sortKey, tablePrefs.isSortDirection());
                }
            }
            if (tablePrefs.getRendererType() != null) {
                setRendererType(tablePrefs.getRendererType());
            }
        }
    }
}
Also used : SortKey(org.olat.core.commons.persistence.SortKey) Preferences(org.olat.core.util.prefs.Preferences) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort) FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement)

Example 34 with Preferences

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

the class QTI21AssessmentRunController method saveOpenPanel.

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

Example 35 with Preferences

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

the class IQRunController method saveOpenPanel.

private void saveOpenPanel(UserRequest ureq, String panelId, boolean newValue) {
    Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
    if (guiPrefs != null) {
        guiPrefs.putAndSave(IQRunController.class, getOpenPanelId(panelId), new Boolean(newValue));
    }
    myContent.contextPut("in-" + panelId, new Boolean(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