Search in sources :

Example 6 with KalendarEventRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarEventRenderWrapper in project openolat by klemens.

the class CalendarPrintMapper method handle.

@Override
public MediaResource handle(String relPath, HttpServletRequest request) {
    StringBuilder sb = new StringBuilder();
    sb.append("<html><head><title>").append("Calendar").append("</title>").append("<meta http-equiv='Content-type' content='text/html; charset=utf-8' />").append("<link href='").append(themeBaseUri).append("theme.css' rel='stylesheet' type='text/css' />\n").append("<!--[if IE 9]><link id='o_theme_css_ie' href='").append(themeBaseUri).append("theme_ie_completions.css' rel='stylesheet' type='text/css' /><![endif]-->\n").append("</head><body class='o_cal_print' onload='window.focus();window.print()'>");
    // collect all events
    List<KalendarEventRenderWrapper> sortedEventsWithin = new ArrayList<>();
    collectEvents(sortedEventsWithin, calendarWrappers);
    Collections.sort(sortedEventsWithin, KalendarEventDateComparator.getInstance());
    // list of events
    renderEvents(sb, sortedEventsWithin, from, to);
    // list of calendars
    renderCalendars(sb);
    sb.append("</body></html>");
    StringMediaResource smr = new StringMediaResource();
    smr.setContentType("text/html");
    smr.setEncoding("UTF-8");
    smr.setData(sb.toString());
    return smr;
}
Also used : ArrayList(java.util.ArrayList) StringMediaResource(org.olat.core.gui.media.StringMediaResource) KalendarEventRenderWrapper(org.olat.commons.calendar.ui.components.KalendarEventRenderWrapper)

Aggregations

KalendarEventRenderWrapper (org.olat.commons.calendar.ui.components.KalendarEventRenderWrapper)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 Calendar (java.util.Calendar)2 KalendarEventDateComparator (org.olat.commons.calendar.ui.components.KalendarEventDateComparator)2 StringMediaResource (org.olat.core.gui.media.StringMediaResource)2