Search in sources :

Example 1 with KalendarEventDateComparator

use of org.olat.commons.calendar.ui.components.KalendarEventDateComparator 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 KalendarEventDateComparator

use of org.olat.commons.calendar.ui.components.KalendarEventDateComparator 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)

Aggregations

ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 KalendarEventDateComparator (org.olat.commons.calendar.ui.components.KalendarEventDateComparator)2 KalendarEventRenderWrapper (org.olat.commons.calendar.ui.components.KalendarEventRenderWrapper)2