Search in sources :

Example 26 with Formatter

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

the class HistoryController method updateChangeLog.

protected void updateChangeLog() {
    Date date = dateChooser.getDate();
    List<SubscriptionListItem> items = notificationsHandler.getAllItems(binder, secCallback, date, getLocale());
    Formatter formatter = Formatter.getInstance(getLocale());
    List<SubscriptionListItemWrapper> wrappers = new ArrayList<>(items.size());
    for (SubscriptionListItem item : items) {
        String dateString = formatter.formatDate(item.getDate());
        String linkName = "subscrIL_" + (counter++);
        String linkLabel = StringHelper.escapeHtml(item.getDescription());
        FormLink link = uifactory.addFormLink(linkName, linkLabel, null, flc, Link.NONTRANSLATED);
        link.setUserObject(item.getBusinessPath());
        SubscriptionListItemWrapper bundle = new SubscriptionListItemWrapper(linkName, dateString, item.getIconCssClass());
        wrappers.add(bundle);
    }
    flc.contextPut("subscriptionItems", wrappers);
}
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) Date(java.util.Date)

Example 27 with Formatter

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

the class PaypalTransactionDetailsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    Formatter format = Formatter.getInstance(getLocale());
    String ack = transaction.getAck();
    uifactory.addStaticTextElement("ack", "paypal.transaction.ack", ack, formLayout);
    String execStatus = transaction.getPaymentExecStatus();
    uifactory.addStaticTextElement("exec.status", "paypal.transaction.exec.status", execStatus, formLayout);
    Date respDate = transaction.getPayResponseDate();
    String respDateStr = format.formatDateAndTime(respDate);
    uifactory.addStaticTextElement("resp.date", "paypal.transaction.response.date", respDateStr, formLayout);
    Price securePrice = transaction.getSecurePrice();
    String securePriceStr = PriceFormat.fullFormat(securePrice);
    uifactory.addStaticTextElement("amount", "paypal.transaction.amount", securePriceStr, formLayout);
    uifactory.addSpacerElement("ipn-spacer", formLayout, false);
    String transactionId = transaction.getTransactionId();
    uifactory.addStaticTextElement("trx-id", "paypal.transaction.id", removeNull(transactionId), formLayout);
    String trxStatus = transaction.getTransactionStatus();
    uifactory.addStaticTextElement("trx-status", "paypal.transaction.status", removeNull(trxStatus), formLayout);
    String senderTransactionId = transaction.getSenderTransactionId();
    uifactory.addStaticTextElement("trx-sender-id", "paypal.transaction.sender.id", removeNull(senderTransactionId), formLayout);
    String senderTrxStatus = transaction.getSenderTransactionStatus();
    uifactory.addStaticTextElement("trx-sender-status", "paypal.transaction.sender.status", removeNull(senderTrxStatus), formLayout);
    String pendingReason = transaction.getPendingReason();
    uifactory.addStaticTextElement("trx-pending-reason", "paypal.transaction.pending.reason", removeNull(pendingReason), formLayout);
    String senderEmail = transaction.getSenderEmail();
    uifactory.addStaticTextElement("trx-sender", "paypal.transaction.sender", removeNull(senderEmail), formLayout);
}
Also used : Price(org.olat.resource.accesscontrol.Price) Formatter(org.olat.core.util.Formatter) Date(java.util.Date)

Example 28 with Formatter

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

the class MemberInfoController method setMembershipCreation.

public void setMembershipCreation(Date date) {
    if (date != null) {
        Formatter formatter = Formatter.getInstance(getLocale());
        membershipCreationEl.setValue(formatter.formatDate(date));
    }
}
Also used : Formatter(org.olat.core.util.Formatter)

Example 29 with Formatter

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

the class LecturesBlockSignaturePDFExport method prepare.

@Override
public void prepare(HttpServletResponse hres) {
    try {
        Formatter formatter = Formatter.getInstance(translator.getLocale());
        String filename = lectureBlock.getTitle() + "_" + formatter.formatDate(lectureBlock.getStartDate()) + "_" + formatter.formatTimeShort(lectureBlock.getStartDate()) + "-" + formatter.formatTimeShort(lectureBlock.getEndDate()) + ".pdf";
        hres.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + StringHelper.urlEncodeUTF8(filename));
        hres.setHeader("Content-Description", StringHelper.urlEncodeUTF8(filename));
        document.save(hres.getOutputStream());
    } catch (COSVisitorException | IOException e) {
        log.error("", e);
    }
}
Also used : COSVisitorException(org.apache.pdfbox.exceptions.COSVisitorException) Formatter(org.olat.core.util.Formatter) IOException(java.io.IOException)

Example 30 with Formatter

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

the class LecturesBlockSignaturePDFExport method create.

public void create(List<Identity> rows) throws IOException, TransformerException {
    addPage();
    String lectureBlockTitle = lectureBlock.getTitle();
    String resourceTitle = entry.getDisplayname();
    addMetadata(lectureBlockTitle, resourceTitle, teacher);
    String title = resourceTitle + " - " + lectureBlockTitle;
    title = translator.translate("attendance.list.to.sign.title", new String[] { title });
    addParagraph(title, 16, true, width);
    Formatter formatter = Formatter.getInstance(translator.getLocale());
    String dates = translator.translate("pdf.table.dates", new String[] { formatter.formatDate(lectureBlock.getStartDate()), formatter.formatTimeShort(lectureBlock.getStartDate()), formatter.formatTimeShort(lectureBlock.getEndDate()) });
    addParagraph(dates, 12, true, width);
    float cellMargin = 5.0f;
    float fontSize = 10.0f;
    String[] content = getRows(rows);
    int numOfRows = content.length;
    for (int offset = 0; offset < numOfRows; ) {
        offset += drawTable(content, offset, fontSize, cellMargin);
        closePage();
        if (offset < numOfRows) {
            addPage();
        }
    }
    addPageNumbers();
}
Also used : Formatter(org.olat.core.util.Formatter)

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