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();
}
}
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());
}
}
}
}
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();
}
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();
}
}
}
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));
}
Aggregations