Search in sources :

Example 21 with Formatter

use of org.olat.core.util.Formatter in project OpenOLAT by OpenOLAT.

the class EPChangelogController method getItemBundlesForSubscriptionItems.

/**
 * @param subscriptionItems
 * @return
 */
private List<SubscriptionItemBundle> getItemBundlesForSubscriptionItems(List<SubscriptionListItem> subscriptionItems) {
    List<SubscriptionItemBundle> bundles = new ArrayList<EPChangelogController.SubscriptionItemBundle>();
    Formatter f = Formatter.getInstance(getTranslator().getLocale());
    for (int i = 0; i < subscriptionItems.size(); i++) {
        SubscriptionListItem listItem = subscriptionItems.get(i);
        SubscriptionItemBundle bundle = new SubscriptionItemBundle();
        bundle.setDateString(f.formatDate(listItem.getDate()));
        String linkName = "subscrIL_" + i;
        bundle.setLinkName(linkName);
        String text = listItem.getDescription();
        FormLink link = uifactory.addFormLink(linkName, text, null, flc, Link.NONTRANSLATED);
        link.setUserObject(listItem.getUserObject());
        bundle.setCssClass(listItem.getIconCssClass());
        bundles.add(bundle);
    }
    return bundles;
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) Formatter(org.olat.core.util.Formatter) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 22 with Formatter

use of org.olat.core.util.Formatter in project openolat by klemens.

the class SubscriptionListItem method getHTMLContent.

private String getHTMLContent(Locale locale) {
    StringBuilder sb = new StringBuilder();
    Translator trans = Util.createPackageTranslator(ContextualSubscriptionController.class, locale);
    Formatter form = Formatter.getInstance(locale);
    String datePart = trans.translate("subscription.listitem.dateprefix", new String[] { form.formatDateAndTime(date) });
    sb.append("<li>");
    if (iconCssClass != null) {
        sb.append("<i class=\"o_icon o_icon-fw ");
        sb.append(iconCssClass);
        sb.append("\"></i>");
    }
    if (StringHelper.containsNonWhitespace(link)) {
        sb.append("<a href=\"");
        sb.append(link);
        sb.append("\">");
    }
    if (StringHelper.containsNonWhitespace(description)) {
        sb.append(new OWASPAntiSamyXSSFilter().filter(description.trim()));
    }
    if (StringHelper.containsNonWhitespace(link))
        sb.append("</a>");
    sb.append(" <span class='o_nowrap o_date'>").append(datePart.trim()).append("</span>");
    sb.append("</li>");
    return sb.toString();
}
Also used : OWASPAntiSamyXSSFilter(org.olat.core.util.filter.impl.OWASPAntiSamyXSSFilter) Translator(org.olat.core.gui.translator.Translator) Formatter(org.olat.core.util.Formatter)

Example 23 with Formatter

use of org.olat.core.util.Formatter in project openolat by klemens.

the class SubscriptionListItem method getPlaintextContent.

private String getPlaintextContent(Locale locale) {
    Translator trans = Util.createPackageTranslator(ContextualSubscriptionController.class, locale);
    Formatter form = Formatter.getInstance(locale);
    StringBuilder sb = new StringBuilder();
    String datePart = trans.translate("subscription.listitem.dateprefix", new String[] { form.formatDateAndTime(date) });
    sb.append("- ");
    sb.append(description.trim());
    sb.append(" ").append(datePart.trim());
    if (StringHelper.containsNonWhitespace(link))
        sb.append("\n").append("  ").append(link);
    return sb.toString();
}
Also used : Translator(org.olat.core.gui.translator.Translator) Formatter(org.olat.core.util.Formatter)

Example 24 with Formatter

use of org.olat.core.util.Formatter in project openolat by klemens.

the class PortfolioResultDetailsController method initMapsForm.

protected void initMapsForm(FormItemContainer formLayout) {
    Formatter formatter = Formatter.getInstance(getLocale());
    int count = 0;
    for (PortfolioStructureMap map : maps) {
        MapElements mapElements = new MapElements();
        if (map instanceof EPStructuredMap) {
            EPStructuredMap structuredMap = (EPStructuredMap) map;
            if (maps.size() > 1 || !structuredMap.getStructuredMapSource().equals(templateMap)) {
                String templateTitle = structuredMap.getStructuredMapSource().getTitle();
                uifactory.addStaticTextElement("map.template." + count, "map.template", templateTitle, formLayout);
            }
            String copyDate = "";
            if (structuredMap.getCopyDate() != null) {
                copyDate = formatter.formatDateAndTime(structuredMap.getCopyDate());
            }
            uifactory.addStaticTextElement("map.copyDate." + count, "map.copyDate", copyDate, formLayout);
            String returnDate = "";
            if (structuredMap.getReturnDate() != null) {
                returnDate = formatter.formatDateAndTime(structuredMap.getReturnDate());
            }
            uifactory.addStaticTextElement("map.returnDate." + count, "map.returnDate", returnDate, formLayout);
            String deadLine = "";
            if (structuredMap.getDeadLine() != null) {
                deadLine = formatter.formatDateAndTime(structuredMap.getDeadLine());
            }
            mapElements.deadlineEl = uifactory.addStaticTextElement("map.deadline." + count, "map.deadline", deadLine, formLayout);
        }
        FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons." + count, getTranslator());
        buttonsCont.setRootForm(mainForm);
        formLayout.add(buttonsCont);
        if (map instanceof EPStructuredMap) {
            mapElements.changeDeadlineLink = uifactory.addFormLink("map.deadline.change." + count, "map.deadline.change", null, buttonsCont, Link.BUTTON);
            mapElements.changeDeadlineLink.setUserObject(map);
        }
        mapElements.openMapLink = uifactory.addFormLink("open.map." + count, "open.map", null, buttonsCont, Link.BUTTON);
        mapElements.openMapLink.setUserObject(map);
        count++;
        if (count != maps.size()) {
            uifactory.addSpacerElement("spacer-" + count, formLayout, false);
        }
        mapToElements.put(map, mapElements);
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) Formatter(org.olat.core.util.Formatter) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 25 with Formatter

use of org.olat.core.util.Formatter in project openolat by klemens.

the class PortfolioResultDetailsController method initBindersForm.

protected void initBindersForm(FormItemContainer formLayout) {
    Formatter formatter = Formatter.getInstance(getLocale());
    int count = 0;
    for (Binder binder : binders) {
        MapElements mapElements = new MapElements();
        if (binders.size() > 1 || !binder.getTemplate().equals(templateBinder)) {
            String templateTitle = binder.getTemplate().getTitle();
            uifactory.addStaticTextElement("map.template." + count, "map.template", templateTitle, formLayout);
        }
        String copyDate = "";
        if (binder.getCopyDate() != null) {
            copyDate = formatter.formatDateAndTime(binder.getCopyDate());
        }
        uifactory.addStaticTextElement("map.copyDate." + count, "map.copyDate", copyDate, formLayout);
        String returnDate = "";
        if (binder.getReturnDate() != null) {
            returnDate = formatter.formatDateAndTime(binder.getReturnDate());
        }
        uifactory.addStaticTextElement("map.returnDate." + count, "map.returnDate", returnDate, formLayout);
        FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons." + count, getTranslator());
        buttonsCont.setRootForm(mainForm);
        formLayout.add(buttonsCont);
        mapElements.openMapLink = uifactory.addFormLink("open.binder." + count, "open.binder", "open.map", null, buttonsCont, Link.BUTTON);
        mapElements.openMapLink.setUserObject(binder);
        count++;
        if (count != binders.size()) {
            uifactory.addSpacerElement("spacer-" + count, formLayout, false);
        }
        binderToElements.put(binder, mapElements);
    }
}
Also used : Binder(org.olat.modules.portfolio.Binder) Formatter(org.olat.core.util.Formatter) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Aggregations

Formatter (org.olat.core.util.Formatter)80 Date (java.util.Date)30 ArrayList (java.util.ArrayList)12 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)12 IOException (java.io.IOException)6 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)6 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)6 Identity (org.olat.core.id.Identity)6 Translator (org.olat.core.gui.translator.Translator)5 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)5 File (java.io.File)4 Calendar (java.util.Calendar)4 HashMap (java.util.HashMap)4 COSVisitorException (org.apache.pdfbox.exceptions.COSVisitorException)4 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)4 OWASPAntiSamyXSSFilter (org.olat.core.util.filter.impl.OWASPAntiSamyXSSFilter)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 VelocityContext (org.apache.velocity.VelocityContext)2 Context (org.apache.velocity.context.Context)2