Search in sources :

Example 11 with DefaultFlexiColumnModel

use of org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel in project OpenOLAT by OpenOLAT.

the class CertificatesSelectionController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    ;
    int colPos = 0;
    if (isAdministrativeUser) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.name", CertificatesSelectionDataModel.USERNAME_COL));
    }
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(AssessedIdentitiesTableDataModel.usageIdentifyer, isAdministrativeUser);
    List<UserPropertyHandler> resultingPropertyHandlers = new ArrayList<UserPropertyHandler>();
    // followed by the users fields
    for (int i = 0; i < userPropertyHandlers.size(); i++) {
        UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
        boolean visible = userManager.isMandatoryUserProperty(AssessedIdentitiesTableDataModel.usageIdentifyer, userPropertyHandler);
        resultingPropertyHandlers.add(userPropertyHandler);
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos++, false, null));
    }
    if (hasAssessableNodes) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.passed", CertificatesSelectionDataModel.PASSED_COL, new PassedCellRenderer()));
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.score", CertificatesSelectionDataModel.SCORE_COL));
    }
    tableModel = new CertificatesSelectionDataModel(columnsModel, resultingPropertyHandlers);
    Set<Integer> preselectedRows = new HashSet<>();
    ICourse course = CourseFactory.loadCourse(courseEntry);
    CourseNode rootNode = course.getRunStructure().getRootNode();
    List<CertificateInfos> infos = new ArrayList<>(datas.size());
    int count = 0;
    for (AssessedIdentityWrapper data : datas) {
        ScoreEvaluation scoreEval = data.getUserCourseEnvironment().getScoreAccounting().getScoreEvaluation(rootNode);
        Float score = scoreEval == null ? null : scoreEval.getScore();
        Boolean passed = scoreEval == null ? null : scoreEval.getPassed();
        Identity assessedIdentity = data.getIdentity();
        infos.add(new CertificateInfos(assessedIdentity, score, passed));
        if (passed != null && passed.booleanValue()) {
            preselectedRows.add(new Integer(count));
        }
        count++;
    }
    tableModel.setObjects(infos);
    tableEl = uifactory.addTableElement(getWindowControl(), "selection", tableModel, getTranslator(), formLayout);
    tableEl.setMultiSelect(true);
    tableEl.setSelectAllEnable(true);
    tableEl.setMultiSelectedIndex(preselectedRows);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) CertificateInfos(org.olat.course.certificate.model.CertificateInfos) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) AssessedIdentityWrapper(org.olat.course.assessment.AssessedIdentityWrapper) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) CourseNode(org.olat.course.nodes.CourseNode) PassedCellRenderer(org.olat.course.assessment.bulk.PassedCellRenderer) Identity(org.olat.core.id.Identity) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) HashSet(java.util.HashSet)

Example 12 with DefaultFlexiColumnModel

use of org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel in project OpenOLAT by OpenOLAT.

the class HibernateEntitiesController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(EntityCols.entity.i18nKey(), EntityCols.entity.ordinal(), true, EntityCols.entity.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(EntityCols.load.i18nKey(), EntityCols.load.ordinal(), true, EntityCols.load.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(EntityCols.fetch.i18nKey(), EntityCols.fetch.ordinal(), true, EntityCols.fetch.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(EntityCols.insert.i18nKey(), EntityCols.insert.ordinal(), true, EntityCols.insert.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(EntityCols.update.i18nKey(), EntityCols.update.ordinal(), true, EntityCols.update.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(EntityCols.delete.i18nKey(), EntityCols.delete.ordinal(), true, EntityCols.delete.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(EntityCols.optimisticFailure.i18nKey(), EntityCols.optimisticFailure.ordinal(), true, EntityCols.optimisticFailure.name()));
    tableModel = new EntityStatisticsDataModel(columnsModel);
    table = uifactory.addTableElement(getWindowControl(), "entities", tableModel, 50, true, getTranslator(), formLayout);
    table.setAndLoadPersistedPreferences(ureq, "HibernateEntityStatistics");
    table.setExportEnabled(true);
    table.setPageSize(250);
}
Also used : FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Example 13 with DefaultFlexiColumnModel

use of org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel in project OpenOLAT by OpenOLAT.

the class HibernateQueriesController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(QueryCols.average.i18nKey(), QueryCols.average.ordinal(), true, QueryCols.average.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(QueryCols.max.i18nKey(), QueryCols.max.ordinal(), true, QueryCols.max.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(QueryCols.min.i18nKey(), QueryCols.min.ordinal(), true, QueryCols.min.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, QueryCols.row.i18nKey(), QueryCols.row.ordinal(), true, QueryCols.row.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(QueryCols.count.i18nKey(), QueryCols.count.ordinal(), true, QueryCols.count.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, QueryCols.cacheHits.i18nKey(), QueryCols.cacheHits.ordinal(), true, QueryCols.cacheHits.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, QueryCols.cacheMisses.i18nKey(), QueryCols.cacheMisses.ordinal(), true, QueryCols.cacheMisses.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, QueryCols.cachePuts.i18nKey(), QueryCols.cachePuts.ordinal(), true, QueryCols.cachePuts.name()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(QueryCols.query.i18nKey(), QueryCols.query.ordinal(), true, QueryCols.query.name()));
    tableModel = new QueryStatisticsDataModel(columnsModel);
    table = uifactory.addTableElement(getWindowControl(), "queries", tableModel, 50, true, getTranslator(), formLayout);
    table.setAndLoadPersistedPreferences(ureq, "HibernateQueriesStatistics");
    table.setExportEnabled(true);
}
Also used : FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Example 14 with DefaultFlexiColumnModel

use of org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel in project OpenOLAT by OpenOLAT.

the class LandingPagesAdminController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("landingpages.title");
    // add the table
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.position.i18nKey(), RCols.position.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.role.i18nKey(), RCols.role.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.userAttributeKey.i18nKey(), RCols.userAttributeKey.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.userAttributeValue.i18nKey(), RCols.userAttributeValue.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.landingPage.i18nKey(), RCols.landingPage.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.landingPageChooser.i18nKey(), RCols.landingPageChooser.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("up", -1, "up", new StaticFlexiCellRenderer("", "up", "o_icon o_icon-lg o_icon_move_up", translate("up"))));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("down", -1, "down", new StaticFlexiCellRenderer("", "down", "o_icon o_icon-lg o_icon_move_down", translate("down"))));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("add", translate("add"), "add"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("delete", translate("delete"), "delete"));
    // pack the rules
    Rules rules = lpModule.getRules();
    List<Rule> ruleList = new ArrayList<>(rules.getRules());
    if (ruleList.isEmpty()) {
        ruleList.add(new Rule());
    }
    List<RuleWrapper> wrappers = new ArrayList<>();
    int i = 0;
    for (Rule rule : ruleList) {
        wrappers.add(initRuleWrapper(++i, rule, formLayout));
    }
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("rules", wrappers);
    }
    model = new RulesDataModel(columnsModel, wrappers);
    tableEl = uifactory.addTableElement(getWindowControl(), "rules", model, getTranslator(), formLayout);
    tableEl.setCustomizeColumns(false);
    tableEl.setRendererType(FlexiTableRendererType.classic);
    FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add("buttons", buttonLayout);
    saveButton = uifactory.addFormSubmitButton("save", buttonLayout);
}
Also used : StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) ArrayList(java.util.ArrayList) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Rule(org.olat.admin.landingpages.model.Rule) Rules(org.olat.admin.landingpages.model.Rules) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Example 15 with DefaultFlexiColumnModel

use of org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel in project OpenOLAT by OpenOLAT.

the class UserSearchFlexiController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        // insert a autocompleter search
        Roles roles = ureq.getUserSession().getRoles();
        boolean autoCompleteAllowed = securityModule.isUserAllowedAutoComplete(roles);
        boolean ajax = Windows.getWindows(ureq).getWindowManager().isAjaxEnabled();
        if (ajax && autoCompleteAllowed) {
            // auto complete
            String velocityAutoCRoot = Util.getPackageVelocityRoot(FlexiAutoCompleterController.class);
            String autoCPage = velocityAutoCRoot + "/autocomplete.html";
            autoCompleterContainer = FormLayoutContainer.createCustomFormLayout("autocompletionsearch", getTranslator(), autoCPage);
            autoCompleterContainer.setRootForm(mainForm);
            layoutCont.add(autoCompleterContainer);
            layoutCont.add("autocompletionsearch", autoCompleterContainer);
            setupAutoCompleter(ureq, autoCompleterContainer, null, isAdministrativeUser, 60, 3, null);
        }
        // user search form
        backLink = uifactory.addFormLink("btn.back", formLayout);
        backLink.setIconLeftCSS("o_icon o_icon_back");
        searchFormContainer = FormLayoutContainer.createDefaultFormLayout("usersearchPanel", getTranslator());
        searchFormContainer.setRootForm(mainForm);
        searchFormContainer.setElementCssClass("o_sel_usersearch_searchform");
        searchFormContainer.setFormTitle(translate("header.normal"));
        layoutCont.add(searchFormContainer);
        layoutCont.add("usersearchPanel", searchFormContainer);
        loginEl = uifactory.addTextElement("login", "search.form.login", 128, "", searchFormContainer);
        loginEl.setVisible(isAdministrativeUser);
        propFormItems = new HashMap<>();
        for (UserPropertyHandler userPropertyHandler : userSearchFormPropertyHandlers) {
            if (userPropertyHandler == null)
                continue;
            FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, UserSearchForm.class.getCanonicalName(), false, searchFormContainer);
            // DO NOT validate email field => see OLAT-3324, OO-155, OO-222
            if (userPropertyHandler instanceof EmailProperty && fi instanceof TextElement) {
                TextElement textElement = (TextElement) fi;
                textElement.setItemValidatorProvider(null);
            }
            propFormItems.put(userPropertyHandler.getName(), fi);
        }
        FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
        buttonGroupLayout.setRootForm(mainForm);
        searchFormContainer.add(buttonGroupLayout);
        // Don't use submit button, form should not be marked as dirty since this is
        // not a configuration form but only a search form (OLAT-5626)
        searchButton = uifactory.addFormLink("submit.search", buttonGroupLayout, Link.BUTTON);
        layoutCont.contextPut("noList", "false");
        layoutCont.contextPut("showButton", "false");
        // add the table
        FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
        int colPos = 0;
        if (isAdministrativeUser) {
            tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.user.login", colPos++, true, "login"));
        }
        List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(usageIdentifyer, isAdministrativeUser);
        List<UserPropertyHandler> resultingPropertyHandlers = new ArrayList<>();
        // followed by the users fields
        for (int i = 0; i < userPropertyHandlers.size(); i++) {
            UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
            boolean visible = UserManager.getInstance().isMandatoryUserProperty(usageIdentifyer, userPropertyHandler);
            if (visible) {
                resultingPropertyHandlers.add(userPropertyHandler);
                tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos++, true, userPropertyHandler.getName()));
            }
        }
        tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("select", translate("select"), "select"));
        Translator myTrans = userManager.getPropertyHandlerTranslator(getTranslator());
        userTableModel = new UserSearchFlexiTableModel(Collections.<Identity>emptyList(), resultingPropertyHandlers, isAdministrativeUser, getLocale(), tableColumnModel);
        tableEl = uifactory.addTableElement(getWindowControl(), "users", userTableModel, 250, false, myTrans, formLayout);
        tableEl.setCustomizeColumns(false);
        tableEl.setMultiSelect(true);
        tableEl.setSelectAllEnable(true);
        layoutCont.put("userTable", tableEl.getComponent());
    }
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Roles(org.olat.core.id.Roles) EmailProperty(org.olat.user.propertyhandlers.EmailProperty) Translator(org.olat.core.gui.translator.Translator) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Aggregations

DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)272 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)254 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)126 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)74 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)72 BooleanCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer)72 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)64 ArrayList (java.util.ArrayList)44 SortKey (org.olat.core.commons.persistence.SortKey)44 FlexiTableSortOptions (org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions)40 FlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel)36 DateFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.DateFlexiCellRenderer)28 FlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiCellRenderer)26 FlexiTableFilter (org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)22 PassedCellRenderer (org.olat.course.assessment.bulk.PassedCellRenderer)20 CSSIconFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.CSSIconFlexiCellRenderer)18 ScoreCellRenderer (org.olat.modules.assessment.ui.ScoreCellRenderer)18 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)14 FlexiTableElement (org.olat.core.gui.components.form.flexible.elements.FlexiTableElement)12 Translator (org.olat.core.gui.translator.Translator)12