Search in sources :

Example 1 with KalendarEventRenderWrapper

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

the class CalendarPrintMapper method renderEvents.

/*
<div class="o_cal_wv_print">
	<ul class="o_cal_wv_list">
		<li>
			<span class="o_cal_date">Monday, May 13, 2013</span>
			<ul class="o_cal_events">
				<li class="o_cal_event">
					<div class="o_cal_time"><span>4:00 AM - 9:00 AM</span></div>
					<div class="o_cal_subject o_cal_blue"><p>Test</p></div>
				</li>
			</ul>
		</li>
		<li>
			<span class="o_cal_date">Tuesday, May 14, 2013</span>
			<ul class="o_cal_events">
				<li class="o_cal_event">
					<div class="o_cal_time"><span>2:00 PM - 3:00 PM</span></div>
					<div class="o_cal_subject o_cal_blue"><p>Test 3</p></div>
				</li>
			</ul>
		</li>
	</ul>
	<div class="clearfix">&nbsp;</div>
</div>
	*/
private void renderEvents(StringBuilder sb, List<KalendarEventRenderWrapper> eventList, Date dateFrom, Date dateTo) {
    sb.append("<div class='o_cal_wv_print'><fieldset>").append("<legend>").append(translator.translate("cal.print.title")).append("<span>").append(StringHelper.formatLocaleDateFull(dateFrom, translator.getLocale())).append(" - ").append(StringHelper.formatLocaleDateFull(dateTo, translator.getLocale())).append("</span></legend>").append("<ul class='o_cal_wv_list'>");
    Collections.sort(eventList, new KalendarEventDateComparator());
    Date currentDate = null;
    List<KalendarEventRenderWrapper> eventByDayList = new ArrayList<KalendarEventRenderWrapper>();
    for (KalendarEventRenderWrapper event : eventList) {
        Date begin = event.getEvent().getBegin();
        Date normalizedBegin = CalendarUtils.removeTime(begin);
        // same day?
        if (currentDate == null || currentDate.before(normalizedBegin)) {
            renderDay(sb, currentDate, eventByDayList);
            eventByDayList.clear();
            currentDate = normalizedBegin;
        }
        eventByDayList.add(event);
    }
    renderDay(sb, currentDate, eventByDayList);
    sb.append("</ul></fieldset><div class='clearfix'>&nbsp;</div></div>");
}
Also used : ArrayList(java.util.ArrayList) KalendarEventDateComparator(org.olat.commons.calendar.ui.components.KalendarEventDateComparator) Date(java.util.Date) KalendarEventRenderWrapper(org.olat.commons.calendar.ui.components.KalendarEventRenderWrapper)

Example 2 with KalendarEventRenderWrapper

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

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)

Example 3 with KalendarEventRenderWrapper

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

the class CalendarPrintMapper method renderEvents.

/*
<div class="o_cal_wv_print">
	<ul class="o_cal_wv_list">
		<li>
			<span class="o_cal_date">Monday, May 13, 2013</span>
			<ul class="o_cal_events">
				<li class="o_cal_event">
					<div class="o_cal_time"><span>4:00 AM - 9:00 AM</span></div>
					<div class="o_cal_subject o_cal_blue"><p>Test</p></div>
				</li>
			</ul>
		</li>
		<li>
			<span class="o_cal_date">Tuesday, May 14, 2013</span>
			<ul class="o_cal_events">
				<li class="o_cal_event">
					<div class="o_cal_time"><span>2:00 PM - 3:00 PM</span></div>
					<div class="o_cal_subject o_cal_blue"><p>Test 3</p></div>
				</li>
			</ul>
		</li>
	</ul>
	<div class="clearfix">&nbsp;</div>
</div>
	*/
private void renderEvents(StringBuilder sb, List<KalendarEventRenderWrapper> eventList, Date dateFrom, Date dateTo) {
    sb.append("<div class='o_cal_wv_print'><fieldset>").append("<legend>").append(translator.translate("cal.print.title")).append("<span>").append(StringHelper.formatLocaleDateFull(dateFrom, translator.getLocale())).append(" - ").append(StringHelper.formatLocaleDateFull(dateTo, translator.getLocale())).append("</span></legend>").append("<ul class='o_cal_wv_list'>");
    Collections.sort(eventList, new KalendarEventDateComparator());
    Date currentDate = null;
    List<KalendarEventRenderWrapper> eventByDayList = new ArrayList<KalendarEventRenderWrapper>();
    for (KalendarEventRenderWrapper event : eventList) {
        Date begin = event.getEvent().getBegin();
        Date normalizedBegin = CalendarUtils.removeTime(begin);
        // same day?
        if (currentDate == null || currentDate.before(normalizedBegin)) {
            renderDay(sb, currentDate, eventByDayList);
            eventByDayList.clear();
            currentDate = normalizedBegin;
        }
        eventByDayList.add(event);
    }
    renderDay(sb, currentDate, eventByDayList);
    sb.append("</ul></fieldset><div class='clearfix'>&nbsp;</div></div>");
}
Also used : ArrayList(java.util.ArrayList) KalendarEventDateComparator(org.olat.commons.calendar.ui.components.KalendarEventDateComparator) Date(java.util.Date) KalendarEventRenderWrapper(org.olat.commons.calendar.ui.components.KalendarEventRenderWrapper)

Example 4 with KalendarEventRenderWrapper

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

the class CalendarPrintMapper method renderDay.

private void renderDay(StringBuilder sb, Date date, List<KalendarEventRenderWrapper> eventList) {
    if (eventList.isEmpty())
        return;
    Date dayStart = date;
    Calendar cal = Calendar.getInstance();
    cal.setTime(dayStart);
    cal.add(Calendar.DAY_OF_YEAR, 1);
    Date dayEnd = cal.getTime();
    sb.append("<li><span class='o_cal_date'>").append(StringHelper.formatLocaleDateFull(dayStart, translator.getLocale())).append("</span><ul class='o_cal_events'>");
    for (KalendarEventRenderWrapper event : eventList) {
        renderEvent(sb, event, dayStart, dayEnd);
    }
    sb.append("</ul></li>");
}
Also used : Calendar(java.util.Calendar) Date(java.util.Date) KalendarEventRenderWrapper(org.olat.commons.calendar.ui.components.KalendarEventRenderWrapper)

Example 5 with KalendarEventRenderWrapper

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

the class CalendarPrintMapper method renderDay.

private void renderDay(StringBuilder sb, Date date, List<KalendarEventRenderWrapper> eventList) {
    if (eventList.isEmpty())
        return;
    Date dayStart = date;
    Calendar cal = Calendar.getInstance();
    cal.setTime(dayStart);
    cal.add(Calendar.DAY_OF_YEAR, 1);
    Date dayEnd = cal.getTime();
    sb.append("<li><span class='o_cal_date'>").append(StringHelper.formatLocaleDateFull(dayStart, translator.getLocale())).append("</span><ul class='o_cal_events'>");
    for (KalendarEventRenderWrapper event : eventList) {
        renderEvent(sb, event, dayStart, dayEnd);
    }
    sb.append("</ul></li>");
}
Also used : Calendar(java.util.Calendar) Date(java.util.Date) 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