Search in sources :

Example 31 with SortKey

use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.

the class ParticipantListRepositoryController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer && !printView) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("winid", "w" + layoutCont.getFormItemComponent().getDispatchID());
        layoutCont.getFormItemComponent().addListener(this);
        layoutCont.getFormItemComponent().contextPut("withPrint", Boolean.TRUE);
    }
    FlexiTableSortOptions options = new FlexiTableSortOptions();
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    if (isAdministrativeUser) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.username));
        options.setDefaultOrderBy(new SortKey(ParticipantsCols.username.sortKey(), true));
    }
    int colPos = USER_PROPS_OFFSET;
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null)
            continue;
        String propName = userPropertyHandler.getName();
        boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
        FlexiColumnModel col = new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos, true, propName);
        columnsModel.addFlexiColumnModel(col);
        colPos++;
        if (!options.hasDefaultOrderBy()) {
            options.setDefaultOrderBy(new SortKey(propName, true));
        } else if (UserConstants.LASTNAME.equals(propName)) {
            options.setDefaultOrderBy(new SortKey(propName, true));
        }
    }
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.plannedLectures));
    if (rollCallEnabled) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.attendedLectures));
        if (authorizedAbsenceEnabled) {
            columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.unauthorizedAbsenceLectures));
            columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.authorizedAbsenceLectures));
        } else {
            columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.absentLectures, new LongCellRenderer("o_sel_absences")));
        }
        FlexiColumnModel progressCol = new DefaultFlexiColumnModel(ParticipantsCols.progress, new LectureStatisticsCellRenderer());
        progressCol.setExportable(false);
        columnsModel.addFlexiColumnModel(progressCol);
    }
    if (rateEnabled) {
        FlexiColumnModel warningCol = new DefaultFlexiColumnModel(ParticipantsCols.rateWarning, new RateWarningCellRenderer(getTranslator()));
        warningCol.setExportable(false);
        columnsModel.addFlexiColumnModel(warningCol);
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ParticipantsCols.rate, new PercentCellRenderer()));
    }
    FlexiColumnModel infoCol = new DefaultFlexiColumnModel(ParticipantsCols.infos, new ParticipantInfosRenderer(getTranslator(), defaultRate));
    infoCol.setExportable(false);
    columnsModel.addFlexiColumnModel(infoCol);
    if (!printView) {
        DefaultFlexiColumnModel editColumn = new DefaultFlexiColumnModel("table.header.edit", -1, "edit", new StaticFlexiCellRenderer("", "edit", "o_icon o_icon-lg o_icon_edit", translate("edit"), null));
        editColumn.setExportable(false);
        editColumn.setAlwaysVisible(true);
        columnsModel.addFlexiColumnModel(editColumn);
    }
    tableModel = new ParticipantListDataModel(columnsModel, getTranslator(), getLocale());
    tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout);
    tableEl.setExportEnabled(!printView);
    tableEl.setEmtpyTableMessageKey("empty.table.participant.list");
    tableEl.setSortSettings(options);
    tableEl.setAndLoadPersistedPreferences(ureq, "participant-list-repo-entry");
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) LongCellRenderer(org.olat.modules.lecture.ui.component.LongCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) FlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel) RateWarningCellRenderer(org.olat.modules.lecture.ui.component.RateWarningCellRenderer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) SortKey(org.olat.core.commons.persistence.SortKey) ParticipantInfosRenderer(org.olat.modules.lecture.ui.component.ParticipantInfosRenderer) PercentCellRenderer(org.olat.modules.lecture.ui.component.PercentCellRenderer) LectureStatisticsCellRenderer(org.olat.modules.lecture.ui.component.LectureStatisticsCellRenderer) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 32 with SortKey

use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.

the class GoToMeetingsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // add the table
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MeetingsCols.name.i18nHeaderKey(), MeetingsCols.name.ordinal(), true, MeetingsCols.name.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MeetingsCols.start.i18nHeaderKey(), MeetingsCols.start.ordinal(), true, MeetingsCols.start.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MeetingsCols.end.i18nHeaderKey(), MeetingsCols.end.ordinal(), true, MeetingsCols.end.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("select", translate("select"), "select-upcoming"));
    upcomingTableModel = new GoToMeetingTableModel(columnsModel);
    upcomingTableEl = uifactory.addTableElement(getWindowControl(), "upcomingmeetings", upcomingTableModel, getTranslator(), formLayout);
    upcomingTableEl.setEmtpyTableMessageKey("table.empty");
    FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
    sortOptions.setDefaultOrderBy(new SortKey(MeetingsCols.start.name(), true));
    upcomingTableEl.setSortSettings(sortOptions);
    FlexiTableColumnModel pastColumnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    pastColumnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MeetingsCols.name.i18nHeaderKey(), MeetingsCols.name.ordinal(), true, MeetingsCols.name.name()));
    pastColumnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MeetingsCols.start.i18nHeaderKey(), MeetingsCols.start.ordinal(), true, MeetingsCols.start.name()));
    pastColumnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MeetingsCols.end.i18nHeaderKey(), MeetingsCols.end.ordinal(), true, MeetingsCols.end.name()));
    pastColumnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("select", translate("select"), "select-past"));
    pastTableModel = new GoToMeetingTableModel(pastColumnsModel);
    pastTableEl = uifactory.addTableElement(getWindowControl(), "pastmeetings", pastTableModel, getTranslator(), formLayout);
    FlexiTableSortOptions pastSortOptions = new FlexiTableSortOptions();
    pastSortOptions.setDefaultOrderBy(new SortKey(MeetingsCols.start.name(), false));
    pastTableEl.setSortSettings(sortOptions);
    updateModel();
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) SortKey(org.olat.core.commons.persistence.SortKey) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Example 33 with SortKey

use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.

the class AbstractMemberListController method initColumns.

private SortKey initColumns(FlexiTableColumnModel columnsModel) {
    SortKey defaultSortKey = null;
    String editAction = readOnly ? null : TABLE_ACTION_EDIT;
    if (chatEnabled) {
        DefaultFlexiColumnModel chatCol = new DefaultFlexiColumnModel(Cols.online.i18n(), Cols.online.ordinal());
        chatCol.setExportable(false);
        columnsModel.addFlexiColumnModel(chatCol);
    }
    if (isAdministrativeUser) {
        FlexiCellRenderer renderer = new StaticFlexiCellRenderer(editAction, new TextFlexiCellRenderer());
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.username.i18n(), Cols.username.ordinal(), editAction, true, Cols.username.name(), renderer));
        defaultSortKey = new SortKey(Cols.username.name(), true);
    }
    int colPos = USER_PROPS_OFFSET;
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null)
            continue;
        String propName = userPropertyHandler.getName();
        boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
        FlexiColumnModel col;
        if (UserConstants.FIRSTNAME.equals(propName) || UserConstants.LASTNAME.equals(propName)) {
            col = new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos, editAction, true, propName, new StaticFlexiCellRenderer(editAction, new TextFlexiCellRenderer()));
        } else {
            col = new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos, true, propName);
        }
        columnsModel.addFlexiColumnModel(col);
        colPos++;
        if (defaultSortKey == null) {
            defaultSortKey = new SortKey(propName, true);
        }
    }
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.firstTime.i18n(), Cols.firstTime.ordinal(), true, Cols.firstTime.name()));
    if (isLastVisitVisible) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.lastTime.i18n(), Cols.lastTime.ordinal(), true, Cols.lastTime.name()));
    }
    CourseRoleCellRenderer roleRenderer = new CourseRoleCellRenderer(getLocale());
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.role.i18n(), Cols.role.ordinal(), true, Cols.role.name(), roleRenderer));
    if (repoEntry != null) {
        GroupCellRenderer groupRenderer = new GroupCellRenderer();
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.groups.i18n(), Cols.groups.ordinal(), true, Cols.groups.name(), groupRenderer));
    }
    DefaultFlexiColumnModel toolsCol = new DefaultFlexiColumnModel(Cols.tools.i18n(), Cols.tools.ordinal());
    toolsCol.setExportable(false);
    toolsCol.setAlwaysVisible(true);
    columnsModel.addFlexiColumnModel(toolsCol);
    return defaultSortKey;
}
Also used : StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) FlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) FlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel) SortKey(org.olat.core.commons.persistence.SortKey) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 34 with SortKey

use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.

the class FlexiTableElementImpl method setSortSettings.

@Override
public void setSortSettings(FlexiTableSortOptions options) {
    this.sortOptions = options;
    if (options.getDefaultOrderBy() != null) {
        SortKey defaultOrder = options.getDefaultOrderBy();
        orderBy = new SortKey[] { defaultOrder };
        selectSortOption(defaultOrder.getKey(), defaultOrder.isAsc());
    }
}
Also used : SortKey(org.olat.core.commons.persistence.SortKey)

Example 35 with SortKey

use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.

the class FlexiTableElementImpl method sort.

@Override
public void sort(String sortKey, boolean asc) {
    collapseAllDetails();
    SortKey key;
    if (StringHelper.containsNonWhitespace(sortKey)) {
        key = new SortKey(sortKey, asc);
        orderBy = new SortKey[] { key };
    } else {
        key = null;
        orderBy = null;
    }
    if (dataModel instanceof SortableFlexiTableDataModel) {
        ((SortableFlexiTableDataModel<?>) dataModel).sort(key);
    } else if (dataSource != null) {
        currentPage = 0;
        if (dataModel instanceof FlexiTableDataSource) {
            ((FlexiTableDataSource<?>) dataModel).clear();
            ((FlexiTableDataSource<?>) dataModel).load(getSearchText(), getSelectedFilters(), getConditionalQueries(), 0, getPageSize(), orderBy);
        } else {
            dataSource.clear();
            dataSource.load(getSearchText(), getSelectedFilters(), getConditionalQueries(), 0, getPageSize(), orderBy);
        }
    }
    reorderMultiSelectIndex();
    selectSortOption(sortKey, asc);
    component.setDirty(true);
}
Also used : SortKey(org.olat.core.commons.persistence.SortKey)

Aggregations

SortKey (org.olat.core.commons.persistence.SortKey)82 FlexiTableSortOptions (org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions)48 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)42 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)42 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)30 ArrayList (java.util.ArrayList)20 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)18 Identity (org.olat.core.id.Identity)18 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)18 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)14 Test (org.junit.Test)12 FlexiTableFilter (org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)12 FlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel)12 BooleanCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer)10 QuestionItem (org.olat.modules.qpool.QuestionItem)10 QuestionItemView (org.olat.modules.qpool.QuestionItemView)10 FlexiTableSort (org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)8 DateFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.DateFlexiCellRenderer)8 FlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiCellRenderer)6 BusinessGroup (org.olat.group.BusinessGroup)6