diff --git a/pom.xml b/pom.xml
index dd073f2..81b39c6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -261,6 +261,11 @@
org.junit.platform
junit-platform-launcher
+
+ org.apache.commons
+ commons-csv
+ 1.7
+
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/CsvExporter.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/CsvExporter.java
new file mode 100644
index 0000000..5bfae4e
--- /dev/null
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/CsvExporter.java
@@ -0,0 +1,17 @@
+package de.kreth.vaadin.clubhelper.vaadinclubhelper.business;
+
+import org.apache.commons.csv.CSVFormat;
+
+public class CsvExporter {
+
+ private static final String HEAD_DATUM = "Datum";
+
+ private static final String HEAD_CAPTION = "Datum";
+
+ private static final String HEAD_ORT = "Ort";
+
+ private static final String[] HEAD = { HEAD_DATUM, HEAD_CAPTION, HEAD_ORT };
+
+ private final CSVFormat format = CSVFormat.RFC4180.withDelimiter(',')
+ .withHeader(HEAD);
+}
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/EventGrid.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/EventGrid.java
index ecdf045..cbf5c57 100644
--- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/EventGrid.java
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/EventGrid.java
@@ -1,24 +1,68 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components;
+import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
+import java.util.List;
+import org.basilbourque.timecolumnrenderers.ZonedDateTimeRenderer;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.vaadin.data.provider.ConfigurableFilterDataProvider;
+import com.vaadin.data.provider.DataProvider;
+import com.vaadin.server.SerializablePredicate;
import com.vaadin.ui.Grid;
+import com.vaadin.ui.Label;
+import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
+@Component
public class EventGrid extends Grid {
private static final long serialVersionUID = -5435770187868470290L;
- private transient final DateTimeFormatter df = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM);
- public EventGrid() {
+ private final transient DateTimeFormatter df = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM);
+
+ private ConfigurableFilterDataProvider> eventDataProvider;
+
+ private transient EventBusiness business;
+
+ public EventGrid(@Autowired EventBusiness eventBusiness) {
+
+ this.business = eventBusiness;
+ setCaption("Veranstaltungen");
+ setSizeFull();
+ setSelectionMode(SelectionMode.NONE);
addColumn(ClubEvent::getStart, dt -> {
return dt != null ? df.format(dt) : "";
}).setCaption("Start");
+
+ addComponentColumn(ev -> {
+ Label l = new Label();
+ l.setHeight("15px");
+ l.setWidth("15px");
+ l.addStyleName(ev.getOrganizerDisplayName());
+ return l;
+ }).setSortable(true).setHidable(false);
+ addColumn(ClubEvent::getStart).setCaption("Start")
+ .setRenderer(new ZonedDateTimeRenderer(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM)))
+ .setSortable(true).setHidable(true);
addColumn(ClubEvent::getCaption).setCaption("Bezeichnung");
addColumn(ClubEvent::getLocation).setCaption("Ort");
+
+ List loadEvents = business.loadEvents();
+
+ eventDataProvider = DataProvider
+ .ofCollection(loadEvents).withConfigurableFilter();
+ eventDataProvider.setFilter(this::filter);
+ setDataProvider(eventDataProvider);
+ }
+
+ private boolean filter(ClubEvent ev) {
+ return ev.getStart().isAfter(ZonedDateTime.now().minusMonths(1).withDayOfMonth(1));
}
}
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/HeadView.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/HeadView.java
index 5b98db0..10d1fd8 100644
--- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/HeadView.java
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/HeadView.java
@@ -16,6 +16,9 @@ import java.util.function.Function;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
import com.vaadin.contextmenu.ContextMenu;
import com.vaadin.icons.VaadinIcons;
@@ -30,23 +33,28 @@ import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.MenuBar.MenuItem;
import com.vaadin.ui.Notification;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
+import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.jasper.CalendarCreator;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityGroups;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarComponent.ClubEventProvider;
+import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.EventGrid;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation.ClubhelperNavigation.ClubNavigator;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperPrint;
-public class HeadView extends HorizontalLayout {
+public class HeadView extends HorizontalLayout implements ApplicationContextAware {
private static final long serialVersionUID = -7915475211371903028L;
+ private static ApplicationContext context;
+
protected transient final Logger log = LoggerFactory.getLogger(getClass());
protected transient DateTimeFormatter dfMonth = DateTimeFormatter.ofPattern("MMMM uuuu");
@@ -123,6 +131,7 @@ public class HeadView extends HorizontalLayout {
MenuItem menuItem = contextMenu.addItem("Export Monat", ev1 -> calendarExport(button, ev1));
monthItemId = menuItem.getId();
contextMenu.addItem("Export Jahr", ev1 -> calendarExport(button, ev1));
+ contextMenu.addItem("Export Termintaabelle", ev1 -> calendarCsv(button, ev1));
if (securityVerifier.isLoggedin()
&& securityVerifier.isPermitted(SecurityGroups.ADMIN, SecurityGroups.UEBUNGSLEITER)) {
contextMenu.addItem("Personen verwalten",
@@ -151,6 +160,24 @@ public class HeadView extends HorizontalLayout {
}
+ private void calendarCsv(Button button, MenuItem ev1) {
+
+ EventBusiness eventBusiness = context.getBean(EventBusiness.class);
+ EventGrid grid = new EventGrid(eventBusiness);
+
+ VerticalLayout layout = new VerticalLayout();
+ layout.addComponents(grid);
+
+ Window window = new Window();
+ window.setCaption("Veranstaltungen");
+ window.setContent(layout);
+ window.setModal(true);
+ window.setWidth("50%");
+ window.setHeight("90%");
+
+ button.getUI().addWindow(window);
+ }
+
private void calendarExport(Button source, MenuItem ev1) {
boolean monthOnly = ev1.getId() == monthItemId;
@@ -269,4 +296,9 @@ public class HeadView extends HorizontalLayout {
return c;
}
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ this.context = applicationContext;
+ }
+
}