Search in sources :

Example 31 with TableController

use of org.olat.core.gui.components.table.TableController in project OpenOLAT by OpenOLAT.

the class EPMultipleArtefactsAsTableController method initOrUpdateTable.

private void initOrUpdateTable(UserRequest ureq, List<AbstractArtefact> artefacts) {
    ArtefactTableDataModel artefactListModel = new ArtefactTableDataModel(artefacts);
    artefactListModel.setLocale(getLocale());
    TableGuiConfiguration tableGuiConfiguration = new TableGuiConfiguration();
    tableGuiConfiguration.setTableEmptyMessage(getTranslator().translate("table.empty"));
    tableGuiConfiguration.setPageingEnabled(true);
    // offer download only when in artefact pool (no struct given)
    tableGuiConfiguration.setDownloadOffered(struct == null);
    tableGuiConfiguration.setResultsPerPage(10);
    tableGuiConfiguration.setPreferencesOffered(true, "artefacts.as.table.prefs");
    artefactListTblCtrl = new TableController(tableGuiConfiguration, ureq, getWindowControl(), getTranslator());
    if (multiSelect) {
        artefactListTblCtrl.setMultiSelect(true);
        artefactListTblCtrl.addMultiSelectAction("select", "select");
    }
    listenTo(artefactListTblCtrl);
    String details = artefactChooseMode ? null : CMD_TITLE;
    DefaultColumnDescriptor descr = new DefaultColumnDescriptor("artefact.title", 0, details, getLocale());
    artefactListTblCtrl.addColumnDescriptor(descr);
    descr = new DefaultColumnDescriptor("artefact.description", 1, null, getLocale());
    descr.setEscapeHtml(EscapeMode.antisamy);
    artefactListTblCtrl.addColumnDescriptor(true, descr);
    descr = new DefaultColumnDescriptor("artefact.date", 2, null, getLocale());
    artefactListTblCtrl.addColumnDescriptor(true, descr);
    descr = new DefaultColumnDescriptor("artefact.author", 3, null, getLocale());
    artefactListTblCtrl.addColumnDescriptor(false, descr);
    descr = new DefaultColumnDescriptor("artefact.tags", 4, null, getLocale());
    artefactListTblCtrl.addColumnDescriptor(false, descr);
    descr = new CustomRenderColumnDescriptor("table.header.type", 5, null, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_CENTER, new ArtefactTypeImageCellRenderer(getLocale())) {

        /**
         * @see org.olat.core.gui.components.table.DefaultColumnDescriptor#compareTo(int, int)
         */
        @Override
        public int compareTo(int rowa, int rowb) {
            Object a = table.getTableDataModel().getValueAt(rowa, dataColumn);
            Object b = table.getTableDataModel().getValueAt(rowb, dataColumn);
            String typeA = getArtefactTranslatedTypeName((AbstractArtefact) a);
            String typeB = getArtefactTranslatedTypeName((AbstractArtefact) b);
            return typeA.compareTo(typeB);
        }
    };
    artefactListTblCtrl.addColumnDescriptor(false, descr);
    StaticColumnDescriptor staticDescr;
    if (!artefactChooseMode) {
        if (mapClosed || !secCallback.canEditReflexion()) {
            // change link-description in row, when map is closed or viewed by another person
            staticDescr = new StaticColumnDescriptor(CMD_REFLEXION, "table.header.reflexion", translate("table.header.view"));
        } else {
            staticDescr = new StaticColumnDescriptor(CMD_REFLEXION, "table.header.reflexion", translate("table.row.reflexion"));
        }
        artefactListTblCtrl.addColumnDescriptor(true, staticDescr);
    }
    if (struct == null) {
        staticDescr = new StaticColumnDescriptor(CMD_DELETEARTEFACT, "delete.artefact", translate("delete.artefact"));
        artefactListTblCtrl.addColumnDescriptor(true, staticDescr);
    }
    if (artefactChooseMode) {
        staticDescr = new StaticColumnDescriptor(CMD_CHOOSE, "table.header.choose", translate("choose.artefact"));
        artefactListTblCtrl.addColumnDescriptor(true, staticDescr);
    }
    if (struct != null && secCallback.canRemoveArtefactFromStruct()) {
        staticDescr = new StaticColumnDescriptor(CMD_UNLINK, "table.header.unlink", translate("remove.from.map"));
        artefactListTblCtrl.addColumnDescriptor(true, staticDescr);
    }
    if (struct != null && secCallback.canRemoveArtefactFromStruct() && secCallback.canAddArtefact()) {
        staticDescr = new StaticColumnDescriptor(CMD_MOVE, "table.header.move", translate("artefact.options.move"));
        artefactListTblCtrl.addColumnDescriptor(true, staticDescr);
    }
    artefactListTblCtrl.setTableDataModel(artefactListModel);
    if (vC.getComponent("artefactTable") != null)
        vC.remove(artefactListTblCtrl.getInitialComponent());
    vC.put("artefactTable", artefactListTblCtrl.getInitialComponent());
}
Also used : CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) TableController(org.olat.core.gui.components.table.TableController) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 32 with TableController

use of org.olat.core.gui.components.table.TableController in project OpenOLAT by OpenOLAT.

the class MembersPeekViewController method initForm.

private void initForm(UserRequest ureq) {
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setDisplayTableHeader(false);
    tableConfig.setCustomCssClass("o_portlet_table table-condensed");
    tableConfig.setDisplayRowCount(false);
    tableConfig.setPageingEnabled(false);
    tableConfig.setDownloadOffered(false);
    tableConfig.setSortingEnabled(false);
    removeAsListenerAndDispose(tableController);
    tableController = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    listenTo(tableController);
    tableController.addColumnDescriptor(new DefaultColumnDescriptor("members.type", 0, null, ureq.getLocale()));
    tableController.addColumnDescriptor(new DefaultColumnDescriptor("members.count", 1, null, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT));
    tableController.setTableDataModel(new DefaultTableDataModel<Row>(entries) {

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public Object getValueAt(int row, int col) {
            Row r = entries.get(row);
            if (col == 0) {
                return r.col1;
            }
            if (col == 1) {
                return r.col2;
            }
            return null;
        }
    });
    putInitialPanel(tableController.getInitialComponent());
}
Also used : TableController(org.olat.core.gui.components.table.TableController) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 33 with TableController

use of org.olat.core.gui.components.table.TableController in project OpenOLAT by OpenOLAT.

the class BusinessGroupMainRunController method doShowResources.

private void doShowResources(UserRequest ureq) {
    // always refresh data model, maybe it has changed
    RepositoryTableModel repoTableModel = new RepositoryTableModel(getLocale());
    List<RepositoryEntry> repoTableModelEntries = businessGroupService.findRepositoryEntries(Collections.singletonList(businessGroup), 0, -1);
    repoTableModel.setObjects(repoTableModelEntries);
    // init table controller only once
    if (resourcesCtr == null) {
        TableGuiConfiguration tableConfig = new TableGuiConfiguration();
        tableConfig.setTableEmptyMessage(translate("resources.noresources"));
        // removeAsListenerAndDispose(resourcesCtr);
        resourcesCtr = new TableController(tableConfig, ureq, getWindowControl(), resourceTrans);
        listenTo(resourcesCtr);
        resourcesVC = createVelocityContainer("resources");
        repoTableModel.addColumnDescriptors(resourcesCtr, true, false, false, false);
        resourcesVC.put("resources", resourcesCtr.getInitialComponent());
    }
    // add table model to table
    resourcesCtr.setTableDataModel(repoTableModel);
    mainPanel.setContent(resourcesVC);
    addToHistory(ureq, ORES_TOOLRESOURCES, null);
}
Also used : RepositoryTableModel(org.olat.repository.ui.RepositoryTableModel) TableController(org.olat.core.gui.components.table.TableController) RepositoryEntry(org.olat.repository.RepositoryEntry) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration)

Example 34 with TableController

use of org.olat.core.gui.components.table.TableController in project OpenOLAT by OpenOLAT.

the class DENManager method createRunDatesTable.

/**
 * Create the table for the run view
 * @param ureq
 * @param wControl
 * @param trans
 * @param listener
 * @param tableData DENRunTableDataModel
 * @return TableController
 */
protected TableController createRunDatesTable(UserRequest ureq, WindowControl wControl, Translator trans, DENRunTableDataModel tableData) {
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(trans.translate("dates.table.empty"));
    TableController tableCntrl = new TableController(tableConfig, ureq, wControl, trans);
    tableCntrl.addColumnDescriptor(new StrongColumnDescriptor("dates.table.date", 0, null, ureq.getLocale()));
    tableCntrl.addColumnDescriptor(new DefaultColumnDescriptor("dates.table.begin", 1, null, ureq.getLocale()));
    tableCntrl.addColumnDescriptor(new StrongColumnDescriptor("dates.table.location", 3, null, ureq.getLocale()));
    tableCntrl.addColumnDescriptor(new DefaultColumnDescriptor("dates.table.duration", 2, null, ureq.getLocale()));
    tableCntrl.addColumnDescriptor(new DefaultColumnDescriptor("dates.table.comment", 4, null, ureq.getLocale()));
    tableCntrl.addColumnDescriptor(new DefaultColumnDescriptor("dates.table.reserved", 5, null, ureq.getLocale()));
    tableCntrl.addColumnDescriptor(new DefaultColumnDescriptor("dates.table.status", 6, null, ureq.getLocale()));
    if (tableData.isEnrollmentEnabled()) {
        tableCntrl.addColumnDescriptor(new BooleanColumnDescriptor("dates.table.sign.in", 7, DENRunTableDataModel.CMD_ENROLL_IN_DATE, trans.translate("dates.table.sign.in"), trans.translate("dates.table.run.no_action")));
        tableCntrl.addColumnDescriptor(new BooleanColumnDescriptor("dates.table.sign.out", 8, DENRunTableDataModel.CMD_ENROLLED_CANCEL, trans.translate("dates.table.sign.out"), trans.translate("dates.table.run.no_action")));
    }
    tableCntrl.setTableDataModel(tableData);
    // timeframe
    tableCntrl.setSortColumn(1, true);
    return tableCntrl;
}
Also used : BooleanColumnDescriptor(org.olat.core.gui.components.table.BooleanColumnDescriptor) TableController(org.olat.core.gui.components.table.TableController) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 35 with TableController

use of org.olat.core.gui.components.table.TableController in project OpenOLAT by OpenOLAT.

the class DENManager method createManageDatesTable.

/**
 * Create the table for the manage dates view
 * @param ureq
 * @param wControl
 * @param trans
 * @param listener
 * @param tableData DENEditTableDataModel
 * @return TableController
 */
protected TableController createManageDatesTable(UserRequest ureq, WindowControl wControl, Translator trans, DENEditTableDataModel tableData) {
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setResultsPerPage(15);
    tableConfig.setShowAllLinkEnabled(true);
    TableController tableCntrl = new TableController(tableConfig, ureq, wControl, trans);
    tableCntrl.addColumnDescriptor(new StrongColumnDescriptor("dates.table.date", 0, null, ureq.getLocale()));
    tableCntrl.addColumnDescriptor(new DefaultColumnDescriptor("dates.table.begin", 1, null, ureq.getLocale()));
    tableCntrl.addColumnDescriptor(new StrongColumnDescriptor("dates.table.location", 3, null, ureq.getLocale()));
    tableCntrl.addColumnDescriptor(new DefaultColumnDescriptor("dates.table.duration", 2, null, ureq.getLocale()));
    tableCntrl.addColumnDescriptor(new DefaultColumnDescriptor("dates.table.comment", 4, null, ureq.getLocale()));
    tableCntrl.addColumnDescriptor(new DefaultColumnDescriptor("dates.table.participants.num", 5, null, ureq.getLocale()));
    tableCntrl.addMultiSelectAction("dates.table.edit.change", DENEditTableDataModel.CHANGE_ACTION);
    tableCntrl.addMultiSelectAction("dates.table.edit.delete", DENEditTableDataModel.DELETE_ACTION);
    tableCntrl.setMultiSelect(true);
    tableCntrl.setTableDataModel(tableData);
    // begin + multi select column
    tableCntrl.setSortColumn(2, true);
    return tableCntrl;
}
Also used : TableController(org.olat.core.gui.components.table.TableController) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Aggregations

TableController (org.olat.core.gui.components.table.TableController)66 TableGuiConfiguration (org.olat.core.gui.components.table.TableGuiConfiguration)60 DefaultColumnDescriptor (org.olat.core.gui.components.table.DefaultColumnDescriptor)38 StaticColumnDescriptor (org.olat.core.gui.components.table.StaticColumnDescriptor)16 CustomRenderColumnDescriptor (org.olat.core.gui.components.table.CustomRenderColumnDescriptor)12 BooleanColumnDescriptor (org.olat.core.gui.components.table.BooleanColumnDescriptor)10 Identity (org.olat.core.id.Identity)10 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 BaseSecurityModule (org.olat.basesecurity.BaseSecurityModule)6 Roles (org.olat.core.id.Roles)6 HashMap (java.util.HashMap)4 WindowControl (org.olat.core.gui.control.WindowControl)4 Translator (org.olat.core.gui.translator.Translator)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)4 RepositoryTableModel (org.olat.repository.ui.RepositoryTableModel)4 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)3 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)3