diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index c3edd86..6d88dab 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -2,6 +2,7 @@ eclipse.preferences.version=1 encoding//src/main/java=UTF-8 encoding//src/main/resources=UTF-8 encoding//src/main/resources/jasper/calendar_month.jrxml=UTF-8 +encoding//src/main/resources/jasper/calendar_year.jrxml=UTF-8 encoding//src/test/java=UTF-8 encoding//src/test/resources=UTF-8 encoding//target/generated-resources/gwt=UTF-8 diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarComponent.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarComponent.java index 68e4946..5a6242c 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarComponent.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarComponent.java @@ -7,6 +7,8 @@ import java.time.LocalDateTime; import java.time.Month; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalUnit; import java.util.Collection; import java.util.Date; import java.util.HashMap; @@ -111,11 +113,14 @@ public class CalendarComponent extends CustomComponent { String calendarName = ev.getOrganizerDisplayName(); if ("Schulferien".equals(calendarName)) { - int endDayOfMonth = ev.getEnd().getDayOfMonth(); - for (int dayOfMonth = ev.getStart().getDayOfMonth(); dayOfMonth<=endDayOfMonth; dayOfMonth++) { + log.trace("Added to holiday List: {}", ev); + TemporalUnit unit = ChronoUnit.DAYS; + int durationDays = (int) ev.getStart().until(ev.getEnd(), unit) + 1; + for (int dayOfMonth = ev.getStart().getDayOfMonth(), endDay=dayOfMonth + durationDays; dayOfMonth<=endDay; dayOfMonth++) { holidays.add(dayOfMonth); } } else { + log.trace("Added to eventsd: {}", ev); StringBuilder content; int dayOfMonth = ev.getStart().getDayOfMonth(); @@ -133,22 +138,25 @@ public class CalendarComponent extends CustomComponent { } } } - + + String calendarMonth = dfMonth.format(start); try { JasperPrint print = CalendarCreator.createCalendar(new Date(start.toInstant().toEpochMilli()), values, holidays); + log.trace("Created Jasper print for {}", calendarMonth); Window window = new Window(); window.setCaption("View PDF"); - AbstractComponent e = createEmbedded(dfMonth.format(start), print); + AbstractComponent e = createEmbedded(calendarMonth, print); window.setContent(e); window.setModal(true); window.setWidth("50%"); window.setHeight("90%"); monthName.getUI().addWindow(window); + log.trace("Added pdf window for {}", calendarMonth); } catch (JRException e) { - log.error("Error Creating Jasper Report.", e); + log.error("Error Creating Jasper Report for {}", calendarMonth, e); Notification.show("Fehler bei PDF: " + e); } catch (IOException e1) { - log.error("Error Creating Jasper Report.", e1); + log.error("Error Creating Jasper Report for {}", calendarMonth, e1); Notification.show("Fehler bei PDF: " + e1); } } diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarCreator.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarCreator.java index 8573a9d..293f83d 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarCreator.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarCreator.java @@ -1,19 +1,15 @@ package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components; import java.io.InputStream; -import java.sql.Timestamp; -import java.time.YearMonth; -import java.time.ZoneId; -import java.util.Arrays; import java.util.Calendar; import java.util.Collection; import java.util.Collections; import java.util.Date; -import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Locale; import java.util.Map; +import net.sf.jasperreports.engine.JRDataSource; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JasperCompileManager; import net.sf.jasperreports.engine.JasperFillManager; @@ -21,132 +17,62 @@ import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperReport; import net.sf.jasperreports.view.JasperViewer; -public class CalendarCreator { - - private final YearMonth yearMonthObject; +public abstract class CalendarCreator { public static JasperPrint createCalendar(Date date) throws JRException { - return new CalendarCreator(date).createCalendar(Collections.emptyMap(), Collections.emptyList()); + return new MonthlyCalendarCreator(date).setValues(Collections.emptyMap()).setHolidays(Collections.emptyList()).createCalendar(); } - public static JasperPrint createCalendar(Date date, Map values, Collection holidays) throws JRException { - return new CalendarCreator(date).createCalendar(values, holidays); - } - - CalendarCreator(Date date) { - yearMonthObject = YearMonth - .from(date.toInstant() - .atZone(ZoneId.systemDefault()) - .toLocalDate() - ); - + public static JasperPrint createCalendar(Date date, Map values, + Collection holidays) throws JRException { + return new MonthlyCalendarCreator(date).setValues(values).setHolidays(holidays).createCalendar(); } - JasperPrint createCalendar(Map values, Collection holidays) throws JRException { + public static JasperPrint createCalendar(int year) throws JRException { + return new YearlyCalendarCreator(year).createCalendar(); + } + public final JasperPrint createCalendar() throws JRException { Map parameters = new HashMap<>(); - Timestamp timestamp = new Timestamp(yearMonthObject.atDay(1).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); + fillParameterMap(parameters); - parameters.put("Date", timestamp); - - InputStream jrxmlResource = CalendarCreator.class.getResourceAsStream("/jasper/calendar_month.jrxml"); - JasperReport report = JasperCompileManager - .compileReport(jrxmlResource); + JasperReport report = JasperCompileManager.compileReport(jrxmlResource()); - JasperPrint print = JasperFillManager.fillReport(report, - parameters, new CalendarSource<>(yearMonthObject, values, holidays)); + JasperPrint print = JasperFillManager.fillReport(report, parameters, + getSource()); return print; } + protected abstract JRDataSource getSource(); + + protected abstract void fillParameterMap(Map parameters); + + protected abstract InputStream jrxmlResource(); + public static void main(String[] args) throws JRException { - + Locale.setDefault(Locale.GERMANY); - - Calendar cal = new GregorianCalendar(2018, Calendar.AUGUST, 1); - JasperViewer v1 = new JasperViewer(createCalendar(cal.getTime(), Collections.emptyMap(), Arrays.asList(2,3,4,5,6))); + +// Calendar cal = new GregorianCalendar(2018, Calendar.DECEMBER, 1); +// +// Map events = new HashMap<>(); +// events.put(3, "Event at 3rd."); +// events.put(23, "Event at 23th."); + +// JasperViewer v1 = new JasperViewer( +// createCalendar(cal.getTime(), events, Arrays.asList(2, 3, 4, 5, 6, 22, 23, 24))); +// v1.setVisible(true); + JasperViewer v1 = new JasperViewer( + createCalendar(2018)); v1.setVisible(true); - + // cal = new GregorianCalendar(2018, Calendar.FEBRUARY, 1); // JasperViewer v3 = new JasperViewer(createCalendar(cal.getTime())); // v3.setVisible(true); } - - /** - * - * @author markus - * - */ - public static class DateMetadata { - - private Calendar date; - private int dow; - private int dom; - private int doy; - private int days; - private int cells; - private int limit; - - public DateMetadata(java.sql.Date date) { - this(toCalendar(date.getTime())); - } - - public DateMetadata(long date) { - this(toCalendar(date)); - } - - public DateMetadata(Calendar date) { - this.date = (Calendar) date.clone(); - date.set(Calendar.DAY_OF_MONTH, 1); - dow = date.get(Calendar.DAY_OF_WEEK); - - dom = date.get(Calendar.MONTH) + 1; - doy = date.get(Calendar.YEAR); - days = YearMonth.of(doy, dom).lengthOfMonth(); - cells = dow - 1 + days; - limit = cells > 28 ? (cells>35?42:35) : 28; - } - - /** - * - * @param date - */ - public DateMetadata(Date date) { - this(toCalendar(date.getTime())); - } - - public Date getDate() { - return date.getTime(); - } - - public int getDow() { - return dow; - } - - public int getDom() { - return dom; - } - public int getDoy() { - return doy; - } - - public int getDays() { - return days; - } - - public int getCells() { - return cells; - } - - public int getLimit() { - return limit; - } - - - } - - private static Calendar toCalendar(long time) { + static Calendar toCalendar(long time) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(time); return cal; diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/DateMetadata.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/DateMetadata.java new file mode 100644 index 0000000..4fffe9d --- /dev/null +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/DateMetadata.java @@ -0,0 +1,79 @@ +package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components; + +import java.time.YearMonth; +import java.util.Calendar; +import java.util.Date; + +/** + * + * @author markus + * + */ +public class DateMetadata { + + private Calendar date; + private int dow; + private int dom; + private int doy; + private int days; + private int cells; + private int limit; + + public DateMetadata(java.sql.Date date) { + this(CalendarCreator.toCalendar(date.getTime())); + } + + public DateMetadata(long date) { + this(CalendarCreator.toCalendar(date)); + } + + public DateMetadata(Calendar date) { + this.date = (Calendar) date.clone(); + date.set(Calendar.DAY_OF_MONTH, 1); + dow = date.get(Calendar.DAY_OF_WEEK); + + dom = date.get(Calendar.MONTH) + 1; + doy = date.get(Calendar.YEAR); + days = YearMonth.of(doy, dom).lengthOfMonth(); + cells = dow - 1 + days; + limit = cells > 28 ? (cells>35?42:35) : 28; + } + + /** + * + * @param date + */ + public DateMetadata(Date date) { + this(CalendarCreator.toCalendar(date.getTime())); + } + + public Date getDate() { + return date.getTime(); + } + + public int getDow() { + return dow; + } + + public int getDom() { + return dom; + } + + public int getDoy() { + return doy; + } + + public int getDays() { + return days; + } + + public int getCells() { + return cells; + } + + public int getLimit() { + return limit; + } + + +} \ No newline at end of file diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/MonthlyCalendarCreator.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/MonthlyCalendarCreator.java new file mode 100644 index 0000000..bb70feb --- /dev/null +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/MonthlyCalendarCreator.java @@ -0,0 +1,52 @@ +package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components; + +import java.io.InputStream; +import java.sql.Timestamp; +import java.time.YearMonth; +import java.time.ZoneId; +import java.util.Collection; +import java.util.Date; +import java.util.Map; + +import net.sf.jasperreports.engine.JRDataSource; + +public class MonthlyCalendarCreator extends CalendarCreator { + + private final YearMonth yearMonthObject; + private Map values; + private Collection holidays; + + public MonthlyCalendarCreator(Date date) { + this.yearMonthObject = YearMonth.from(date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()); + } + + public MonthlyCalendarCreator setValues(Map values) { + this.values = values; + return this; + } + + public MonthlyCalendarCreator setHolidays(Collection holidays) { + this.holidays = holidays; + return this; + } + + @Override + protected void fillParameterMap(Map parameters) { + + Timestamp timestamp = new Timestamp( + yearMonthObject.atDay(1).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); + + parameters.put("Date", timestamp); + } + + @Override + protected InputStream jrxmlResource() { + return CalendarCreator.class.getResourceAsStream("/jasper/calendar_month.jrxml"); + } + + @Override + protected JRDataSource getSource() { + return new MonthlyCalendarSource<>(yearMonthObject, values, holidays); + } + +} \ No newline at end of file diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarSource.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/MonthlyCalendarSource.java similarity index 82% rename from src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarSource.java rename to src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/MonthlyCalendarSource.java index fff5505..bbd2f24 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarSource.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/MonthlyCalendarSource.java @@ -12,7 +12,7 @@ import net.sf.jasperreports.engine.JRDataSource; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JRField; -public class CalendarSource implements JRDataSource { +public class MonthlyCalendarSource implements JRDataSource { private final List days; private final Map dayContent; @@ -20,7 +20,7 @@ public class CalendarSource implements JRDataSource { private int prefix; private final Collection holidays; - public CalendarSource(YearMonth yearMonthObject, Map dayContent, Collection holidays) { + public MonthlyCalendarSource(YearMonth yearMonthObject, Map dayContent, Collection holidays) { days = new ArrayList<>(); this.dayContent = dayContent; @@ -64,13 +64,13 @@ public class CalendarSource implements JRDataSource { } } - public static CalendarSource createTestSource() { + public static MonthlyCalendarSource createTestSource() { Map values = new HashMap<>(); for (int i=1; i<30;i+=3) { values.put(i, String.format("Termin am %s.", i)); } List holi = Arrays.asList(2,3,4,5,6); - return new CalendarSource<>(YearMonth.now(), values, holi ); + return new MonthlyCalendarSource<>(YearMonth.now(), values, holi ); } } \ No newline at end of file diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/YearlyCalendarCreator.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/YearlyCalendarCreator.java new file mode 100644 index 0000000..72c281a --- /dev/null +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/YearlyCalendarCreator.java @@ -0,0 +1,49 @@ +package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components; + +import java.io.InputStream; +import java.util.Collection; +import java.util.Map; + +import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.calendar.Year; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRField; +import net.sf.jasperreports.engine.JasperPrint; + +public class YearlyCalendarCreator extends CalendarCreator { + + private Year year; + + public YearlyCalendarCreator(int year) { + this.year = new Year(year); + } + + @Override + protected JRDataSource getSource() { + return new EmptySource(); + } + + @Override + protected void fillParameterMap(Map parameters) { + parameters.put("Year", year); + } + + @Override + protected InputStream jrxmlResource() { + return CalendarCreator.class.getResourceAsStream("/jasper/calendar_year.jrxml"); + } + + private static class EmptySource implements JRDataSource { + + @Override + public boolean next() throws JRException { + return false; + } + + @Override + public Object getFieldValue(JRField jrField) throws JRException { + return null; + } + + } +} diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/calendar/Year.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/calendar/Year.java new file mode 100644 index 0000000..486f31f --- /dev/null +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/calendar/Year.java @@ -0,0 +1,60 @@ +package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.calendar; + +import java.time.DayOfWeek; +import java.time.LocalDate; +import java.time.Month; +import java.time.format.TextStyle; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Queue; + +public class Year { + + private final LocalDate date; + private final Locale locale; + + public Year(int year) { + this(year, Locale.getDefault()); + } + + public Year(int year, Locale locale) { + if (year < 1900 || year >2100) { + throw new IllegalArgumentException("Year value must be between 1900 and 2100"); + } + this.date = LocalDate.of(year, 1, 1); + this.locale = locale; + } + + public int getYear() { + return date.getYear(); + } + + public CharSequence getMonth(Month month) { + return month.getDisplayName(TextStyle.FULL_STANDALONE, locale); + } + + List days = Arrays.asList(null, null, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,28,30,31,32); + Queue queue = new LinkedList<>(days); + + /** + * Day of month, numeric for the specified by parameters. + * @param month month of the day + * @param week 1-5th week of the month + * @param dayOfWeek weekday of the week in the month. + * @return numeric value of the day of the month. + */ + public String getDay(Month month, short week, DayOfWeek dayOfWeek) { + if (queue.isEmpty()) { + queue.addAll(days); + } + Integer poll = queue.poll(); + if (poll != null) { + return poll.toString(); + } else { + return ""; + } + } + +} diff --git a/src/main/resources/jasper/calendar_month.jrxml b/src/main/resources/jasper/calendar_month.jrxml index 4a375e3..8575594 100644 --- a/src/main/resources/jasper/calendar_month.jrxml +++ b/src/main/resources/jasper/calendar_month.jrxml @@ -56,6 +56,12 @@ + + + + + + @@ -66,12 +72,10 @@ - - - - + + - + @@ -81,12 +85,10 @@ - - - - + + - + @@ -96,12 +98,10 @@ - - - - + + - + @@ -111,12 +111,10 @@ - - - - + + - + @@ -126,12 +124,10 @@ - - - - + + - + @@ -141,12 +137,10 @@ - - - - + + - + @@ -156,12 +150,11 @@ - - - - + + + - + @@ -176,6 +169,12 @@ + + + + + + 0&&$V{Date}.intValue()<=$P{Days}.intValue()]]> diff --git a/src/main/resources/jasper/calendar_year.jrxml b/src/main/resources/jasper/calendar_year.jrxml new file mode 100644 index 0000000..ddf0f7e --- /dev/null +++ b/src/main/resources/jasper/calendar_year.jrxml @@ -0,0 +1,300 @@ + + + + + + + + + + + + + + + + + + + + + + <band height="505"> + <textField pattern="MMMM"> + <reportElement isPrintRepeatedValues="false" x="0" y="0" width="286" height="25" uuid="21293131-3839-43aa-b449-b19867eee2da"/> + <box> + <topPen lineWidth="1.0"/> + <leftPen lineWidth="1.0"/> + <rightPen lineWidth="1.0"/> + </box> + <textElement textAlignment="Center"> + <font size="16" isBold="true"/> + </textElement> + <textFieldExpression><![CDATA[java.time.Month.JANUARY.getDisplayName(java.time.format.TextStyle.FULL_STANDALONE, java.util.Locale.getDefault())]]></textFieldExpression> + </textField> + <staticText> + <reportElement mode="Opaque" x="0" y="26" width="41" height="10" forecolor="#FFFCFC" backcolor="#403D3D" uuid="1b4d6c56-6d09-482b-8eb5-662c88cbe870"> + <property name="com.jaspersoft.studio.unit.y" value="pixel"/> + </reportElement> + <box> + <pen lineColor="#000000"/> + <leftPen lineWidth="1.0"/> + <bottomPen lineWidth="1.0"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="6" isBold="true"/> + </textElement> + <text><![CDATA[Montag]]></text> + </staticText> + <staticText> + <reportElement mode="Opaque" x="42" y="26" width="41" height="10" forecolor="#FFFCFC" backcolor="#403D3D" uuid="a373077e-66c1-4218-b9a2-bd35f7d19f7a"> + <property name="com.jaspersoft.studio.unit.y" value="pixel"/> + </reportElement> + <box> + <pen lineColor="#000000"/> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="6" isBold="true"/> + </textElement> + <text><![CDATA[Dienstag]]></text> + </staticText> + <staticText> + <reportElement mode="Opaque" x="84" y="26" width="41" height="10" forecolor="#FFFCFC" backcolor="#403D3D" uuid="d1e26dda-0b1a-4ef2-b48c-276accc3eeaa"> + <property name="com.jaspersoft.studio.unit.y" value="pixel"/> + </reportElement> + <box> + <pen lineColor="#000000"/> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="6" isBold="true"/> + </textElement> + <text><![CDATA[Mittwoch]]></text> + </staticText> + <staticText> + <reportElement mode="Opaque" x="126" y="26" width="41" height="10" forecolor="#FFFCFC" backcolor="#403D3D" uuid="9c9395c6-7cc2-4571-97f6-e3b4bfe58263"> + <property name="com.jaspersoft.studio.unit.y" value="pixel"/> + </reportElement> + <box> + <pen lineColor="#000000"/> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="6" isBold="true"/> + </textElement> + <text><![CDATA[Donnerstag]]></text> + </staticText> + <staticText> + <reportElement mode="Opaque" x="168" y="26" width="41" height="10" forecolor="#FFFCFC" backcolor="#403D3D" uuid="12589ff4-2da8-448f-995a-99cf8446ccfa"> + <property name="com.jaspersoft.studio.unit.y" value="pixel"/> + </reportElement> + <box> + <pen lineColor="#000000"/> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="6" isBold="true"/> + </textElement> + <text><![CDATA[Freitag]]></text> + </staticText> + <staticText> + <reportElement mode="Opaque" x="210" y="26" width="41" height="10" forecolor="#FFFCFC" backcolor="#403D3D" uuid="c2f7be3d-5ccf-4838-b55d-51eafd78f3e4"> + <property name="com.jaspersoft.studio.unit.y" value="pixel"/> + </reportElement> + <box> + <pen lineColor="#000000"/> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="6" isBold="true"/> + </textElement> + <text><![CDATA[Samstag]]></text> + </staticText> + <staticText> + <reportElement mode="Opaque" x="252" y="26" width="41" height="10" forecolor="#FFFCFC" backcolor="#403D3D" uuid="bc9c8dee-afda-435c-8f11-d7294c248f8c"> + <property name="com.jaspersoft.studio.unit.y" value="pixel"/> + </reportElement> + <box> + <pen lineColor="#000000"/> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="6" isBold="true"/> + </textElement> + <text><![CDATA[Sonntag]]></text> + </staticText> + <frame> + <reportElement mode="Transparent" x="0" y="38" width="41" height="50" backcolor="#F7C86F" uuid="7621d880-6dae-4cfb-9d99-6c4c83dd1983"> + <property name="com.jaspersoft.studio.unit.x" value="pixel"/> + <property name="com.jaspersoft.studio.unit.y" value="pixel"/> + <property name="com.jaspersoft.studio.unit.width" value="pixel"/> + </reportElement> + <textField> + <reportElement style="Style_Calendar_Day_Number" mode="Opaque" x="0" y="0" width="41" height="10" isRemoveLineWhenBlank="true" uuid="e30cd5f6-c9f8-459d-b37e-401dadccba90"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font size="6" isBold="true"/> + <paragraph rightIndent="1"/> + </textElement> + <textFieldExpression><![CDATA[$P{Year}.getDay( java.time.Month.JANUARY, (short)1, java.time.DayOfWeek.MONDAY )]]></textFieldExpression> + </textField> + <textField> + <reportElement x="0" y="10" width="41" height="40" isRemoveLineWhenBlank="true" uuid="660304e6-2981-448f-8990-0cf8f2efbc23"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement> + <font size="4"/> + </textElement> + <textFieldExpression><![CDATA[$F{Field_Value}]]></textFieldExpression> + </textField> + </frame> + <frame> + <reportElement mode="Transparent" x="41" y="38" width="41" height="50" backcolor="#F7C86F" uuid="7e44315b-20e3-43bf-9014-e0d0aa6072f3"> + <property name="com.jaspersoft.studio.unit.x" value="pixel"/> + <property name="com.jaspersoft.studio.unit.y" value="pixel"/> + <property name="com.jaspersoft.studio.unit.width" value="pixel"/> + </reportElement> + <textField> + <reportElement style="Style_Calendar_Day_Number" mode="Opaque" x="0" y="0" width="41" height="10" isRemoveLineWhenBlank="true" uuid="202fe000-98be-4c0f-b59c-7bc91a656a5b"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font size="6" isBold="true"/> + <paragraph rightIndent="1"/> + </textElement> + <textFieldExpression><![CDATA[$P{Year}.getDay( java.time.Month.JANUARY, (short)1, java.time.DayOfWeek.TUESDAY )]]></textFieldExpression> + </textField> + <textField> + <reportElement x="0" y="10" width="41" height="40" isRemoveLineWhenBlank="true" uuid="208dff4b-9244-4c50-9ae1-e6b1a36fc06a"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement> + <font size="4"/> + </textElement> + <textFieldExpression><![CDATA[$F{Field_Value}]]></textFieldExpression> + </textField> + </frame> + <frame> + <reportElement mode="Transparent" x="41" y="90" width="41" height="50" backcolor="#F7C86F" uuid="55a1c7f6-7ce3-4824-9d1b-fb0290572f7c"> + <property name="com.jaspersoft.studio.unit.x" value="pixel"/> + <property name="com.jaspersoft.studio.unit.y" value="pixel"/> + <property name="com.jaspersoft.studio.unit.width" value="pixel"/> + </reportElement> + <textField> + <reportElement style="Style_Calendar_Day_Number" mode="Opaque" x="0" y="0" width="41" height="10" isRemoveLineWhenBlank="true" uuid="389d3764-a279-4825-bb7d-e36f1be6b580"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font size="6" isBold="true"/> + <paragraph rightIndent="1"/> + </textElement> + <textFieldExpression><![CDATA[$P{Year}.getDay( java.time.Month.JANUARY, (short)2, java.time.DayOfWeek.TUESDAY )]]></textFieldExpression> + </textField> + <textField> + <reportElement x="0" y="10" width="41" height="40" isRemoveLineWhenBlank="true" uuid="ecf323b4-70bd-4cdf-96e5-f16c400d7710"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement> + <font size="4"/> + </textElement> + <textFieldExpression><![CDATA[$F{Field_Value}]]></textFieldExpression> + </textField> + </frame> + <frame> + <reportElement mode="Transparent" x="0" y="90" width="41" height="50" backcolor="#F7C86F" uuid="f72aa4b4-fc79-4ee5-bb8e-51df4c08d0b4"> + <property name="com.jaspersoft.studio.unit.x" value="pixel"/> + <property name="com.jaspersoft.studio.unit.y" value="pixel"/> + <property name="com.jaspersoft.studio.unit.width" value="pixel"/> + </reportElement> + <textField> + <reportElement style="Style_Calendar_Day_Number" mode="Opaque" x="0" y="0" width="41" height="10" isRemoveLineWhenBlank="true" uuid="74c81ac8-3588-4df4-bec7-bb3193c625c1"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font size="6" isBold="true"/> + <paragraph rightIndent="1"/> + </textElement> + <textFieldExpression><![CDATA[$P{Year}.getDay( java.time.Month.JANUARY, (short)2, java.time.DayOfWeek.MONDAY )]]></textFieldExpression> + </textField> + <textField> + <reportElement x="0" y="10" width="41" height="40" isRemoveLineWhenBlank="true" uuid="16724e14-9391-4fe0-99b8-4284ec4d39d1"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement> + <font size="4"/> + </textElement> + <textFieldExpression><![CDATA[$F{Field_Value}]]></textFieldExpression> + </textField> + </frame> + </band> + + + + + diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarCreatorTest.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarCreatorTest.java index 6a96c66..2730d96 100644 --- a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarCreatorTest.java +++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarCreatorTest.java @@ -8,8 +8,6 @@ import org.junit.jupiter.api.Test; import com.ibm.icu.util.Calendar; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarCreator.DateMetadata; - class CalendarCreatorTest { @Test diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/calendar/YearTest.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/calendar/YearTest.java new file mode 100644 index 0000000..55965e1 --- /dev/null +++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/calendar/YearTest.java @@ -0,0 +1,32 @@ +package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.calendar; + +import static org.junit.jupiter.api.Assertions.*; + +import java.time.DayOfWeek; +import java.time.Month; + +import org.junit.jupiter.api.Test; + +class YearTest { + + @Test() + void test18thCenturyEx() { + assertThrows(IllegalArgumentException.class, () -> new Year(1899)); + assertThrows(IllegalArgumentException.class, () -> new Year(2101)); + new Year(1900); + new Year(2100); + } + + @Test + void testMondayIsFirst() { + Year y = new Year(2018); + assertEquals(Short.valueOf((short)1), y.getDay(Month.OCTOBER, (short)1, DayOfWeek.MONDAY)); + } + + @Test + void testThursdayIsFirst() { + Year y = new Year(2018); + assertNull(y.getDay(Month.NOVEMBER, (short)1, DayOfWeek.MONDAY)); + } + +}