use of org.olat.core.gui.components.form.flexible.elements.FlexiTableSort in project OpenOLAT by OpenOLAT.
the class MediaCenterController method initSorters.
private void initSorters(FlexiTableElement tableElement) {
List<FlexiTableSort> sorters = new ArrayList<>(14);
sorters.add(new FlexiTableSort(translate(MediaCols.key.i18nHeaderKey()), MediaCols.key.name()));
sorters.add(new FlexiTableSort(translate(MediaCols.type.i18nHeaderKey()), MediaCols.type.name()));
sorters.add(new FlexiTableSort(translate(MediaCols.title.i18nHeaderKey()), MediaCols.title.name()));
sorters.add(new FlexiTableSort(translate(MediaCols.collectionDate.i18nHeaderKey()), MediaCols.collectionDate.name()));
sorters.add(FlexiTableSort.SPACER);
FlexiTableSortOptions options = new FlexiTableSortOptions(sorters);
options.setDefaultOrderBy(new SortKey(OrderBy.title.name(), true));
tableElement.setSortSettings(options);
}
use of org.olat.core.gui.components.form.flexible.elements.FlexiTableSort 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.gui.components.form.flexible.elements.FlexiTableSort 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.gui.components.form.flexible.elements.FlexiTableSort in project openolat by klemens.
the class RepositoryEntryListController method initSorters.
private void initSorters(FlexiTableElement tableElement) {
List<FlexiTableSort> sorters = new ArrayList<>(14);
sorters.add(new FlexiTableSort(translate("orderby.automatic"), OrderBy.automatic.name()));
sorters.add(new FlexiTableSort(translate("orderby.favorit"), OrderBy.favorit.name()));
sorters.add(new FlexiTableSort(translate("orderby.lastVisited"), OrderBy.lastVisited.name()));
sorters.add(new FlexiTableSort(translate("orderby.score"), OrderBy.score.name()));
sorters.add(new FlexiTableSort(translate("orderby.passed"), OrderBy.passed.name()));
sorters.add(FlexiTableSort.SPACER);
sorters.add(new FlexiTableSort(translate("orderby.title"), OrderBy.title.name()));
sorters.add(new FlexiTableSort(translate("orderby.lifecycle"), OrderBy.lifecycle.name()));
sorters.add(new FlexiTableSort(translate("orderby.author"), OrderBy.author.name()));
sorters.add(new FlexiTableSort(translate("orderby.creationDate"), OrderBy.creationDate.name()));
sorters.add(new FlexiTableSort(translate("orderby.lastModified"), OrderBy.lastModified.name()));
if (repositoryModule.isRatingEnabled()) {
sorters.add(new FlexiTableSort(translate("orderby.rating"), OrderBy.rating.name()));
}
FlexiTableSortOptions options = new FlexiTableSortOptions(sorters);
options.setDefaultOrderBy(new SortKey(OrderBy.title.name(), true));
tableElement.setSortSettings(options);
}
use of org.olat.core.gui.components.form.flexible.elements.FlexiTableSort in project openolat by klemens.
the class VideoListingController method initSorters.
private void initSorters(FlexiTableElement tableElement) {
List<FlexiTableSort> sorters = new ArrayList<>(8);
sorters.add(new FlexiTableSort(translate("orderby.automatic"), OrderBy.automatic.name()));
sorters.add(new FlexiTableSort(translate("orderby.title"), OrderBy.title.name()));
sorters.add(new FlexiTableSort(translate("orderby.author"), OrderBy.author.name()));
sorters.add(new FlexiTableSort(translate("orderby.creationDate"), OrderBy.creationDate.name()));
sorters.add(new FlexiTableSort(translate("orderby.launchCounter"), OrderBy.launchCounter.name()));
if (repositoryModule.isRatingEnabled()) {
sorters.add(new FlexiTableSort(translate("orderby.rating"), OrderBy.rating.name()));
}
FlexiTableSortOptions options = new FlexiTableSortOptions(sorters);
options.setDefaultOrderBy(new SortKey(OrderBy.creationDate.name(), false));
tableElement.setSortSettings(options);
}
Aggregations