Search in sources :

Example 11 with FlexiTableSort

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);
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) ArrayList(java.util.ArrayList) SortKey(org.olat.core.commons.persistence.SortKey) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)

Example 12 with FlexiTableSort

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();
    }
}
Also used : Preferences(org.olat.core.util.prefs.Preferences) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)

Example 13 with FlexiTableSort

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());
            }
        }
    }
}
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 14 with FlexiTableSort

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);
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) ArrayList(java.util.ArrayList) SortKey(org.olat.core.commons.persistence.SortKey) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)

Example 15 with FlexiTableSort

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);
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) ArrayList(java.util.ArrayList) SortKey(org.olat.core.commons.persistence.SortKey) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)

Aggregations

FlexiTableSort (org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)20 ArrayList (java.util.ArrayList)8 SortKey (org.olat.core.commons.persistence.SortKey)8 FlexiTableSortOptions (org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions)8 Form (org.olat.core.gui.components.form.flexible.impl.Form)4 NameValuePair (org.olat.core.gui.components.form.flexible.impl.NameValuePair)4 Preferences (org.olat.core.util.prefs.Preferences)4 Component (org.olat.core.gui.components.Component)2 FlexiTableElement (org.olat.core.gui.components.form.flexible.elements.FlexiTableElement)2 FlexiTableFilter (org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)2 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)2 FlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel)2 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)2 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)2 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)2 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)2