Search in sources :

Example 41 with TableController

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

the class ReadyToDeleteController method initializeTableController.

private void initializeTableController(UserRequest ureq) {
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("error.no.user.found"));
    tableConfig.setShowAllLinkEnabled(false);
    removeAsListenerAndDispose(tableCtr);
    tableCtr = new TableController(tableConfig, ureq, getWindowControl(), this.propertyHandlerTranslator);
    listenTo(tableCtr);
    List<Identity> l = UserDeletionManager.getInstance().getIdentitiesInDeletionProcess(UserDeletionManager.getInstance().getDeleteEmailDuration());
    tdm = new UserDeleteTableModel(l, getLocale(), isAdministrativeUser);
    tdm.addColumnDescriptors(tableCtr, null, "table.identity.deleteEmail");
    tableCtr.addColumnDescriptor(new StaticColumnDescriptor(ACTION_SINGLESELECT_CHOOSE, "table.header.action", translate("action.activate")));
    tableCtr.addMultiSelectAction("action.ready.to.delete", ACTION_MULTISELECT_CHOOSE);
    tableCtr.setMultiSelect(true);
    tableCtr.setTableDataModel(tdm);
}
Also used : TableController(org.olat.core.gui.components.table.TableController) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) Identity(org.olat.core.id.Identity)

Example 42 with TableController

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

the class GroupController method init.

protected void init(UserRequest ureq, boolean mayModifyMembers, boolean enableTablePreferences, boolean enableUserSelection, boolean allowDownload) {
    setTranslator(Util.createPackageTranslator(org.olat.admin.securitygroup.gui.GroupController.class, getLocale(), getTranslator()));
    Roles roles = ureq.getUserSession().getRoles();
    BaseSecurityModule securityModule = CoreSpringFactory.getImpl(BaseSecurityModule.class);
    isAdministrativeUser = securityModule.isUserAllowedAdminProps(roles);
    chatEnabled = imModule.isEnabled() && imModule.isPrivateEnabled();
    // default group controller has no mail functionality
    this.addUserMailDefaultTempl = null;
    this.removeUserMailDefaultTempl = null;
    groupmemberview = createVelocityContainer("index");
    addUsersButton = LinkFactory.createButtonSmall("overview.addusers", groupmemberview, this);
    addUsersButton.setElementCssClass("o_sel_group_import_users");
    addUserButton = LinkFactory.createButtonSmall("overview.adduser", groupmemberview, this);
    addUserButton.setElementCssClass("o_sel_group_add_user");
    if (mayModifyMembers) {
        groupmemberview.contextPut("mayadduser", Boolean.TRUE);
    }
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setDownloadOffered(allowDownload);
    if (enableTablePreferences) {
        // save table preferences for each group seperatly
        if (mayModifyMembers) {
            tableConfig.setPreferencesOffered(true, "groupcontroller" + group.getKey());
        } else {
            // different rowcount...
            tableConfig.setPreferencesOffered(true, "groupcontrollerreadonly" + group.getKey());
        }
    }
    myTrans = userManager.getPropertyHandlerTranslator(getTranslator());
    tableCtr = new TableController(tableConfig, ureq, getWindowControl(), myTrans);
    listenTo(tableCtr);
    initGroupTable(tableCtr, ureq, enableTablePreferences, enableUserSelection);
    // set data model
    reloadData();
    groupmemberview.put("subjecttable", tableCtr.getInitialComponent());
    putInitialPanel(groupmemberview);
}
Also used : TableController(org.olat.core.gui.components.table.TableController) BaseSecurityModule(org.olat.basesecurity.BaseSecurityModule) Roles(org.olat.core.id.Roles) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration)

Example 43 with TableController

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

the class InfoPeekViewController method init.

private void init(UserRequest ureq) {
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("peekview.noInfos"));
    tableConfig.setDisplayTableHeader(false);
    tableConfig.setCustomCssClass("o_portlet_table");
    tableConfig.setDisplayRowCount(false);
    tableConfig.setPageingEnabled(false);
    tableConfig.setDownloadOffered(false);
    tableConfig.setSortingEnabled(false);
    removeAsListenerAndDispose(tableController);
    tableController = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    tableController.addColumnDescriptor(new CustomRenderColumnDescriptor("peekview.title", 0, null, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new InfoNodeRenderer()));
    String resSubPath = courseNode.getIdent();
    List<InfoMessage> infos = infoService.loadInfoMessageByResource(ores, resSubPath, null, null, null, 0, 5);
    InfosTableModel model = new InfosTableModel(infos);
    tableController.setTableDataModel(model);
    listenTo(tableController);
}
Also used : CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) InfoMessage(org.olat.commons.info.InfoMessage) TableController(org.olat.core.gui.components.table.TableController) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration)

Example 44 with TableController

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

the class ProjectListController method createTableController.

private TableController createTableController(final UserRequest ureq, WindowControl wControl) {
    numberOfCustomFieldInTable = 0;
    numberOfEventInTable = 0;
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("projectlist.no.projects"));
    tableConfig.setPreferencesOffered(true, "projectbrokerList");
    // Do not allow show all because many entries takes too long to render
    tableConfig.setShowAllLinkEnabled(false);
    removeAsListenerAndDispose(tableController);
    tableController = new TableController(tableConfig, ureq, wControl, this.getTranslator(), true);
    listenTo(tableController);
    int dataColumn = 0;
    tableController.addColumnDescriptor(new DefaultColumnDescriptor("projectlist.tableheader.title", dataColumn++, TABLE_ACTION_SHOW_DETAIL, getLocale()));
    CustomRenderColumnDescriptor projectManagerDescriptor = new CustomRenderColumnDescriptor("projectlist.tableheader.account.manager", dataColumn++, TABLE_ACTION_ACCOUNT_MANAGER, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new ProjectManagerColumnRenderer()) {

        /**
         * @see org.olat.core.gui.components.table.DefaultColumnDescriptor#compareTo(int, int)
         */
        @Override
        public int compareTo(int rowa, int rowb) {
            return super.compareTo(rowa, rowb);
        }

        /**
         * @see org.olat.core.gui.components.table.CustomRenderColumnDescriptor#renderValue(org.olat.core.gui.render.StringOutput, int, org.olat.core.gui.render.Renderer)
         */
        @Override
        public void renderValue(StringOutput sb, int row, Renderer renderer) {
            Object val = getModelData(row);
            // to get info about row in Renderer!
            String rowSt = Integer.toString(row);
            getCustomCellRenderer().render(sb, renderer, val, getLocale(), getAlignment(), rowSt);
        }
    };
    tableController.addColumnDescriptor(projectManagerDescriptor);
    // Custom-Fields
    List<CustomField> customFieldList = moduleConfig.getCustomFields();
    for (Iterator<CustomField> iterator = customFieldList.iterator(); iterator.hasNext(); ) {
        CustomField customField = iterator.next();
        if (customField.isTableViewEnabled()) {
            numberOfCustomFieldInTable++;
            DefaultColumnDescriptor columnDescriptor = new DefaultColumnDescriptor(customField.getName(), dataColumn++, null, getLocale());
            columnDescriptor.setTranslateHeaderKey(false);
            tableController.addColumnDescriptor(columnDescriptor);
        }
    }
    // Project Events
    for (Project.EventType eventType : Project.EventType.values()) {
        if (moduleConfig.isProjectEventEnabled(eventType) && moduleConfig.isProjectEventTableViewEnabled(eventType)) {
            numberOfEventInTable++;
            tableController.addColumnDescriptor(new CustomRenderColumnDescriptor("projectlist.tableheader.event." + eventType.getI18nKey(), dataColumn++, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new ProjectEventColumnRenderer()));
        }
    }
    tableController.addColumnDescriptor(new CustomRenderColumnDescriptor("projectlist.tableheader.state", dataColumn++, null, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new ProjectStateColumnRenderer()));
    tableController.addColumnDescriptor(new DefaultColumnDescriptor("projectlist.tableheader.numbers", dataColumn++, null, getLocale()) {

        @Override
        public int compareTo(int rowa, int rowb) {
            Object a = table.getTableDataModel().getValueAt(rowa, dataColumn);
            Object b = table.getTableDataModel().getValueAt(rowb, dataColumn);
            if (a == null || b == null) {
                boolean bb = (b == null);
                return (a == null) ? (bb ? 0 : -1) : (bb ? 1 : 0);
            }
            try {
                Long la = new Long((String) a);
                Long lb = new Long((String) b);
                return la.compareTo(lb);
            } catch (NumberFormatException e) {
                return super.compareTo(rowa, rowb);
            }
        }
    });
    String selectCmd = userCourseEnv.isCourseReadOnly() ? null : TABLE_ACTION_SELECT;
    tableController.addColumnDescriptor(new BooleanColumnDescriptor("projectlist.tableheader.select", dataColumn++, selectCmd, translate("table.action.select"), "-"));
    String cancelCmd = userCourseEnv.isCourseReadOnly() ? null : TABLE_ACTION_CANCEL_SELECT;
    tableController.addColumnDescriptor(new BooleanColumnDescriptor("projectlist.tableheader.cancel.select", dataColumn++, cancelCmd, translate("projectlist.tableheader.cancel.select"), "-"));
    return tableController;
}
Also used : CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) TableController(org.olat.core.gui.components.table.TableController) StringOutput(org.olat.core.gui.render.StringOutput) BooleanColumnDescriptor(org.olat.core.gui.components.table.BooleanColumnDescriptor) Project(org.olat.course.nodes.projectbroker.datamodel.Project) Renderer(org.olat.core.gui.render.Renderer) CustomField(org.olat.course.nodes.projectbroker.datamodel.CustomField) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 45 with TableController

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

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)

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