Search in sources :

Example 26 with DefaultColumnDescriptor

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

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 27 with DefaultColumnDescriptor

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

the class ENRunController method createTableController.

private TableController createTableController(UserRequest ureq, boolean hasAnyWaitingList) {
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("grouplist.no.groups"));
    removeAsListenerAndDispose(tableCtr);
    tableCtr = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    listenTo(tableCtr);
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("grouplist.table.name", 0, CMD_VISIT_CARD, getLocale()));
    DefaultColumnDescriptor descCd = new DefaultColumnDescriptor("grouplist.table.desc", 1, null, getLocale());
    descCd.setEscapeHtml(EscapeMode.antisamy);
    tableCtr.addColumnDescriptor(descCd);
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("grouplist.table.partipiciant", 2, 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 {
                Integer la, lb;
                if (a instanceof String) {
                    String sa = (String) a;
                    la = Integer.parseInt(sa.substring(0, sa.indexOf("/")));
                } else {
                    la = (Integer) a;
                }
                if (b instanceof String) {
                    String sb = (String) b;
                    lb = Integer.parseInt(sb.substring(0, sb.indexOf("/")));
                } else {
                    lb = (Integer) b;
                }
                return la.compareTo(lb);
            } catch (NumberFormatException e) {
                return super.compareTo(rowa, rowb);
            }
        }
    });
    tableCtr.addColumnDescriptor(hasAnyWaitingList, new DefaultColumnDescriptor("grouplist.table.waitingList", 3, null, getLocale()));
    DefaultColumnDescriptor stateColdEsc = new DefaultColumnDescriptor("grouplist.table.state", 4, null, getLocale());
    stateColdEsc.setEscapeHtml(EscapeMode.none);
    tableCtr.addColumnDescriptor(stateColdEsc);
    String enrollCmd = userCourseEnv.isCourseReadOnly() ? null : CMD_ENROLL_IN_GROUP;
    BooleanColumnDescriptor columnDesc = new BooleanColumnDescriptor("grouplist.table.enroll", 5, enrollCmd, translate(CMD_ENROLL_IN_GROUP), translate("grouplist.table.no_action"));
    columnDesc.setSortingAllowed(false);
    tableCtr.addColumnDescriptor(columnDesc);
    String cancelCmd = userCourseEnv.isCourseReadOnly() ? null : CMD_ENROLLED_CANCEL;
    tableCtr.addColumnDescriptor(new BooleanColumnDescriptor("grouplist.table.cancel_enroll", 6, cancelCmd, translate(CMD_ENROLLED_CANCEL), translate("grouplist.table.no_action")));
    return tableCtr;
}
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 28 with DefaultColumnDescriptor

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

the class HomeOrgStatisticManager method createColumnDescriptor.

@Override
public ColumnDescriptor createColumnDescriptor(UserRequest ureq, int column, String headerId) {
    if (column == 0) {
        return new DefaultColumnDescriptor("stat.table.header.node", 0, null, ureq.getLocale());
    }
    /*		if (headerId!=null) {
			Translator translator = Util.createPackageTranslator(ShibbolethModule.class, ureq.getLocale());
			if (translator!=null) {
				String newHeaderId = translator.translate("swissEduPersonHomeOrganization."+headerId);
				if (newHeaderId!=null && !newHeaderId.startsWith(Translator.NO_TRANSLATION_ERROR_PREFIX)) {
					headerId = newHeaderId;
				}
			}
		}*/
    TotalAwareColumnDescriptor cd = new TotalAwareColumnDescriptor(headerId, column, StatisticDisplayController.CLICK_TOTAL_ACTION + column, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_RIGHT);
    cd.setTranslateHeaderKey(false);
    return cd;
}
Also used : TotalAwareColumnDescriptor(org.olat.course.statistic.TotalAwareColumnDescriptor) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 29 with DefaultColumnDescriptor

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

the class OrgTypeStatisticManager method createColumnDescriptor.

@Override
public ColumnDescriptor createColumnDescriptor(UserRequest ureq, int column, String headerId) {
    if (column == 0) {
        return new DefaultColumnDescriptor("stat.table.header.node", 0, null, ureq.getLocale());
    }
    if (headerId != null) {
        Translator translator = Util.createPackageTranslator(ShibbolethModule.class, ureq.getLocale());
        if (translator != null) {
            String newHeaderId = translator.translate("swissEduPersonHomeOrganizationType." + headerId);
            if (newHeaderId != null && !newHeaderId.startsWith(Translator.NO_TRANSLATION_ERROR_PREFIX)) {
                headerId = newHeaderId;
            }
        }
    }
    TotalAwareColumnDescriptor cd = new TotalAwareColumnDescriptor(headerId, column, StatisticDisplayController.CLICK_TOTAL_ACTION + column, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_RIGHT);
    cd.setTranslateHeaderKey(false);
    return cd;
}
Also used : Translator(org.olat.core.gui.translator.Translator) TotalAwareColumnDescriptor(org.olat.course.statistic.TotalAwareColumnDescriptor) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 30 with DefaultColumnDescriptor

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

the class StudyLevelStatisticManager method createColumnDescriptor.

@Override
public ColumnDescriptor createColumnDescriptor(UserRequest ureq, int column, String headerId) {
    if (column == 0) {
        return new DefaultColumnDescriptor("stat.table.header.node", 0, null, ureq.getLocale());
    }
    if (headerId != null) {
        Translator translator = Util.createPackageTranslator(ShibbolethModule.class, ureq.getLocale());
        if (translator != null) {
            String newHeaderId = translator.translate("swissEduPersonStudyLevel." + headerId);
            if (newHeaderId != null && !newHeaderId.startsWith(Translator.NO_TRANSLATION_ERROR_PREFIX)) {
                headerId = newHeaderId;
            }
        }
    }
    TotalAwareColumnDescriptor cd = new TotalAwareColumnDescriptor(headerId, column, StatisticDisplayController.CLICK_TOTAL_ACTION + column, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_RIGHT);
    cd.setTranslateHeaderKey(false);
    return cd;
}
Also used : Translator(org.olat.core.gui.translator.Translator) TotalAwareColumnDescriptor(org.olat.course.statistic.TotalAwareColumnDescriptor) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Aggregations

DefaultColumnDescriptor (org.olat.core.gui.components.table.DefaultColumnDescriptor)68 TableController (org.olat.core.gui.components.table.TableController)38 TableGuiConfiguration (org.olat.core.gui.components.table.TableGuiConfiguration)38 CustomRenderColumnDescriptor (org.olat.core.gui.components.table.CustomRenderColumnDescriptor)18 StaticColumnDescriptor (org.olat.core.gui.components.table.StaticColumnDescriptor)18 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)13 BooleanColumnDescriptor (org.olat.core.gui.components.table.BooleanColumnDescriptor)10 TotalAwareColumnDescriptor (org.olat.course.statistic.TotalAwareColumnDescriptor)10 Date (java.util.Date)8 ColumnDescriptor (org.olat.core.gui.components.table.ColumnDescriptor)8 Translator (org.olat.core.gui.translator.Translator)6 OnlineIconRenderer (org.olat.group.ui.main.OnlineIconRenderer)6 ArrayList (java.util.ArrayList)4 Locale (java.util.Locale)4 Renderer (org.olat.core.gui.render.Renderer)4 StringOutput (org.olat.core.gui.render.StringOutput)4 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)4 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)4 BigDecimal (java.math.BigDecimal)2 DateFormat (java.text.DateFormat)2