Search in sources :

Example 56 with SortKey

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

the class GoToMeetingsEditController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (!readOnly) {
        addTrainingButton = uifactory.addFormLink("add.training", formLayout, Link.BUTTON);
    }
    // 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(MeetingsCols.organizer.i18nHeaderKey(), MeetingsCols.organizer.ordinal(), true, MeetingsCols.organizer.name()));
    if (!readOnly) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("edit", translate("edit"), "edit"));
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("delete", translate("delete"), "delete"));
    }
    tableModel = new GoToMeetingTableModel(columnsModel);
    tableEl = uifactory.addTableElement(getWindowControl(), "meetings", tableModel, getTranslator(), formLayout);
    FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
    sortOptions.setDefaultOrderBy(new SortKey(MeetingsCols.start.name(), false));
    tableEl.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 57 with SortKey

use of org.olat.core.commons.persistence.SortKey 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 58 with SortKey

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

the class SharedPagesController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SharePageCols.bookmark));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SharePageCols.userInfosStatus, new SharedPageStatusCellRenderer(getTranslator())));
    FlexiCellRenderer titleRenderer = new BooleanCellRenderer(new StaticFlexiCellRenderer("select", new PageTitleCellRenderer()), new PageTitleCellRenderer());
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, true, "select", SharePageCols.pageName.ordinal(), "select", true, SharePageCols.pageName.sortKey(), FlexiColumnModel.ALIGNMENT_LEFT, titleRenderer));
    SortKey defaultSortKey = null;
    if (isAdministrativeUser) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.username));
        defaultSortKey = new SortKey(Cols.username.name(), true);
    }
    // followed by the users fields
    int colPos = USER_PROPS_OFFSET;
    for (int i = 0; i < userPropertyHandlers.size(); i++) {
        UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
        String propName = userPropertyHandler.getName();
        if (defaultSortKey == null && i == 0) {
            defaultSortKey = new SortKey(propName, true);
        } else if (UserConstants.LASTNAME.equals(propName) && !isAdministrativeUser) {
            defaultSortKey = new SortKey(propName, true);
        }
        boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos, true, propName));
        colPos++;
    }
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SharePageCols.lastChanges));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SharePageCols.pageStatus, new StatusCellRenderer(getTranslator())));
    model = new SharedPagesDataModel(columnsModel, getLocale());
    tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
    tableEl.setSearchEnabled(true);
    tableEl.setCustomizeColumns(true);
    tableEl.setElementCssClass("o_binder_shared_bookmark_pages_listing");
    tableEl.setEmtpyTableMessageKey("table.sEmptyTable");
    tableEl.setPageSize(24);
    tableEl.setAndLoadPersistedPreferences(ureq, "shared-bookmark-pages");
    if (filters != null && !filters.isEmpty()) {
        List<FlexiTableFilter> tableFilters = new ArrayList<>(filters.size());
        for (PageStatus status : filters) {
            String label = translate(status.i18nKey());
            tableFilters.add(new FlexiTableFilter(label, status.name(), "o_icon ".concat(status.cssClass())));
        }
        tableFilters.add(FlexiTableFilter.SPACER);
        tableFilters.add(new FlexiTableFilter(translate("filter.show.all"), "all", true));
        tableEl.setFilters("Filters", tableFilters, true);
        if (defaultFilter != null) {
            tableEl.setSelectedFilterKey(defaultFilter.name());
        }
    }
}
Also used : PageStatus(org.olat.modules.portfolio.PageStatus) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) FlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiCellRenderer) PageTitleCellRenderer(org.olat.modules.portfolio.ui.renderer.PageTitleCellRenderer) ArrayList(java.util.ArrayList) StatusCellRenderer(org.olat.modules.portfolio.ui.renderer.StatusCellRenderer) SharedPageStatusCellRenderer(org.olat.modules.portfolio.ui.renderer.SharedPageStatusCellRenderer) SortKey(org.olat.core.commons.persistence.SortKey) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) SharedPageStatusCellRenderer(org.olat.modules.portfolio.ui.renderer.SharedPageStatusCellRenderer) BooleanCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) 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 59 with SortKey

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

the class FlexiTableClassicRenderer method renderHeader.

private void renderHeader(StringOutput sb, FlexiTableComponent ftC, FlexiColumnModel fcm, Translator translator) {
    String header = getHeader(fcm, translator);
    sb.append("<th");
    // append sort key to make column width set via css
    if (fcm.getSortKey() != null) {
        sb.append(" class='o_col_").append(fcm.getSortKey()).append("'");
    }
    sb.append(">");
    // sort is not defined
    if (!fcm.isSortable() || fcm.getSortKey() == null) {
        sb.append(header);
    } else {
        FlexiTableElementImpl ftE = ftC.getFlexiTableElement();
        Boolean asc = null;
        String sortKey = fcm.getSortKey();
        SortKey[] orderBy = ftE.getOrderBy();
        if (orderBy != null && orderBy.length > 0) {
            for (int i = orderBy.length; i-- > 0; ) {
                if (sortKey.equals(orderBy[i].getKey())) {
                    asc = new Boolean(orderBy[i].isAsc());
                }
            }
        }
        Form theForm = ftE.getRootForm();
        if (asc == null) {
            sb.append("<a class='o_orderby' href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, ftC.getFormDispatchId(), 1, true, true, true, new NameValuePair("sort", sortKey), new NameValuePair("asc", "asc"))).append("\">");
        } else if (asc.booleanValue()) {
            sb.append("<a class='o_orderby o_orderby_asc' href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, ftC.getFormDispatchId(), 1, true, true, true, new NameValuePair("sort", sortKey), new NameValuePair("asc", "desc"))).append("\">");
        } else {
            sb.append("<a class='o_orderby o_orderby_desc' href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, ftC.getFormDispatchId(), 1, true, true, true, new NameValuePair("sort", sortKey), new NameValuePair("asc", "asc"))).append("\">");
        }
        sb.append(header).append("</a>");
    }
    sb.append("</th>");
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form) SortKey(org.olat.core.commons.persistence.SortKey)

Example 60 with SortKey

use of org.olat.core.commons.persistence.SortKey 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)

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