Search in sources :

Example 56 with Preferences

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

the class FlexiTableElementImpl method saveCustomSettings.

private void saveCustomSettings(UserRequest ureq) {
    if (StringHelper.containsNonWhitespace(persistentId)) {
        Preferences prefs = ureq.getUserSession().getGuiPreferences();
        boolean sortDirection = false;
        String sortedColKey = null;
        if (orderBy != null && orderBy.length > 0 && orderBy[0] != null) {
            sortDirection = orderBy[0].isAsc();
            String sortKey = orderBy[0].getKey();
            if (sortKey != null) {
                FlexiTableColumnModel colModel = dataModel.getTableColumnModel();
                for (int i = colModel.getColumnCount(); i-- > 0; ) {
                    FlexiColumnModel col = colModel.getColumnModel(i);
                    if (col.getSortKey() != null && sortKey.equals(col.getSortKey())) {
                        sortedColKey = col.getColumnKey();
                    }
                }
            }
            if (sortedColKey == null && sortOptions != null && sortOptions.getSorts() != null) {
                for (FlexiTableSort sortOption : sortOptions.getSorts()) {
                    if (sortOption.getSortKey().getKey().equals(sortKey)) {
                        sortedColKey = sortKey;
                    }
                }
            }
        }
        FlexiTablePreferences tablePrefs = new FlexiTablePreferences(getPageSize(), sortedColKey, sortDirection, convertColumnIndexToKeys(enabledColumnIndex), rendererType);
        prefs.put(FlexiTableElement.class, persistentId, tablePrefs);
        prefs.save();
    }
}
Also used : Preferences(org.olat.core.util.prefs.Preferences) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)

Example 57 with Preferences

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

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 58 with Preferences

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

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 59 with Preferences

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

the class ToggleBoxController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == toggleButton) {
        Preferences prefs = ureq.getUserSession().getGuiPreferences();
        toggleStatus = new Boolean(!toggleStatus.booleanValue());
        prefs.putAndSave(this.getClass(), key, toggleStatus);
        updateUI();
    } else if (source == hideButton) {
        Preferences prefs = ureq.getUserSession().getGuiPreferences();
        toggleStatus = Boolean.FALSE;
        prefs.putAndSave(this.getClass(), key, toggleStatus);
        updateUI();
    } else if (source == mainVC) {
        if ("hide".equals(event.getCommand())) {
            Preferences prefs = ureq.getUserSession().getGuiPreferences();
            toggleStatus = Boolean.FALSE;
            prefs.putAndSave(this.getClass(), key, toggleStatus);
            updateUI();
        }
    }
}
Also used : Preferences(org.olat.core.util.prefs.Preferences)

Example 60 with Preferences

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

the class AbstractPortletRunController method saveManuallySortedItems.

/**
 * Stores the manually sorted items.
 * @param ureq
 * @param sortedItems
 */
protected void saveManuallySortedItems(UserRequest ureq, List<PortletEntry<T>> sortedItems) {
    Preferences guiPreferences = ureq.getUserSession().getGuiPreferences();
    // store manual sorting type
    SortingCriteria manualSortingCriteria = new SortingCriteria();
    guiPreferences.putAndSave(Map.class, getPreferenceKey(SORTING_CRITERIA_PREF), manualSortingCriteria.getPersistable());
    // store the sorted items
    guiPreferences.putAndSave(Map.class, getPreferenceKey(SORTED_ITEMS_PREF), getSortedItemsMap(sortedItems));
}
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