Search in sources :

Example 36 with FlexiTableSortOptions

use of org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions in project OpenOLAT by OpenOLAT.

the class MySharedItemsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("my.shared.items");
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, MySharedItemCols.binderKey, "select"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MySharedItemCols.binderName, "select"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MySharedItemCols.courseName, "select"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MySharedItemCols.lastModified));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("select", translate("select"), "select"));
    model = new MySharedItemsDataModel(columnsModel, getLocale());
    tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
    tableEl.setSearchEnabled(true);
    tableEl.setCustomizeColumns(true);
    tableEl.setElementCssClass("o_binder_shared_items_listing");
    tableEl.setEmtpyTableMessageKey("table.sEmptyTable");
    tableEl.setPageSize(24);
    tableEl.setAndLoadPersistedPreferences(ureq, "my-shared-items");
    FlexiTableSortOptions options = new FlexiTableSortOptions();
    options.setDefaultOrderBy(new SortKey(MySharedItemCols.binderName.name(), true));
    tableEl.setSortSettings(options);
}
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 37 with FlexiTableSortOptions

use of org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions in project OpenOLAT by OpenOLAT.

the class TeacherRollCallController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        StringBuilder sb = new StringBuilder();
        List<Identity> teachers = lectureService.getTeachers(lectureBlock);
        for (Identity teacher : teachers) {
            if (sb.length() > 0)
                sb.append(", ");
            sb.append(StringHelper.escapeHtml(userManager.getUserDisplayName(teacher)));
        }
        Formatter formatter = Formatter.getInstance(getLocale());
        String date = formatter.formatDate(lectureBlock.getStartDate());
        String startTime = formatter.formatTimeShort(lectureBlock.getStartDate());
        String endTime = formatter.formatTimeShort(lectureBlock.getEndDate());
        String[] args = new String[] { // {0}
        lectureBlock.getTitle(), // {1}
        sb.toString(), // {2}
        date, // {3}
        startTime, // {4}
        endTime };
        layoutCont.contextPut("date", date);
        layoutCont.contextPut("startTime", startTime);
        layoutCont.contextPut("endTime", endTime);
        layoutCont.contextPut("dateAndTime", translate("lecture.block.dateAndTime", args));
        layoutCont.contextPut("teachers", sb.toString());
        layoutCont.contextPut("lectureBlockTitle", StringHelper.escapeHtml(lectureBlock.getTitle()));
        layoutCont.contextPut("lectureBlockExternalId", StringHelper.escapeHtml(lectureBlock.getExternalId()));
        StringBuilder description = Formatter.stripTabsAndReturns(Formatter.formatURLsAsLinks(lectureBlock.getDescription()));
        layoutCont.contextPut("lectureBlockDescription", StringHelper.xssScan(description));
        StringBuilder preparation = Formatter.stripTabsAndReturns(Formatter.formatURLsAsLinks(lectureBlock.getPreparation()));
        layoutCont.contextPut("lectureBlockPreparation", StringHelper.xssScan(preparation));
        layoutCont.contextPut("lectureBlockLocation", StringHelper.escapeHtml(lectureBlock.getLocation()));
        layoutCont.contextPut("lectureBlock", lectureBlock);
        layoutCont.contextPut("lectureBlockOptional", !lectureBlock.isCompulsory());
        layoutCont.setFormTitle(translate("lecture.block", args));
        layoutCont.setFormDescription(StringHelper.escapeJavaScript(lectureBlock.getDescription()));
    }
    // table
    FlexiTableSortOptions options = new FlexiTableSortOptions();
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    if (isAdministrativeUser) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RollCols.username));
        options.setDefaultOrderBy(new SortKey(RollCols.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));
        }
    }
    if (lectureBlock.isCompulsory()) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RollCols.status));
        for (int i = 0; i < numOfLectures; i++) {
            DefaultFlexiColumnModel col = new DefaultFlexiColumnModel("table.header.lecture." + (i + 1), i + CHECKBOX_OFFSET, true, "lecture." + (i + 1));
            col.setAlwaysVisible(true);
            columnsModel.addFlexiColumnModel(col);
        }
        // all button
        DefaultFlexiColumnModel allCol = new DefaultFlexiColumnModel("all", RollCols.all.ordinal(), "all", new BooleanCellRenderer(new StaticFlexiCellRenderer(translate("all"), "all", null, null, translate("all.desc")), null));
        allCol.setAlwaysVisible(true);
        columnsModel.addFlexiColumnModel(allCol);
        if (secCallback.canViewAuthorizedAbsences() || secCallback.canEditAuthorizedAbsences()) {
            DefaultFlexiColumnModel authorizedCol = new DefaultFlexiColumnModel(RollCols.authorizedAbsence);
            authorizedCol.setAlwaysVisible(true);
            columnsModel.addFlexiColumnModel(authorizedCol);
        }
    }
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RollCols.comment));
    tableModel = new TeacherRollCallDataModel(columnsModel, secCallback, getLocale());
    tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout);
    tableEl.setCustomizeColumns(true);
    tableEl.setSortSettings(options);
    tableEl.setAndLoadPersistedPreferences(ureq, "teacher-roll-call");
    // buttons
    uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
    quickSaveButton = uifactory.addFormSubmitButton("save", "save.temporary", formLayout);
    quickSaveButton.setElementCssClass("o_sel_lecture_quick_save");
    closeLectureBlocksButton = uifactory.addFormLink("close.lecture.blocks", formLayout, Link.BUTTON);
    closeLectureBlocksButton.setElementCssClass("o_sel_lecture_close");
    if (lectureModule.isStatusCancelledEnabled()) {
        cancelLectureBlockButton = uifactory.addFormLink("cancel.lecture.blocks", formLayout, Link.BUTTON);
    }
    reopenButton = uifactory.addFormLink("reopen.lecture.blocks", formLayout, Link.BUTTON);
    reopenButton.setElementCssClass("o_sel_lecture_reopen");
    updateUI();
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) Formatter(org.olat.core.util.Formatter) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) FlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) SortKey(org.olat.core.commons.persistence.SortKey) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) BooleanCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) Identity(org.olat.core.id.Identity) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 38 with FlexiTableSortOptions

use of org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions in project OpenOLAT by OpenOLAT.

the class TeacherLecturesTableController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    if (withRepositoryEntry) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.externalRef, "open.course"));
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.entry, "open.course"));
    }
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.date, new DateFlexiCellRenderer(getLocale())));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.startTime, new TimeFlexiCellRenderer(getLocale())));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.endTime, new TimeFlexiCellRenderer(getLocale())));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.lectureBlock));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.location));
    if (withTeachers) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.teachers));
    }
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.status, new LectureBlockStatusCellRenderer(getTranslator())));
    DefaultFlexiColumnModel detailsCol = new DefaultFlexiColumnModel(TeachCols.details.i18nHeaderKey(), TeachCols.details.ordinal(), "details", new BooleanCellRenderer(new StaticFlexiCellRenderer(translate("table.header.details"), "details"), null));
    // set sort key even though we do not sort - added as css classes to column headers for styling
    detailsCol.setSortKey(TeachCols.details.name());
    columnsModel.addFlexiColumnModel(detailsCol);
    DefaultFlexiColumnModel toolsCol = new DefaultFlexiColumnModel(TeachCols.tools);
    toolsCol.setSortable(false);
    columnsModel.addFlexiColumnModel(toolsCol);
    tableModel = new TeacherOverviewDataModel(columnsModel, getLocale());
    tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout);
    FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
    sortOptions.setDefaultOrderBy(new SortKey(TeachCols.date.name(), sortAsc));
    tableEl.setSortSettings(sortOptions);
    tableEl.setCustomizeColumns(false);
    tableEl.setNumOfRowsEnabled(false);
    tableEl.setEmtpyTableMessageKey(emptyI18nKey);
    tableEl.setAndLoadPersistedPreferences(ureq, "lecture-teacher-overview-".concat(id));
}
Also used : DateFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.DateFlexiCellRenderer) FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) TimeFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TimeFlexiCellRenderer) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) BooleanCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) SortKey(org.olat.core.commons.persistence.SortKey) LectureBlockStatusCellRenderer(org.olat.modules.lecture.ui.component.LectureBlockStatusCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Example 39 with FlexiTableSortOptions

use of org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions in project OpenOLAT by OpenOLAT.

the class LectureListRepositoryController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (!lectureManagementManaged) {
        addLectureButton = uifactory.addFormLink("add.lecture", formLayout, Link.BUTTON);
        addLectureButton.setIconLeftCSS("o_icon o_icon_add");
        addLectureButton.setElementCssClass("o_sel_repo_add_lecture");
        deleteLecturesButton = uifactory.addFormLink("delete", formLayout, Link.BUTTON);
    }
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, BlockCols.id));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(BlockCols.title));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(BlockCols.location));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(BlockCols.date, new DateFlexiCellRenderer(getLocale())));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(BlockCols.startTime, new TimeFlexiCellRenderer(getLocale())));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(BlockCols.endTime, new TimeFlexiCellRenderer(getLocale())));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(BlockCols.teachers));
    if (lectureManagementManaged) {
        // edit check it
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("details", translate("details"), "edit"));
    } else {
        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);
        DefaultFlexiColumnModel toolsColumn = new DefaultFlexiColumnModel(BlockCols.tools);
        toolsColumn.setExportable(false);
        toolsColumn.setAlwaysVisible(true);
        columnsModel.addFlexiColumnModel(toolsColumn);
    }
    tableModel = new LectureListRepositoryDataModel(columnsModel, getLocale());
    tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout);
    tableEl.setExportEnabled(true);
    tableEl.setMultiSelect(true);
    tableEl.setSelectAllEnable(true);
    tableEl.setEmtpyTableMessageKey("empty.table.lectures.blocks.admin");
    FlexiTableSortOptions options = new FlexiTableSortOptions();
    options.setDefaultOrderBy(new SortKey(BlockCols.date.name(), false));
    tableEl.setSortSettings(options);
    tableEl.setAndLoadPersistedPreferences(ureq, "repo-lecture-block-list");
}
Also used : DateFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.DateFlexiCellRenderer) FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) TimeFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TimeFlexiCellRenderer) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) 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 40 with FlexiTableSortOptions

use of org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions in project openolat by klemens.

the class TeacherLecturesTableController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    if (withRepositoryEntry) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.externalRef, "open.course"));
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.entry, "open.course"));
    }
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.date, new DateFlexiCellRenderer(getLocale())));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.startTime, new TimeFlexiCellRenderer(getLocale())));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.endTime, new TimeFlexiCellRenderer(getLocale())));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.lectureBlock));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.location));
    if (withTeachers) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.teachers));
    }
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(TeachCols.status, new LectureBlockStatusCellRenderer(getTranslator())));
    DefaultFlexiColumnModel detailsCol = new DefaultFlexiColumnModel(TeachCols.details.i18nHeaderKey(), TeachCols.details.ordinal(), "details", new BooleanCellRenderer(new StaticFlexiCellRenderer(translate("table.header.details"), "details"), null));
    // set sort key even though we do not sort - added as css classes to column headers for styling
    detailsCol.setSortKey(TeachCols.details.name());
    columnsModel.addFlexiColumnModel(detailsCol);
    DefaultFlexiColumnModel toolsCol = new DefaultFlexiColumnModel(TeachCols.tools);
    toolsCol.setSortable(false);
    columnsModel.addFlexiColumnModel(toolsCol);
    tableModel = new TeacherOverviewDataModel(columnsModel, getLocale());
    tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout);
    FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
    sortOptions.setDefaultOrderBy(new SortKey(TeachCols.date.name(), sortAsc));
    tableEl.setSortSettings(sortOptions);
    tableEl.setCustomizeColumns(false);
    tableEl.setNumOfRowsEnabled(false);
    tableEl.setEmtpyTableMessageKey(emptyI18nKey);
    tableEl.setAndLoadPersistedPreferences(ureq, "lecture-teacher-overview-".concat(id));
}
Also used : DateFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.DateFlexiCellRenderer) FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) TimeFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TimeFlexiCellRenderer) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) BooleanCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) SortKey(org.olat.core.commons.persistence.SortKey) LectureBlockStatusCellRenderer(org.olat.modules.lecture.ui.component.LectureBlockStatusCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Aggregations

FlexiTableSortOptions (org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions)52 SortKey (org.olat.core.commons.persistence.SortKey)48 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)44 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)38 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)26 ArrayList (java.util.ArrayList)18 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)18 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)14 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)12 FlexiTableFilter (org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)10 FlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel)10 FlexiTableSort (org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)8 BooleanCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer)8 DateFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.DateFlexiCellRenderer)8 LicenseRenderer (org.olat.core.commons.services.license.ui.LicenseRenderer)4 TimeFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TimeFlexiCellRenderer)4 Identity (org.olat.core.id.Identity)4 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)4 BusinessGroup (org.olat.group.BusinessGroup)4 PublisherData (org.olat.core.commons.services.notifications.PublisherData)2