Search in sources :

Example 1 with ColumnDescriptor

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

the class GroupController method initGroupTable.

/**
 * Init GroupList-table-controller for non-waitinglist (participant-list,
 * owner-list).
 */
protected void initGroupTable(TableController tableController, UserRequest ureq, boolean enableTablePreferences, boolean enableUserSelection) {
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(usageIdentifyer, isAdministrativeUser);
    if (isAdministrativeUser) {
        // first the login name, but only if administrative user
        DefaultColumnDescriptor cd0 = new DefaultColumnDescriptor("table.user.login", 0, COMMAND_VCARD, ureq.getLocale());
        cd0.setIsPopUpWindowAction(true, "height=700, width=900, location=no, menubar=no, resizable=yes, status=no, scrollbars=yes, toolbar=no");
        tableController.addColumnDescriptor(cd0);
    }
    if (chatEnabled) {
        tableController.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.online", 1, COMMAND_IM, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new OnlineIconRenderer()));
    }
    int visibleColId = 0;
    // followed by the users fields
    for (int i = 0; i < userPropertyHandlers.size(); i++) {
        UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
        boolean visible = userManager.isMandatoryUserProperty(usageIdentifyer, userPropertyHandler);
        ColumnDescriptor cd = userPropertyHandler.getColumnDescriptor(i + 3, COMMAND_VCARD, ureq.getLocale());
        // make all user attributes clickable to open visiting card
        if (cd instanceof DefaultColumnDescriptor) {
            DefaultColumnDescriptor dcd = (DefaultColumnDescriptor) cd;
            dcd.setIsPopUpWindowAction(true, "height=700, width=900, location=no, menubar=no, resizable=yes, status=no, scrollbars=yes, toolbar=no");
        }
        tableController.addColumnDescriptor(visible, cd);
        if (visible) {
            visibleColId++;
        }
    }
    // in the end
    if (enableTablePreferences) {
        DefaultColumnDescriptor dcd = new DefaultColumnDescriptor("table.subject.addeddate", 2, COMMAND_VCARD, ureq.getLocale());
        dcd.setIsPopUpWindowAction(true, "height=700, width=900, location=no, menubar=no, resizable=yes, status=no, scrollbars=yes, toolbar=no");
        tableController.addColumnDescriptor(true, dcd);
        tableController.setSortColumn(++visibleColId, true);
    }
    if (enableUserSelection) {
        tableController.addColumnDescriptor(new StaticColumnDescriptor(COMMAND_SELECTUSER, "table.subject.action", myTrans.translate("action.general")));
    }
    if (mayModifyMembers) {
        tableController.addMultiSelectAction("action.remove", COMMAND_REMOVEUSER);
        tableController.setMultiSelect(true);
    }
}
Also used : CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) OnlineIconRenderer(org.olat.group.ui.main.OnlineIconRenderer) CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) ColumnDescriptor(org.olat.core.gui.components.table.ColumnDescriptor) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 2 with ColumnDescriptor

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

the class GroupChoiceForm method downloadResults.

private void downloadResults(UserRequest ureq) {
    int cdcnt = manageTableData.getColumnCount();
    int rcnt = manageTableData.getRowCount();
    StringBuilder sb = new StringBuilder();
    boolean isAdministrativeUser = securityModule.isUserAllowedAdminProps(ureq.getUserSession().getRoles());
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(USER_PROPS_ID, isAdministrativeUser);
    // additional informations
    sb.append(translate("cl.course.title")).append('\t').append(course.getCourseTitle());
    sb.append('\n');
    String listTitle = checklist.getTitle() == null ? "" : checklist.getTitle();
    sb.append(translate("cl.title")).append('\t').append(listTitle);
    sb.append('\n').append('\n');
    // header
    for (int c = 0; c < (cdcnt - 1); c++) {
        // skip last column (action)
        ColumnDescriptor cd = manageChecklistTable.getColumnDescriptor(c);
        String headerKey = cd.getHeaderKey();
        String headerVal = cd.translateHeaderKey() ? translate(headerKey) : headerKey;
        sb.append('\t').append(headerVal);
    }
    sb.append('\n');
    // checkpoint description
    if (isAdministrativeUser) {
        sb.append('\t');
    }
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null)
            continue;
        sb.append('\t');
    }
    for (Checkpoint checkpoint : checklist.getCheckpoints()) {
        sb.append('\t').append(checkpoint.getDescription());
    }
    sb.append('\n');
    // data
    for (int r = 0; r < rcnt; r++) {
        for (int c = 0; c < (cdcnt - 1); c++) {
            // skip last column (action)
            ColumnDescriptor cd = manageChecklistTable.getColumnDescriptor(c);
            StringOutput so = new StringOutput();
            cd.renderValue(so, r, null);
            String cellValue = so.toString();
            cellValue = StringHelper.stripLineBreaks(cellValue);
            sb.append('\t').append(cellValue);
        }
        sb.append('\n');
    }
    String res = sb.toString();
    String charset = UserManager.getInstance().getUserCharset(ureq.getIdentity());
    ExcelMediaResource emr = new ExcelMediaResource(res, charset);
    ureq.getDispatchResult().setResultingMediaResource(emr);
}
Also used : DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) ColumnDescriptor(org.olat.core.gui.components.table.ColumnDescriptor) StringOutput(org.olat.core.gui.render.StringOutput) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) ExcelMediaResource(org.olat.core.gui.media.ExcelMediaResource)

Example 3 with ColumnDescriptor

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

the class StatisticDisplayController method calculateNodeGraph.

private Graph calculateNodeGraph(UserRequest ureq, int rowId) {
    Object o = tableCtr_.getTableDataModel().getValueAt(rowId, 0);
    String selectionInfo = "";
    if (o instanceof Map) {
        Map map = (Map) o;
        CourseNode node = (CourseNode) map.get(StatisticResult.KEY_NODE);
        ThreadLocalUserActivityLogger.log(StatisticLoggingAction.VIEW_NODE_STATISTIC, getClass(), LoggingResourceable.wrap(node), LoggingResourceable.wrapNonOlatResource(StringResourceableType.statisticType, "", STATISTIC_TYPE_VIEW_NODE_STATISTIC));
        String shortTitle = StringHelper.escapeHtml((String) map.get(AssessmentHelper.KEY_TITLE_SHORT));
        selectionInfo = getTranslator().translate("statistic.chart.selectioninfo.node", new String[] { shortTitle });
    } else {
        ThreadLocalUserActivityLogger.log(StatisticLoggingAction.VIEW_TOTAL_OF_NODES_STATISTIC, getClass(), LoggingResourceable.wrapNonOlatResource(StringResourceableType.statisticType, "", STATISTIC_TYPE_VIEW_TOTAL_OF_NODES_STATISTIC));
        selectionInfo = getTranslator().translate("statistic.chart.selectioninfo.total");
    }
    String chartIntroStr = headerTranslator_.translate("statistic.chart.intro", new String[] { selectionInfo, getStatsSinceStr() });
    StringBuffer chd = new StringBuffer();
    List<Integer> values = new ArrayList<Integer>();
    int max = 10;
    int columnCnt = tableCtr_.getTableDataModel().getColumnCount();
    List<String> labelList = new LinkedList<String>();
    for (int column = 1; /*we ignore the node itself*/
    column < columnCnt - 1; /*we ignore the total*/
    column++) {
        Object cellValue = tableCtr_.getTableDataModel().getValueAt(rowId, column);
        Integer v = 0;
        if (cellValue instanceof Integer) {
            v = (Integer) cellValue;
        }
        max = Math.max(max, v);
        if (chd.length() != 0) {
            chd.append(",");
        }
        chd.append(v);
        values.add(v);
        ColumnDescriptor cd = tableCtr_.getColumnDescriptor(column);
        String headerKey = cd.getHeaderKey();
        if (cd.translateHeaderKey()) {
            headerKey = headerTranslator_.translate(headerKey);
        }
        labelList.add(headerKey);
    }
    Graph result = new Graph();
    result.values = values;
    result.labelList = labelList;
    result.chartIntroStr = chartIntroStr;
    result.numElements = columnCnt - 2;
    return result;
}
Also used : CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) ColumnDescriptor(org.olat.core.gui.components.table.ColumnDescriptor) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) CourseNode(org.olat.course.nodes.CourseNode) Map(java.util.Map)

Example 4 with ColumnDescriptor

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

the class StatisticDisplayController method calculateTotalGraph.

private Graph calculateTotalGraph(UserRequest ureq, int columnId) {
    ColumnDescriptor cd = tableCtr_.getColumnDescriptor(columnId);
    String headerKey = cd.getHeaderKey();
    if (cd.translateHeaderKey()) {
        headerKey = headerTranslator_.translate(headerKey);
    }
    String selectionInfo = headerKey;
    String chartIntroStr;
    if (columnId == tableCtr_.getTableDataModel().getColumnCount() - 1) {
        ThreadLocalUserActivityLogger.log(StatisticLoggingAction.VIEW_TOTAL_TOTAL_STATISTIC, getClass(), LoggingResourceable.wrapNonOlatResource(StringResourceableType.statisticType, "", STATISTIC_TYPE_VIEW_TOTAL_TOTAL_STATISTIC));
        chartIntroStr = headerTranslator_.translate("statistic.chart.pernode.total.intro", new String[] { getStatsSinceStr() });
    } else {
        ThreadLocalUserActivityLogger.log(StatisticLoggingAction.VIEW_TOTAL_BY_VALUE_STATISTIC, getClass(), LoggingResourceable.wrapNonOlatResource(StringResourceableType.statisticType, "", STATISTIC_TYPE_VIEW_TOTAL_BY_VALUE_STATISTIC), LoggingResourceable.wrapNonOlatResource(StringResourceableType.statisticColumn, "", selectionInfo));
        chartIntroStr = headerTranslator_.translate("statistic.chart.pernode.intro", new String[] { selectionInfo });
    }
    StringBuffer chd = new StringBuffer();
    int max = 10;
    List<String> labelList = new LinkedList<String>();
    for (int row = 0; row < tableCtr_.getTableDataModel().getRowCount() - 1; row++) {
        Object cellValue = tableCtr_.getTableDataModel().getValueAt(row, columnId);
        Integer v = 0;
        if (cellValue instanceof Integer) {
            v = (Integer) cellValue;
        }
        max = Math.max(max, v);
        if (chd.length() != 0) {
            chd.append(",");
        }
        chd.append(v);
        Map m = (Map) tableCtr_.getTableDataModel().getValueAt(row, 0);
        headerKey = "n/a";
        if (m != null) {
            headerKey = (String) m.get(AssessmentHelper.KEY_TITLE_SHORT);
        }
        labelList.add(headerKey);
    }
    Graph result = new Graph();
    result.labelList = labelList;
    result.chartIntroStr = chartIntroStr;
    result.numElements = tableCtr_.getTableDataModel().getRowCount() - 1;
    return result;
}
Also used : CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) ColumnDescriptor(org.olat.core.gui.components.table.ColumnDescriptor) Map(java.util.Map) LinkedList(java.util.LinkedList)

Example 5 with ColumnDescriptor

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

the class GroupController method initGroupTable.

/**
 * Init GroupList-table-controller for non-waitinglist (participant-list,
 * owner-list).
 */
protected void initGroupTable(TableController tableCtr, UserRequest ureq, boolean enableTablePreferences, boolean enableUserSelection) {
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(usageIdentifyer, isAdministrativeUser);
    if (isAdministrativeUser) {
        // first the login name, but only if administrative user
        DefaultColumnDescriptor cd0 = new DefaultColumnDescriptor("table.user.login", 0, COMMAND_VCARD, ureq.getLocale());
        cd0.setIsPopUpWindowAction(true, "height=700, width=900, location=no, menubar=no, resizable=yes, status=no, scrollbars=yes, toolbar=no");
        tableCtr.addColumnDescriptor(cd0);
    }
    if (chatEnabled) {
        tableCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.online", 1, COMMAND_IM, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new OnlineIconRenderer()));
    }
    int visibleColId = 0;
    // followed by the users fields
    for (int i = 0; i < userPropertyHandlers.size(); i++) {
        UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
        boolean visible = userManager.isMandatoryUserProperty(usageIdentifyer, userPropertyHandler);
        ColumnDescriptor cd = userPropertyHandler.getColumnDescriptor(i + 3, COMMAND_VCARD, ureq.getLocale());
        // make all user attributes clickable to open visiting card
        if (cd instanceof DefaultColumnDescriptor) {
            DefaultColumnDescriptor dcd = (DefaultColumnDescriptor) cd;
            dcd.setIsPopUpWindowAction(true, "height=700, width=900, location=no, menubar=no, resizable=yes, status=no, scrollbars=yes, toolbar=no");
        }
        tableCtr.addColumnDescriptor(visible, cd);
        if (visible) {
            visibleColId++;
        }
    }
    // in the end
    if (enableTablePreferences) {
        DefaultColumnDescriptor cd = new DefaultColumnDescriptor("table.subject.addeddate", 2, COMMAND_VCARD, ureq.getLocale());
        cd.setIsPopUpWindowAction(true, "height=700, width=900, location=no, menubar=no, resizable=yes, status=no, scrollbars=yes, toolbar=no");
        tableCtr.addColumnDescriptor(true, cd);
        tableCtr.setSortColumn(++visibleColId, true);
    }
    if (enableUserSelection) {
        tableCtr.addColumnDescriptor(new StaticColumnDescriptor(COMMAND_SELECTUSER, "table.subject.action", myTrans.translate("action.general")));
    }
    if (mayModifyMembers) {
        tableCtr.addMultiSelectAction("action.remove", COMMAND_REMOVEUSER);
        tableCtr.setMultiSelect(true);
    }
}
Also used : CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) OnlineIconRenderer(org.olat.group.ui.main.OnlineIconRenderer) CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) ColumnDescriptor(org.olat.core.gui.components.table.ColumnDescriptor) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Aggregations

ColumnDescriptor (org.olat.core.gui.components.table.ColumnDescriptor)14 CustomRenderColumnDescriptor (org.olat.core.gui.components.table.CustomRenderColumnDescriptor)12 DefaultColumnDescriptor (org.olat.core.gui.components.table.DefaultColumnDescriptor)10 StaticColumnDescriptor (org.olat.core.gui.components.table.StaticColumnDescriptor)8 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)8 OnlineIconRenderer (org.olat.group.ui.main.OnlineIconRenderer)6 LinkedList (java.util.LinkedList)4 Map (java.util.Map)4 StringOutput (org.olat.core.gui.render.StringOutput)4 ArrayList (java.util.ArrayList)2 Locale (java.util.Locale)2 CustomCellRenderer (org.olat.core.gui.components.table.CustomCellRenderer)2 DateCellRenderer (org.olat.core.gui.components.table.DateCellRenderer)2 ExcelMediaResource (org.olat.core.gui.media.ExcelMediaResource)2 Renderer (org.olat.core.gui.render.Renderer)2 CourseNode (org.olat.course.nodes.CourseNode)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 OLATResourceAccess (org.olat.resource.accesscontrol.model.OLATResourceAccess)2