Search in sources :

Example 26 with FlexiCellRenderer

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

the class CourseSiteAdminController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("admin.menu.title");
    enableToolbar = uifactory.addCheckboxesHorizontal("site.enable.toolbar", "site.enable.toolbar", formLayout, new String[] { "x" }, new String[] { "" });
    enableToolbar.addActionListener(FormEvent.ONCHANGE);
    if (siteConfiguration.isToolbar()) {
        enableToolbar.select("x", true);
    }
    String cssClass = siteConfiguration.getNavIconCssClass();
    iconCssClassEl = uifactory.addTextElement("site.iconCssClass", "site.icon", 32, cssClass, formLayout);
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CSCols.defLanguage.i18nKey(), CSCols.defLanguage.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CSCols.language.i18nKey(), CSCols.language.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CSCols.title.i18nKey(), CSCols.title.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, CSCols.courseId.i18nKey(), CSCols.courseId.ordinal(), false, null));
    FlexiCellRenderer renderer = new StaticFlexiCellRenderer("openre", new TextFlexiCellRenderer());
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CSCols.courseTitle.i18nKey(), CSCols.courseTitle.ordinal(), "openre", renderer));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("select", translate("select"), "select"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("remove", translate("remove"), "remove"));
    String page = velocity_root + "/lang_options.html";
    tableLayout = FormLayoutContainer.createCustomFormLayout("site.options.lang", getTranslator(), page);
    tableLayout.setRootForm(mainForm);
    tableLayout.setLabel("site.courses", null);
    formLayout.add(tableLayout);
    model = new CourseSiteDataModel(columnsModel);
    List<LanguageConfigurationRow> configs = new ArrayList<LanguageConfigurationRow>();
    Map<String, LanguageConfiguration> langToConfigMap = new HashMap<String, LanguageConfiguration>();
    if (siteConfiguration.getConfigurations() != null) {
        for (LanguageConfiguration langConfig : siteConfiguration.getConfigurations()) {
            langToConfigMap.put(langConfig.getLanguage(), langConfig);
        }
    }
    for (String langKey : i18nModule.getEnabledLanguageKeys()) {
        if (langToConfigMap.containsKey(langKey)) {
            LanguageConfiguration langConfig = langToConfigMap.get(langKey);
            RepositoryEntry re = repositoryManager.lookupRepositoryEntryBySoftkey(langConfig.getRepoSoftKey(), false);
            configs.add(new LanguageConfigurationRow(langConfig, re, tableLayout));
        } else {
            configs.add(new LanguageConfigurationRow(new LanguageConfiguration(langKey), null, tableLayout));
        }
    }
    model.setObjects(configs);
    tableEl = uifactory.addTableElement(getWindowControl(), "languageTable", model, getTranslator(), tableLayout);
    tableEl.setRendererType(FlexiTableRendererType.classic);
    tableEl.setCustomizeColumns(true);
    tableEl.setAndLoadPersistedPreferences(ureq, "course-site-admin");
    FormLayoutContainer buttonsLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsLayout);
    okButton = uifactory.addFormLink("save", "save", null, buttonsLayout, Link.BUTTON);
    okButton.setCustomEnabledLinkCSS("btn btn-primary");
// uifactory.addFormSubmitButton("save", "save", formLayout);
}
Also used : StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) FlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiCellRenderer) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) RepositoryEntry(org.olat.repository.RepositoryEntry) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) LanguageConfiguration(org.olat.course.site.model.LanguageConfiguration) 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)26 FlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiCellRenderer)26 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)24 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)22 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)20 BooleanCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer)10 SortKey (org.olat.core.commons.persistence.SortKey)6 ArrayList (java.util.ArrayList)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 DateFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.DateFlexiCellRenderer)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)4 HashMap (java.util.HashMap)2 LicenseRenderer (org.olat.core.commons.services.license.ui.LicenseRenderer)2 TaskStatusRenderer (org.olat.core.commons.services.taskexecutor.ui.TaskStatusRenderer)2 FlexiTableFilter (org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)2 FlexiTableSortOptions (org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions)2 FlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel)2 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)2 LanguageConfiguration (org.olat.course.site.model.LanguageConfiguration)2