Search in sources :

Example 66 with Formatter

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

the class TechnicalMetadataEditController method updateUI.

private void updateUI() {
    String editor = item.getEditor() == null ? "" : item.getEditor();
    editorEl.setValue(editor);
    String editorVersion = item.getEditorVersion() == null ? "" : item.getEditorVersion();
    editorVersionEl.setValue(editorVersion);
    String format = item.getFormat() == null ? "" : item.getFormat();
    formatEl.setValue(format);
    Formatter formatter = Formatter.getInstance(getLocale());
    String lastModified = formatter.formatDateAndTime(item.getLastModified());
    lastModifiedEl.setValue(lastModified);
    versionEl.setValue(item.getItemVersion());
    String statusLastModified = formatter.formatDateAndTime(item.getQuestionStatusLastModified());
    statusLastModified = statusLastModified != null ? statusLastModified : "";
    statusLastMdifiedEl.setValue(statusLastModified);
}
Also used : Formatter(org.olat.core.util.Formatter)

Example 67 with Formatter

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

the class TechnicalMetadataEditController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    uifactory.addStaticTextElement("general.identifier", item.getIdentifier(), formLayout);
    uifactory.addStaticTextElement("general.master.identifier", item.getMasterIdentifier(), formLayout);
    editorEl = uifactory.addStaticTextElement("technical.editor", "", formLayout);
    editorVersionEl = uifactory.addStaticTextElement("technical.editorVersion", "", formLayout);
    formatEl = uifactory.addStaticTextElement("technical.format", "", formLayout);
    Formatter formatter = Formatter.getInstance(getLocale());
    String creationDate = formatter.formatDateAndTime(item.getCreationDate());
    uifactory.addStaticTextElement("technical.creation", creationDate, formLayout);
    lastModifiedEl = uifactory.addStaticTextElement("technical.lastModified", "", formLayout);
    versionEl = uifactory.addTextElement("lifecycle.version", "lifecycle.version", 50, "", formLayout);
    statusLastMdifiedEl = uifactory.addStaticTextElement("technical.statusLastModified", "", formLayout);
    buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsCont.setRootForm(mainForm);
    formLayout.add(buttonsCont);
    uifactory.addFormSubmitButton("ok", "ok", buttonsCont);
    uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
}
Also used : Formatter(org.olat.core.util.Formatter)

Example 68 with Formatter

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

the class LectureBlockAuditLogExport method addHeaders.

@Override
protected void addHeaders(OpenXMLWorksheet exportSheet) {
    Row headerRow = exportSheet.newRow();
    int pos = 0;
    headerRow.addCell(pos++, translator.translate("export.header.entry", new String[] { entry.getDisplayname() }));
    Formatter formatter = Formatter.getInstance(translator.getLocale());
    String[] args = new String[] { lectureBlock.getTitle(), formatter.formatDate(lectureBlock.getStartDate()), formatter.formatTimeShort(lectureBlock.getStartDate()), formatter.formatTimeShort(lectureBlock.getEndDate()) };
    headerRow.addCell(pos++, translator.translate("export.header.lectureblocks", args));
}
Also used : Formatter(org.olat.core.util.Formatter) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row)

Example 69 with Formatter

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

the class LectureBlockExport method addHeaders_1.

private void addHeaders_1(OpenXMLWorksheet exportSheet) {
    Row headerRow = exportSheet.newRow();
    int pos = 0;
    Formatter formatter = Formatter.getInstance(translator.getLocale());
    String[] args = new String[] { lectureBlock.getTitle(), formatter.formatDate(lectureBlock.getStartDate()), formatter.formatTimeShort(lectureBlock.getStartDate()), formatter.formatTimeShort(lectureBlock.getEndDate()) };
    headerRow.addCell(pos, translator.translate("export.header.lectureblocks", args));
    if (isAdministrativeUser) {
        pos++;
    }
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null)
            continue;
        pos++;
    }
    if (teachers != null && teachers.size() > 0) {
        StringBuilder sb = new StringBuilder();
        for (Identity teacher : teachers) {
            if (sb.length() > 0)
                sb.append(", ");
            sb.append(userManager.getUserDisplayName(teacher));
        }
        headerRow.addCell(pos, translator.translate("export.header.teachers", new String[] { sb.toString() }));
    }
    if (StringHelper.containsNonWhitespace(lectureBlock.getLocation())) {
        pos += lectureBlock.getPlannedLecturesNumber();
        headerRow.addCell(pos, translator.translate("export.header.location", new String[] { lectureBlock.getLocation() }));
    }
}
Also used : Formatter(org.olat.core.util.Formatter) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 70 with Formatter

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

the class LecturesBlockPDFExport 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)

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