Search in sources :

Example 1 with SortKey

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

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 2 with SortKey

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

the class MembersTableController method initColumns.

private SortKey initColumns(FlexiTableColumnModel columnsModel) {
    int colPos = AbstractMemberListController.USER_PROPS_OFFSET;
    SortKey defaultSortKey = null;
    String rowAction = "vcard";
    if (chatEnabled && editable) {
        DefaultFlexiColumnModel chatCol = new DefaultFlexiColumnModel(Cols.online.i18n(), Cols.online.ordinal());
        chatCol.setExportable(false);
        columnsModel.addFlexiColumnModel(chatCol);
    }
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null)
            continue;
        String propName = userPropertyHandler.getName();
        boolean visible = userManager.isMandatoryUserProperty(MembersDisplayRunController.USER_PROPS_LIST_ID, userPropertyHandler);
        String emailRowAction = rowAction;
        FlexiColumnModel col;
        if (UserConstants.FIRSTNAME.equals(propName) || UserConstants.LASTNAME.equals(propName) || UserConstants.EMAIL.equals(propName)) {
            // when email is enabled, the action will trigger email workflow
            if (UserConstants.EMAIL.equals(propName) && canEmail) {
                emailRowAction = "email";
            }
            col = new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos, emailRowAction, true, propName, new StaticFlexiCellRenderer(emailRowAction, new TextFlexiCellRenderer()));
        } else {
            col = new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos, true, propName);
        }
        columnsModel.addFlexiColumnModel(col);
        colPos++;
        if (defaultSortKey == null) {
            defaultSortKey = new SortKey(propName, true);
        }
    }
    if (userLastTimeVisible) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.firstTime.i18n(), Cols.firstTime.ordinal(), true, Cols.firstTime.name()));
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.lastTime.i18n(), Cols.lastTime.ordinal(), true, Cols.lastTime.name()));
    }
    return defaultSortKey;
}
Also used : StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) 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 3 with SortKey

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

the class MembersTableController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    SortKey defaultSortKey = initColumns(columnsModel);
    membersModel = new MemberListTableModel(columnsModel, imModule.isOnlineStatusEnabled());
    membersModel.setObjects(membersList);
    membersTable = uifactory.addTableElement(getWindowControl(), "table", membersModel, pageSize, false, getTranslator(), formLayout);
    membersTable.setEmtpyTableMessageKey("nomembers");
    membersTable.setAndLoadPersistedPreferences(ureq, this.getClass().getSimpleName());
    membersTable.setExportEnabled(false);
    membersTable.setElementCssClass("o_sel_member_list");
    if (defaultSortKey != null) {
        FlexiTableSortOptions options = new FlexiTableSortOptions();
        options.setDefaultOrderBy(defaultSortKey);
        membersTable.setSortSettings(options);
    }
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) MemberListTableModel(org.olat.group.ui.main.MemberListTableModel) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) SortKey(org.olat.core.commons.persistence.SortKey)

Example 4 with SortKey

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

the class BinderPageListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (tableEl == source) {
        if (event instanceof FlexiTableRenderEvent) {
            FlexiTableRenderEvent re = (FlexiTableRenderEvent) event;
            if (re.getRendererType() == FlexiTableRendererType.custom) {
                tableEl.sort(new SortKey(null, false));
            }
        } else if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            String cmd = se.getCommand();
            if ("select-page".equals(cmd)) {
                PortfolioElementRow row = model.getObject(se.getIndex());
                if (row.isPendingAssignment()) {
                    doStartAssignment(ureq, row);
                } else {
                    doOpenRow(ureq, row, false);
                }
            }
        }
    } else if (previousSectionLink == source) {
        Section previousSection = (Section) previousSectionLink.getUserObject();
        doFilterSection(previousSection);
    } else if (nextSectionLink == source) {
        Section nextSection = (Section) nextSectionLink.getUserObject();
        doFilterSection(nextSection);
    } else if (showAllSectionsLink == source) {
        doShowAll();
    } else if (newSectionButton == source) {
        doCreateNewSection(ureq);
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        if ("new.entry".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doCreateNewPage(ureq, row.getSection());
        } else if ("new.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doCreateNewAssignment(ureq, row.getSection());
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) SortKey(org.olat.core.commons.persistence.SortKey) FlexiTableRenderEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableRenderEvent) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section)

Example 5 with SortKey

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

the class BinderPageListController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    super.initForm(formLayout, listener, ureq);
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        StringBuilder ownerSb = new StringBuilder();
        for (Identity owner : owners) {
            if (ownerSb.length() > 0)
                ownerSb.append(", ");
            ownerSb.append(userManager.getUserDisplayName(owner));
        }
        layoutCont.contextPut("owners", ownerSb.toString());
        layoutCont.contextPut("binderKey", binder.getKey());
        layoutCont.contextPut("binderTitle", StringHelper.escapeHtml(binder.getTitle()));
    }
    FlexiTableSortOptions options = new FlexiTableSortOptions();
    options.setFromColumnModel(false);
    options.setDefaultOrderBy(new SortKey(null, false));
    tableEl.setSortSettings(options);
    previousSectionLink = uifactory.addFormLink("section.paging.previous", formLayout, Link.BUTTON | Link.NONTRANSLATED);
    previousSectionLink.setVisible(false);
    previousSectionLink.setIconLeftCSS("o_icon o_icon_move_left");
    nextSectionLink = uifactory.addFormLink("section.paging.next", formLayout, Link.BUTTON | Link.NONTRANSLATED);
    nextSectionLink.setVisible(false);
    nextSectionLink.setIconRightCSS("o_icon o_icon_move_right");
    showAllSectionsLink = uifactory.addFormLink("section.paging.all", formLayout, Link.BUTTON);
    showAllSectionsLink.setVisible(false);
    if (secCallback.canAddSection()) {
        newSectionButton = uifactory.addFormLink("create.new.section", formLayout, Link.BUTTON);
        newSectionButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_section");
    }
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) SortKey(org.olat.core.commons.persistence.SortKey) Identity(org.olat.core.id.Identity)

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