Search in sources :

Example 21 with CustomRenderColumnDescriptor

use of org.olat.core.gui.components.table.CustomRenderColumnDescriptor in project openolat by klemens.

the class GenericArchiveController method doNodeChoose.

/**
 * @param ureq
 */
private void doNodeChoose(UserRequest ureq, VelocityContainer nodeChoose) {
    // table configuraton
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("nodesoverview.nonodes"));
    tableConfig.setDownloadOffered(false);
    tableConfig.setSortingEnabled(false);
    tableConfig.setDisplayTableHeader(true);
    tableConfig.setDisplayRowCount(false);
    tableConfig.setPageingEnabled(false);
    removeAsListenerAndDispose(nodeListCtr);
    nodeListCtr = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    listenTo(nodeListCtr);
    // table columns
    nodeListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.node", 0, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new IndentedNodeRenderer()));
    nodeListCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.action.select", 1, CMD_SELECT_NODE, getLocale()));
    // get list of course node data and populate table data model
    ICourse course = CourseFactory.loadCourse(ores);
    CourseNode rootNode = course.getRunStructure().getRootNode();
    List<AssessmentNodeData> nodesTableObjectArrayList = addNodesAndParentsToList(0, rootNode);
    // only populate data model if data available
    if (nodesTableObjectArrayList == null) {
        nodeChoose.contextPut("hasNodes", Boolean.FALSE);
    } else {
        nodeChoose.contextPut("hasNodes", Boolean.TRUE);
        nodeTableModel = new NodeTableDataModel(nodesTableObjectArrayList, getTranslator());
        nodeListCtr.setTableDataModel(nodeTableModel);
        nodeChoose.put("nodeTable", nodeListCtr.getInitialComponent());
    }
    // set main content to nodechoose, do not use wrapper
    main.setContent(nodeChoose);
}
Also used : CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) TableController(org.olat.core.gui.components.table.TableController) ICourse(org.olat.course.ICourse) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) IndentedNodeRenderer(org.olat.course.assessment.IndentedNodeRenderer) CourseNode(org.olat.course.nodes.CourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor) AssessmentNodeData(org.olat.course.assessment.model.AssessmentNodeData)

Example 22 with CustomRenderColumnDescriptor

use of org.olat.core.gui.components.table.CustomRenderColumnDescriptor in project openolat by klemens.

the class StatisticDisplayController method createTableController.

private TableController createTableController(UserRequest ureq, StatisticResult result) {
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setDisplayTableHeader(true);
    tableConfig.setDisplayRowCount(true);
    tableConfig.setPageingEnabled(true);
    tableConfig.setDownloadOffered(true);
    tableConfig.setSortingEnabled(true);
    removeAsListenerAndDispose(tableController);
    tableController = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    listenTo(tableController);
    // tableCtr.addColumnDescriptor(statisticManager.createColumnDescriptor(ureq, 0, null));
    IndentedStatisticNodeRenderer indentedNodeRenderer = new IndentedStatisticNodeRenderer(Util.createPackageTranslator(statisticManager.getClass(), ureq.getLocale()));
    indentedNodeRenderer.setSimpleRenderingOnExport(true);
    CustomRenderColumnDescriptor nodeCD = new CustomRenderColumnDescriptor("stat.table.header.node", 0, CLICK_NODE_ACTION, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, indentedNodeRenderer) {

        @Override
        public int compareTo(int rowa, int rowb) {
            // order by original row order
            return new Integer(rowa).compareTo(rowb);
        }
    };
    tableController.addColumnDescriptor(nodeCD);
    int column = 1;
    List<String> headers = result.getHeaders();
    for (Iterator<String> it = headers.iterator(); it.hasNext(); ) {
        final String aHeader = it.next();
        final int aColumnId = column++;
        tableController.addColumnDescriptor(statisticManager.createColumnDescriptor(ureq, aColumnId, aHeader));
    }
    tableController.addColumnDescriptor(new CustomRenderColumnDescriptor("stat.table.header.total", column, StatisticDisplayController.CLICK_TOTAL_ACTION + column, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_RIGHT, new TotalColumnRenderer()) {

        @Override
        public String getAction(int row) {
            if (row == table.getTableDataModel().getRowCount() - 1) {
                return super.getAction(row);
            } else {
                return null;
            }
        }
    });
    tableController.setTableDataModel(result);
    return tableController;
}
Also used : CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) TableController(org.olat.core.gui.components.table.TableController) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration)

Aggregations

CustomRenderColumnDescriptor (org.olat.core.gui.components.table.CustomRenderColumnDescriptor)22 DefaultColumnDescriptor (org.olat.core.gui.components.table.DefaultColumnDescriptor)18 TableController (org.olat.core.gui.components.table.TableController)12 TableGuiConfiguration (org.olat.core.gui.components.table.TableGuiConfiguration)12 StaticColumnDescriptor (org.olat.core.gui.components.table.StaticColumnDescriptor)10 ColumnDescriptor (org.olat.core.gui.components.table.ColumnDescriptor)8 OnlineIconRenderer (org.olat.group.ui.main.OnlineIconRenderer)6 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)6 Renderer (org.olat.core.gui.render.Renderer)4 StringOutput (org.olat.core.gui.render.StringOutput)4 BigDecimal (java.math.BigDecimal)2 Date (java.util.Date)2 Locale (java.util.Locale)2 InfoMessage (org.olat.commons.info.InfoMessage)2 ShortName (org.olat.core.gui.ShortName)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 BooleanColumnDescriptor (org.olat.core.gui.components.table.BooleanColumnDescriptor)2 CustomCellRenderer (org.olat.core.gui.components.table.CustomCellRenderer)2 DateCellRenderer (org.olat.core.gui.components.table.DateCellRenderer)2 User (org.olat.core.id.User)2