Search in sources :

Example 71 with SortKey

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

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)

Example 72 with SortKey

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

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

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

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

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

the class SharedBindersController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, ShareItemCols.binderKey, "select"));
    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(ShareItemCols.binderName, "select"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.courseName, "select"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.lastModified));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.recentLaunch));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.openSections, "select"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.selectSections, new SelectSectionsCellRenderer()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.newlyPublishedPage));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, ShareItemCols.draftPage));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, ShareItemCols.inRevisionPage));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, ShareItemCols.closedPage));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.grading, new AssessmentEntryCellRenderer(getTranslator())));
    StaticFlexiCellRenderer selectRenderer = new StaticFlexiCellRenderer(translate("select"), "select");
    selectRenderer.setIconRightCSS("o_icon-sw o_icon_start");
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, true, "select", -1, "select", false, null, FlexiColumnModel.ALIGNMENT_LEFT, selectRenderer));
    StaticFlexiCellRenderer leaveRenderer = new StaticFlexiCellRenderer(translate("leave"), "leave");
    leaveRenderer.setIconRightCSS("o_icon-sw o_icon_delete");
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, false, "leave", -2, "leave", false, null, FlexiColumnModel.ALIGNMENT_LEFT, leaveRenderer));
    model = new SharedBindersDataModel(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, "shared-items");
    FlexiTableSortOptions options = new FlexiTableSortOptions();
    if (defaultSortKey != null) {
        options.setDefaultOrderBy(defaultSortKey);
    }
    tableEl.setSortSettings(options);
    List<FlexiTableFilter> tableFilters = new ArrayList<>();
    tableFilters.add(new FlexiTableFilter(translate("filter.sections.empty"), SharedBindersDataModel.EMPTY_SECTIONS, true));
    tableFilters.add(FlexiTableFilter.SPACER);
    tableFilters.add(new FlexiTableFilter(translate("filter.show.all"), "all", true));
    tableEl.setFilters("Filters", tableFilters, false);
    tableEl.setSelectedFilterKey(SharedBindersDataModel.EMPTY_SECTIONS);
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) SelectSectionsCellRenderer(org.olat.modules.portfolio.ui.renderer.SelectSectionsCellRenderer) ArrayList(java.util.ArrayList) SortKey(org.olat.core.commons.persistence.SortKey) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) AssessmentEntryCellRenderer(org.olat.modules.portfolio.ui.renderer.AssessmentEntryCellRenderer) 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 75 with SortKey

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

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)

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