Menu in EventDetail, more commands replace buttons.

master
Markus Kreth 6 years ago
parent 7daf22a7e3
commit f9d156de36
  1. 17
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusiness.java
  2. 68
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/SelectEvent.java
  3. 6
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/SelectionListener.java
  4. 38
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/CreateMeldungCommand.java
  5. 30
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/commands/DeleteEventCommand.java
  6. 111
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/EventDetails.java
  7. 66
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/SingleEventView.java
  8. 171
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinMenuitemState.java
  9. 5
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/MenuItemStateFactory.java
  10. 28
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperNavigation.java
  11. 86
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/EventDetails.java
  12. 16
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/NavigationEvent.java
  13. 6
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/NavigationListener.java

@ -1,6 +1,7 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.business;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
@ -23,6 +24,8 @@ public class EventBusiness {
private final Logger log = LoggerFactory.getLogger(getClass());
private final List<SelectionListener<ClubEvent>> selectionListener = new ArrayList<>();
@Autowired
ClubEventDao clubEventDao;
@ -42,7 +45,12 @@ public class EventBusiness {
}
public void setSelected(ClubEvent ev) {
ClubEvent old = current;
this.current = ev;
SelectEvent<ClubEvent> event = new SelectEvent<>(old, ev);
for (SelectionListener<ClubEvent> l : selectionListener) {
l.selectionChanged(event);
}
}
public void changePersons(Set<Person> selected) throws ClubhelperException {
@ -102,4 +110,13 @@ public class EventBusiness {
clubEventDao.delete(bean);
current = null;
}
public void add(SelectionListener<ClubEvent> e) {
selectionListener.add(e);
}
public void remove(SelectionListener<ClubEvent> o) {
selectionListener.remove(o);
}
}

@ -0,0 +1,68 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.business;
public class SelectEvent<T> {
private final T oldObject;
private final T newObject;
public SelectEvent(T oldObject, T newObject) {
super();
this.oldObject = oldObject;
this.newObject = newObject;
}
public T getOldObject() {
return oldObject;
}
public T getNewObject() {
return newObject;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((newObject == null) ? 0 : newObject.hashCode());
result = prime * result + ((oldObject == null) ? 0 : oldObject.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
SelectEvent<?> other = (SelectEvent<?>) obj;
if (newObject == null) {
if (other.newObject != null) {
return false;
}
}
else if (!newObject.equals(other.newObject)) {
return false;
}
if (oldObject == null) {
if (other.oldObject != null) {
return false;
}
}
else if (!oldObject.equals(other.oldObject)) {
return false;
}
return true;
}
@Override
public String toString() {
return "SelectEvent [oldObject=" + oldObject + ", newObject=" + newObject + "]";
}
}

@ -0,0 +1,6 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.business;
public interface SelectionListener<T> {
void selectionChanged(SelectEvent<T> event);
}

@ -0,0 +1,38 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands;
import java.util.function.Consumer;
import org.springframework.context.ApplicationContext;
import com.vaadin.server.Resource;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.meldung.EventMeldung;
public class CreateMeldungCommand implements ClubCommand {
private EventBusiness business;
private Consumer<EventMeldung> showMeldungCommand;
public CreateMeldungCommand(ApplicationContext context, Consumer<EventMeldung> showMeldungCommand) {
this.business = context.getBean(EventBusiness.class);
this.showMeldungCommand = showMeldungCommand;
}
@Override
public String getLabel() {
return "Meldung erstellen";
}
@Override
public Resource getIcon() {
return null;
}
@Override
public void execute() {
showMeldungCommand.accept(business.createMeldung());
}
}

@ -0,0 +1,30 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.server.Resource;
public class DeleteEventCommand implements ClubCommand {
private final Runnable deleteDelegate;
public DeleteEventCommand(Runnable deleteDelegate) {
super();
this.deleteDelegate = deleteDelegate;
}
@Override
public String getLabel() {
return "Veranstaltung löschen";
}
@Override
public Resource getIcon() {
return VaadinIcons.DEL;
}
@Override
public void execute() {
deleteDelegate.run();
}
}

@ -1,111 +0,0 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import de.kreth.googleconnectors.calendar.CalendarAdapter;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.meldung.EventMeldung;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PflichtenDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation.ClubhelperNavigation.ClubNavigator;
public class EventDetails extends GridLayout implements View {
private static final long serialVersionUID = 8290150079638390995L;
private final EventBusiness eventBusiness;
private final PersonBusiness personDao;
private final GroupDao groupDao;
private final PflichtenDao pflichtenDao;
private ClubEvent currentEvent;
private SingleEventView eventView;
private PersonGrid personGrid;
private EventAltersgruppen eventAltersgruppen;
private CalendarAdapter calendarAdapter;
public EventDetails(PersonBusiness personDao, GroupDao groupDao, EventBusiness eventBusiness,
PflichtenDao pflichtenDao,
CalendarAdapter calendarAdapter) {
super(3, 5);
this.eventBusiness = eventBusiness;
this.personDao = personDao;
this.groupDao = groupDao;
this.pflichtenDao = pflichtenDao;
this.calendarAdapter = calendarAdapter;
}
@Override
public void enter(ViewChangeEvent event) {
currentEvent = eventBusiness.getCurrent();
if (eventView == null) {
ClubNavigator navigator = (ClubNavigator) event.getNavigator();
eventView = new SingleEventView(true);
eventView.setCalendarAdapter(calendarAdapter);
eventView.setEventBusiness(eventBusiness);
eventView.setDeletedHandler(() -> navigator.back());
eventView.addDataUpdatedListener(() -> eventBusiness.storeEventType());
eventAltersgruppen = new EventAltersgruppen(pflichtenDao, eventBusiness);
eventView.addDataUpdatedListener(eventAltersgruppen);
personGrid = new PersonGrid(groupDao, personDao);
personGrid.hideFilter();
personGrid.setSelectionMode(SelectionMode.NONE);
Button back = new Button("Zurück");
back.addClickListener(ev -> navigator.back());
Button createMeldung = new Button("Meldung");
createMeldung.addClickListener(ev -> show(eventBusiness.createMeldung()));
HorizontalLayout buttonLayout = new HorizontalLayout(back, createMeldung);
buttonLayout.setMargin(true);
buttonLayout.setSpacing(true);
addComponent(eventView, 0, 0);
addComponent(eventAltersgruppen, 1, 0);
addComponent(personGrid, 2, 0);
addComponent(buttonLayout, 0, 4, 2, 4);
setSizeFull();
}
else {
eventAltersgruppen.updateData();
}
eventView.setEvent(currentEvent);
personGrid.setEvent(currentEvent);
}
private void show(EventMeldung createMeldung) {
VerticalLayout content = new VerticalLayout();
content.addComponent(new Label(createMeldung.toString(), ContentMode.PREFORMATTED));
Window dlg = new Window("Meldung für " + eventBusiness.getCurrent().getCaption());
dlg.setContent(content);
dlg.center();
getUI().addWindow(dlg);
}
}

@ -1,22 +1,17 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components;
import java.io.IOException;
import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import com.vaadin.data.Binder;
import com.vaadin.data.HasValue.ValueChangeEvent;
import com.vaadin.ui.Button;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.DateField;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Notification;
import com.vaadin.ui.TextField;
import de.kreth.googleconnectors.calendar.CalendarAdapter;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.CompetitionType;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.CompetitionType.Type;
@ -41,14 +36,6 @@ public class SingleEventView extends CustomComponent {
private DefaultDataUpdateHandler updateHandler = new DefaultDataUpdateHandler();
private Button deleteButton;
private CalendarAdapter calendarAdapter;
private EventBusiness eventBusiness;
private Runnable deletedHandler;
public SingleEventView(boolean showCompetitionType) {
setCaption("Gewählte Veranstaltung");
addStyleName("bold-caption");
@ -97,50 +84,15 @@ public class SingleEventView extends CustomComponent {
layout = new GridLayout(2, 2);
}
deleteButton = new Button("Löschen");
layout.setMargin(true);
layout.setSpacing(true);
layout.addComponents(textTitle, startDate, textLocation, endDate);
if (showCompetitionType) {
layout.addComponent(competitionType);
deleteButton = new Button("Löschen");
deleteButton.addClickListener(ev -> deleteEvent());
layout.addComponent(deleteButton);
}
setCompositionRoot(layout);
}
private void deleteEvent() {
ClubEvent bean = binder.getBean();
ConfirmDialog dlg = ConfirmDialog.builder().setCaption("Löschen bestätigen!").setMessage("Wollen Sie Termin \""
+ bean.getCaption() + "\" vom " + bean.getStart() + "\" bis " + bean.getEnd()
+ " wirklich löschen? Dieser Vorgang kann nicht rückgängig gemacht werden und betrifft auch den Online Google Calendar.")
.setResultHandler(btn -> {
if (btn == ConfirmDialog.Buttons.YES) {
try {
String host = getUI().getPage().getLocation().getHost();
if (calendarAdapter.deleteEvent(host, bean.getOrganizerDisplayName(), bean.getId())) {
eventBusiness.delete(bean);
if (deletedHandler != null) {
deletedHandler.run();
}
}
else {
Notification.show("Fehler beim Löschen von " + bean, "Bitte erneut versuchen.",
Notification.Type.ERROR_MESSAGE);
}
}
catch (IOException e) {
Notification.show("Fehler beim Löschen von " + bean, e.toString(),
Notification.Type.ERROR_MESSAGE);
}
}
}).yesCancel().build();
getUI().addWindow(dlg);
}
void endDateVisibleCheck(ValueChangeEvent<LocalDate> event) {
ZonedDateTime start = binder.getBean().getStart();
ZonedDateTime end = binder.getBean().getEnd();
@ -162,10 +114,6 @@ public class SingleEventView extends CustomComponent {
return updateHandler.remove(o);
}
public void setDeletedHandler(Runnable deletedHandler) {
this.deletedHandler = deletedHandler;
}
void setLocation(String value) {
if (value == null) {
value = "";
@ -177,23 +125,11 @@ public class SingleEventView extends CustomComponent {
binder.setBean(ev);
if (ev != null) {
deleteButton.setEnabled(true);
}
else {
if (ev == null) {
textTitle.setValue("");
setLocation("");
endDate.setVisible(false);
deleteButton.setEnabled(false);
}
}
public void setCalendarAdapter(CalendarAdapter calendarAdapter) {
this.calendarAdapter = calendarAdapter;
}
public void setEventBusiness(EventBusiness eventBusiness) {
this.eventBusiness = eventBusiness;
}
}

@ -1,6 +1,8 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.menu;
import java.io.IOException;
import java.time.ZonedDateTime;
import java.util.Arrays;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
@ -8,16 +10,29 @@ import org.springframework.context.ApplicationContext;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.navigator.View;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.Label;
import com.vaadin.ui.MenuBar.MenuItem;
import com.vaadin.ui.Notification;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import de.kreth.googleconnectors.calendar.CalendarAdapter;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.meldung.EventMeldung;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands.ClubCommand;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands.CreateMeldungCommand;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands.DeleteEventCommand;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands.ExportCalendarMonthCommand;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands.ExportCalendarYearCommand;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands.ExportCsvCommand;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands.LogoutCommand;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands.SwitchViewCommand;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.ClubEventProvider;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.ConfirmDialog;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation.ClubhelperNavigation;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation.ClubhelperNavigation.ClubNavigator;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation.ClubhelperViews;
@ -41,26 +56,83 @@ class LoggedinMenuitemState implements MenuItemState {
private BiConsumer<String, JasperPrint> printConsumer;
public LoggedinMenuitemState(ApplicationContext context, Supplier<ZonedDateTime> startProvider,
private MenuItem openPersonMenuItem;
private MenuItem calendarMenuItem;
private UI ui;
private MenuItem eventDetailItem;
private EventBusiness eventBusiness;
private MenuItem createMeldungMenuItem;
private MenuItem deleteMenuItem;
public LoggedinMenuitemState(ApplicationContext context, UI ui, Supplier<ZonedDateTime> startProvider,
Supplier<ZonedDateTime> endProvider, BiConsumer<String, JasperPrint> printConsumer) {
super();
this.navigator = context.getBean(ClubhelperNavigation.class);
this.ui = ui;
this.context = context;
this.dataProvider = context.getBean(ClubEventProvider.class);
this.startProvider = startProvider;
this.endProvider = endProvider;
this.printConsumer = printConsumer;
this.navigator = context.getBean(ClubhelperNavigation.class);
this.dataProvider = context.getBean(ClubEventProvider.class);
this.eventBusiness = context.getBean(EventBusiness.class);
navigator.add(ev -> setSelectedMenuItem(ev.getNewView()));
View current = navigator.getNavigator().getCurrentView();
ClubhelperViews view = ClubhelperViews.byView(current);
eventBusiness.add(ev -> setSelectedMenuItem(view));
}
@Override
public void applyMenuStates(ClubhelperMenuBar menuBar) {
menuBar.getAllMainMenus().forEach(m -> m.setVisible(false));
MenuItem fileMenuItem = menuBar.getFileMenuItem();
fileMenuItem.setVisible(true);
CommandWrapper logout = new CommandWrapper(new LogoutCommand(navigator2, securityVerifier));
fileMenuItem.addItem(logout.getLabel(), logout);
prepareEditMenu(menuBar);
prepareViewMenu(menuBar);
menuBar.getSettingsItem().setVisible(false);
View current = navigator.getNavigator().getCurrentView();
ClubhelperViews view = ClubhelperViews.byView(current);
setSelectedMenuItem(view);
}
private void prepareViewMenu(ClubhelperMenuBar menuBar) {
MenuItem viewMenu = menuBar.getViewMenuItem();
viewMenu.setVisible(true);
CommandWrapper calendarView = new CommandWrapper(
new SwitchViewCommand(context, "Hauptansicht", VaadinIcons.CALENDAR, ClubhelperViews.MainView));
calendarMenuItem = viewMenu.addItem(calendarView.getLabel(), calendarView);
calendarMenuItem.setCheckable(true);
CommandWrapper openPersonEditor = new CommandWrapper(
new SwitchViewCommand(context, "Personen verwalten", VaadinIcons.EDIT, ClubhelperViews.PersonEditView));
openPersonMenuItem = viewMenu.addItem(openPersonEditor.getLabel(), openPersonEditor);
openPersonMenuItem.setCheckable(true);
CommandWrapper detailViewCommand = new CommandWrapper(
new SwitchViewCommand(context, "Veranstaltung Detail", null, ClubhelperViews.EventDetails));
eventDetailItem = viewMenu.addItem(detailViewCommand.getLabel(), detailViewCommand);
eventDetailItem.setCheckable(true);
}
private void prepareEditMenu(ClubhelperMenuBar menuBar) {
MenuItem editMenu = menuBar.getEditMenuItem();
editMenu.setVisible(true);
CommandWrapper exportCalendarMonthCommand = new CommandWrapper(
new ExportCalendarMonthCommand(startProvider, endProvider, dataProvider, printConsumer));
@ -71,24 +143,89 @@ class LoggedinMenuitemState implements MenuItemState {
ClubCommand exportCsvCommand = new ExportCsvCommand(menuBar, context);
editMenu.addItem(exportCsvCommand.getLabel(), ev -> exportCsvCommand.execute());
MenuItem viewMenu = menuBar.getViewMenuItem();
viewMenu.setVisible(true);
CommandWrapper openPersonEditor = new CommandWrapper(
new SwitchViewCommand(context, "Personen verwalten", VaadinIcons.EDIT, ClubhelperViews.PersonEditView));
MenuItem openPersonMenuItem = viewMenu.addItem(openPersonEditor.getLabel(), openPersonEditor);
openPersonMenuItem.setCheckable(true);
CommandWrapper calendarView = new CommandWrapper(
new SwitchViewCommand(context, "Hauptansicht", VaadinIcons.CALENDAR, ClubhelperViews.MainView));
MenuItem calendarMenuItem = viewMenu.addItem(calendarView.getLabel(), calendarView);
calendarMenuItem.setCheckable(true);
View current = navigator.getNavigator().getCurrentView();
ClubhelperViews view = ClubhelperViews.byView(current);
CreateMeldungCommand createMeldungCommand = new CreateMeldungCommand(context, this::show);
createMeldungMenuItem = editMenu.addItem(createMeldungCommand.getLabel(),
new CommandWrapper(createMeldungCommand));
CommandWrapper deleeteEvent = new CommandWrapper(new DeleteEventCommand(this::deleteEvent));
deleteMenuItem = editMenu.addItem(deleeteEvent.getLabel(), deleeteEvent);
}
protected void setSelectedMenuItem(ClubhelperViews view) {
if (eventBusiness.getCurrent() != null) {
createMeldungMenuItem.setEnabled(true);
eventDetailItem.setVisible(true);
deleteMenuItem.setEnabled(true);
}
else {
createMeldungMenuItem.setEnabled(false);
eventDetailItem.setVisible(false);
deleteMenuItem.setEnabled(false);
}
for (MenuItem item : Arrays.asList(openPersonMenuItem, calendarMenuItem, eventDetailItem)) {
item.setChecked(false);
item.setEnabled(true);
}
if (ClubhelperViews.PersonEditView == view) {
openPersonMenuItem.setChecked(true);
openPersonMenuItem.setEnabled(false);
}
else {
else if (ClubhelperViews.MainView == view) {
calendarMenuItem.setChecked(true);
calendarMenuItem.setEnabled(false);
}
else if (ClubhelperViews.EventDetails.equals(view)) {
eventDetailItem.setChecked(true);
eventDetailItem.setEnabled(false);
}
}
private void show(EventMeldung createMeldung) {
VerticalLayout content = new VerticalLayout();
content.addComponent(new Label(createMeldung.toString(), ContentMode.PREFORMATTED));
Window dlg = new Window("Meldung für " + eventBusiness.getCurrent().getCaption());
dlg.setContent(content);
dlg.center();
ui.addWindow(dlg);
}
private void deleteEvent() {
ClubEvent bean = eventBusiness.getCurrent();
ConfirmDialog dlg = ConfirmDialog.builder().setCaption("Löschen bestätigen!").setMessage("Wollen Sie Termin \""
+ bean.getCaption() + "\" vom " + bean.getStart() + "\" bis " + bean.getEnd()
+ " wirklich löschen? Dieser Vorgang kann nicht rückgängig gemacht werden und betrifft auch den Online Google Calendar.")
.setResultHandler(btn -> {
if (btn == ConfirmDialog.Buttons.YES) {
try {
String host = ui.getPage().getLocation().getHost();
CalendarAdapter calendarAdapter = context.getBean(CalendarAdapter.class);
if (calendarAdapter.deleteEvent(host, bean.getOrganizerDisplayName(), bean.getId())) {
eventBusiness.delete(bean);
View current = navigator.getNavigator().getCurrentView();
ClubhelperViews view = ClubhelperViews.byView(current);
if (ClubhelperViews.EventDetails.equals(view)) {
navigator.getNavigator().back();
}
}
else {
Notification.show("Fehler beim Löschen von " + bean, "Bitte erneut versuchen.",
Notification.Type.ERROR_MESSAGE);
}
}
catch (IOException e) {
Notification.show("Fehler beim Löschen von " + bean, e.toString(),
Notification.Type.ERROR_MESSAGE);
}
}
}).yesCancel().build();
ui.addWindow(dlg);
}
}

@ -52,11 +52,10 @@ public class MenuItemStateFactory implements ApplicationContextAware {
View currentView = clubhelperNavigation.getNavigator().getCurrentView();
ClubhelperViews current = ClubhelperViews.byView(currentView);
if (ClubhelperViews.PersonEditView == current) {
state = new LoggedinMenuitemState(context, startDateSupplier, endDateSupplier, this::showPrint);
state = new LoggedinMenuitemState(context, ui, startDateSupplier, endDateSupplier, this::showPrint);
}
else if (securityGroupVerifier.isLoggedin()) {
state = new LoggedinMenuitemState(context, startDateSupplier, endDateSupplier, this::showPrint);
state = new LoggedinMenuitemState(context, ui, startDateSupplier, endDateSupplier, this::showPrint);
}
else {
state = new LoggedOffState(context, startDateSupplier, endDateSupplier, this::showPrint);

@ -1,6 +1,8 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import java.util.function.Supplier;
@ -23,7 +25,6 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PflichtenDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.EventDetails;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.menu.ClubhelperMenuBar;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.menu.MenuItemStateFactory;
@ -34,6 +35,8 @@ public class ClubhelperNavigation implements ApplicationContextAware {
private static final int WIDTH_LIMIT_FOR_MOBILE = 1000;
private final List<NavigationListener> naviListeners = new ArrayList<>();
private ApplicationContext context;
@Autowired
@ -75,8 +78,7 @@ public class ClubhelperNavigation implements ApplicationContextAware {
navi.addView(ClubhelperViews.LoginUI.name(), new LoginUI(personBusiness, securityGroupVerifier));
personEdit = factory.createPersonEdit();
navi.addView(ClubhelperViews.PersonEditView.name(), personEdit);
navi.addView(ClubhelperViews.EventDetails.name(),
new EventDetails(personBusiness, groupDao, eventBusiness, pflichtenDao, calendarAdapter));
navi.addView(ClubhelperViews.EventDetails.name(), new EventDetails(context));
page.addBrowserWindowResizeListener(ev -> {
int width = ev.getWidth();
@ -125,6 +127,14 @@ public class ClubhelperNavigation implements ApplicationContextAware {
navi.navigateTo(navigationState);
}
public void add(NavigationListener e) {
naviListeners.add(e);
}
public void remove(NavigationListener o) {
naviListeners.remove(o);
}
public class ClubNavigator extends Navigator {
private static final long serialVersionUID = -6503600786209888296L;
@ -165,12 +175,20 @@ public class ClubhelperNavigation implements ApplicationContextAware {
navigationViewNames.add(byState);
super.navigateTo(navigationState);
}
NavigationEvent event = new NavigationEvent(byState);
for (NavigationListener navigationListener : naviListeners) {
navigationListener.navigation(event);
}
}
public void back() {
navigationViewNames.pop();
navigateTo(navigationViewNames.pop().name());
ClubhelperViews pop = navigationViewNames.pop();
navigateTo(pop.name());
NavigationEvent event = new NavigationEvent(pop);
for (NavigationListener navigationListener : naviListeners) {
navigationListener.navigation(event);
}
}
}

@ -0,0 +1,86 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation;
import org.springframework.context.ApplicationContext;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.GridLayout;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PflichtenDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.EventAltersgruppen;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonGrid;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.SingleEventView;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.menu.ClubhelperMenuBar;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.menu.MenuItemStateFactory;
public class EventDetails extends GridLayout implements View {
private static final long serialVersionUID = 8290150079638390995L;
private final EventBusiness eventBusiness;
private final PersonBusiness personDao;
private final GroupDao groupDao;
private final PflichtenDao pflichtenDao;
private ClubEvent currentEvent;
private SingleEventView eventView;
private PersonGrid personGrid;
private EventAltersgruppen eventAltersgruppen;
private MenuItemStateFactory stateFactory;
public EventDetails(ApplicationContext context) {
super(3, 5);
this.stateFactory = context.getBean(MenuItemStateFactory.class);
this.eventBusiness = context.getBean(EventBusiness.class);
this.personDao = context.getBean(PersonBusiness.class);
this.groupDao = context.getBean(GroupDao.class);
this.pflichtenDao = context.getBean(PflichtenDao.class);
}
@Override
public void enter(ViewChangeEvent event) {
currentEvent = eventBusiness.getCurrent();
if (eventView == null) {
ClubhelperMenuBar menubar = new ClubhelperMenuBar(stateFactory.currentState());
// ClubNavigator navigator = (ClubNavigator) event.getNavigator();
eventView = new SingleEventView(true);
// eventView.setCalendarAdapter(calendarAdapter);
eventView.addDataUpdatedListener(() -> eventBusiness.storeEventType());
eventAltersgruppen = new EventAltersgruppen(pflichtenDao, eventBusiness);
eventView.addDataUpdatedListener(eventAltersgruppen);
personGrid = new PersonGrid(groupDao, personDao);
personGrid.hideFilter();
personGrid.setSelectionMode(SelectionMode.NONE);
addComponent(menubar, 0, 0, 2, 0);
addComponent(eventView, 0, 1);
addComponent(eventAltersgruppen, 1, 1);
addComponent(personGrid, 2, 1);
setSizeFull();
}
else {
eventAltersgruppen.updateData();
}
eventView.setEvent(currentEvent);
personGrid.setEvent(currentEvent);
}
}

@ -0,0 +1,16 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation;
public class NavigationEvent {
private final ClubhelperViews newView;
NavigationEvent(ClubhelperViews newView) {
super();
this.newView = newView;
}
public ClubhelperViews getNewView() {
return newView;
}
}

@ -0,0 +1,6 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation;
public interface NavigationListener {
void navigation(NavigationEvent event);
}
Loading…
Cancel
Save