Search in sources :

Example 1 with CustomRenderColumnDescriptor

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

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)

Example 2 with CustomRenderColumnDescriptor

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

the class MediaFilesTableModel method addColumnDescriptors.

public void addColumnDescriptors(TableController tableCtr) {
    tableCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.filename", 0, WikiMainController.ACTION_SHOW_MEDIA, getLocale(), 1, new StrikeThroughCellRenderer()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.created.by", 1, null, getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.creation.date", 2, null, getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.deleted.by", 3, null, getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.deleted.at", 4, null, getLocale()));
}
Also used : CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 3 with CustomRenderColumnDescriptor

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

the class OrderDetailController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    backLink = uifactory.addFormLink("back", formLayout, Link.LINK_BACK);
    FormLayoutContainer mainLayout = FormLayoutContainer.createDefaultFormLayout("mainCmp", getTranslator());
    mainLayout.setRootForm(mainForm);
    formLayout.add("mainCmp", mainLayout);
    String orderNr = order.getOrderNr();
    uifactory.addStaticTextElement("order-nr", "order.nr", orderNr, mainLayout);
    Date creationDate = order.getCreationDate();
    String creationDateStr = Formatter.getInstance(getLocale()).formatDateAndTime(creationDate);
    uifactory.addStaticTextElement("creation-date", "order.creationDate", creationDateStr, mainLayout);
    String orderTotal = PriceFormat.fullFormat(order.getTotal());
    String orderTotalStr;
    if (acModule.isVatEnabled()) {
        BigDecimal vat = acModule.getVat();
        String vatStr = vat == null ? "" : vat.setScale(3, BigDecimal.ROUND_HALF_EVEN).toPlainString();
        orderTotalStr = translate("access.info.price.vat", new String[] { orderTotal, vatStr });
    } else {
        orderTotalStr = translate("access.info.price.noVat", new String[] { orderTotal });
    }
    uifactory.addStaticTextElement("order-total", "order.total", orderTotalStr, mainLayout);
    OrderItemsDataModel tableModel = getOrderItemsDataModel();
    if (tableModel.getRowCount() == 1) {
        OrderItemWrapper wrapper = tableModel.getObject(0);
        if (wrapper.getItem().getOffer().getResource() != null) {
            // resource is null if the resource has been deleted
            String linkName = StringHelper.escapeHtml(wrapper.getDisplayName());
            selectResourceLink = uifactory.addFormLink("resource", linkName, translate("order.item"), mainLayout, Link.NONTRANSLATED);
            selectResourceLink.setUserObject(wrapper);
            selectResourceLink.setCustomEnabledLinkCSS("form-control-static");
        }
    }
    User user = order.getDelivery().getUser();
    String delivery = StringHelper.escapeHtml(userManager.getUserDisplayName(user));
    uifactory.addStaticTextElement("delivery", "order.delivery", delivery, mainLayout);
    if (formLayout instanceof FormLayoutContainer) {
        TableGuiConfiguration tableConfig = new TableGuiConfiguration();
        tableConfig.setDownloadOffered(false);
        tableConfig.setTableEmptyMessage(translate("orders.empty"));
        tableCtr = new TableController(tableConfig, ureq, getWindowControl(), Collections.<ShortName>emptyList(), null, null, null, false, getTranslator());
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("order.item.name", 0, null, getLocale()));
        tableCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("order.part.payment", 1, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new AccessMethodRenderer(acModule)));
        tableCtr.addColumnDescriptor(new StaticColumnDescriptor(CMD_SELECT, "table.order.details", getTranslator().translate("order.details")));
        tableCtr.setTableDataModel(tableModel);
        listenTo(tableCtr);
        FormLayoutContainer layoutContainer = (FormLayoutContainer) formLayout;
        layoutContainer.put("orderItemList", tableCtr.getInitialComponent());
    }
}
Also used : CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) User(org.olat.core.id.User) TableController(org.olat.core.gui.components.table.TableController) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) ShortName(org.olat.core.gui.ShortName) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) Date(java.util.Date) BigDecimal(java.math.BigDecimal) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 4 with CustomRenderColumnDescriptor

use of org.olat.core.gui.components.table.CustomRenderColumnDescriptor 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 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 5 with CustomRenderColumnDescriptor

use of org.olat.core.gui.components.table.CustomRenderColumnDescriptor 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)

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