Refactoring Navigation

master
Markus Kreth 7 years ago
parent 2cfb3a6d58
commit 9de8550c11
  1. 1
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDaoImpl.java
  2. 28
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/MainUi.java
  3. 12
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/NamedView.java
  4. 18
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/EventDetails.java
  5. 114
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperNavigation.java
  6. 14
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperViews.java
  7. 15
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/HeadView.java
  8. 12
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/LoginUI.java
  9. 23
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/MainView.java
  10. 14
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/PersonEditView.java

@ -37,6 +37,7 @@ public class ClubEventDaoImpl extends AbstractDaoImpl<ClubEvent> implements Club
} }
@Override @Override
@Transactional
public void addPersons(ClubEvent event, Collection<Person> updated) { public void addPersons(ClubEvent event, Collection<Person> updated) {
List<Person> added = new ArrayList<>(updated); List<Person> added = new ArrayList<>(updated);
List<Person> removed = new ArrayList<>(); List<Person> removed = new ArrayList<>();

@ -7,8 +7,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.annotations.PreserveOnRefresh; import com.vaadin.annotations.PreserveOnRefresh;
import com.vaadin.annotations.Push; import com.vaadin.annotations.Push;
import com.vaadin.annotations.Theme; import com.vaadin.annotations.Theme;
import com.vaadin.navigator.Navigator; import com.vaadin.server.Page;
import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinRequest;
import com.vaadin.server.WebBrowser;
import com.vaadin.shared.communication.PushMode; import com.vaadin.shared.communication.PushMode;
import com.vaadin.spring.annotation.SpringUI; import com.vaadin.spring.annotation.SpringUI;
import com.vaadin.ui.UI; import com.vaadin.ui.UI;
@ -19,7 +20,8 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao; import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PflichtenDao; import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PflichtenDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier; import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.EventDetails; import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation.ClubhelperNavigation;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation.ClubhelperViews;
@Theme("vaadin-clubhelpertheme") @Theme("vaadin-clubhelpertheme")
@SpringUI @SpringUI
@ -48,22 +50,24 @@ public class MainUi extends UI {
@Autowired @Autowired
CalendarAdapter calendarAdapter; CalendarAdapter calendarAdapter;
@Autowired
ClubhelperNavigation clubhelperNavigation;
@Override @Override
protected void init(VaadinRequest request) { protected void init(VaadinRequest request) {
LOGGER.debug("Starting Vaadin UI with {}", getClass().getName()); Page page = getPage();
int browserWidth = page.getBrowserWindowWidth();
WebBrowser webBrowser = page.getWebBrowser();
getPage().setTitle("Vereinshelfer"); LOGGER.debug("Starting Vaadin UI with {}, windowWidth={}, touchDevice={}, Android={}, IPad={}, IPhone={}",
getClass().getName(), browserWidth, webBrowser.isTouchDevice(), webBrowser.isAndroid(),
webBrowser.isIPad(), webBrowser.isIPhone());
Navigator navigator = new Navigator(this, this); page.setTitle("Vereinshelfer");
// Create and register the views clubhelperNavigation.configure(this);
navigator.addView(MainView.VIEW_NAME, new MainView(personDao, groupDao, eventBusiness, securityGroupVerifier)); clubhelperNavigation.navigateTo(ClubhelperViews.MainView.name());
navigator.addView(LoginUI.VIEW_NAME, new LoginUI(personDao, securityGroupVerifier));
navigator.addView(PersonEditView.VIEW_NAME, new PersonEditView(groupDao, personDao));
navigator.addView(EventDetails.VIEW_NAME,
new EventDetails(personDao, groupDao, eventBusiness, pflichtenDao, calendarAdapter));
navigator.navigateTo(MainView.VIEW_NAME);
} }
} }

@ -1,12 +0,0 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui;
import com.vaadin.navigator.View;
public interface NamedView extends View {
/**
* Navigation view name used for this view.
*
* @return view name.
*/
String getViewName();
}

@ -1,6 +1,6 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components; package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components;
import com.vaadin.navigator.Navigator; import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.shared.ui.ContentMode; import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
@ -18,11 +18,10 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao; import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PflichtenDao; import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PflichtenDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.NamedView; import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation.ClubhelperNavigation.ClubNavigator;
public class EventDetails extends GridLayout implements NamedView { public class EventDetails extends GridLayout implements View {
public static final String VIEW_NAME = "EventDetails";
private static final long serialVersionUID = 8290150079638390995L; private static final long serialVersionUID = 8290150079638390995L;
private final EventBusiness eventBusiness; private final EventBusiness eventBusiness;
@ -52,12 +51,12 @@ public class EventDetails extends GridLayout implements NamedView {
currentEvent = eventBusiness.getCurrent(); currentEvent = eventBusiness.getCurrent();
if (eventView == null) { if (eventView == null) {
Navigator navigator = event.getNavigator(); ClubNavigator navigator = (ClubNavigator) event.getNavigator();
eventView = new SingleEventView(true); eventView = new SingleEventView(true);
eventView.setCalendarAdapter(calendarAdapter); eventView.setCalendarAdapter(calendarAdapter);
eventView.setEventBusiness(eventBusiness); eventView.setEventBusiness(eventBusiness);
eventView.setDeletedHandler(() -> navigator.navigateTo(((NamedView) event.getOldView()).getViewName())); eventView.setDeletedHandler(() -> navigator.back());
eventView.addDataUpdatedListener(() -> eventBusiness.storeEventType()); eventView.addDataUpdatedListener(() -> eventBusiness.storeEventType());
@ -69,7 +68,7 @@ public class EventDetails extends GridLayout implements NamedView {
personGrid.setSelectionMode(SelectionMode.NONE); personGrid.setSelectionMode(SelectionMode.NONE);
Button back = new Button("Zurück"); Button back = new Button("Zurück");
back.addClickListener(ev -> navigator.navigateTo(((NamedView) event.getOldView()).getViewName())); back.addClickListener(ev -> navigator.back());
Button createMeldung = new Button("Meldung"); Button createMeldung = new Button("Meldung");
createMeldung.addClickListener(ev -> show(eventBusiness.createMeldung())); createMeldung.addClickListener(ev -> show(eventBusiness.createMeldung()));
@ -100,9 +99,4 @@ public class EventDetails extends GridLayout implements NamedView {
} }
@Override
public String getViewName() {
return VIEW_NAME;
}
} }

@ -0,0 +1,114 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation;
import java.util.Stack;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.vaadin.navigator.Navigator;
import com.vaadin.ui.Notification;
import com.vaadin.ui.UI;
import de.kreth.googleconnectors.calendar.CalendarAdapter;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
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;
@Component
public class ClubhelperNavigation {
private static final Logger LOGGER = LoggerFactory.getLogger(ClubhelperNavigation.class);
@Autowired
PersonDao personDao;
@Autowired
GroupDao groupDao;
@Autowired
EventBusiness eventBusiness;
@Autowired
PflichtenDao pflichtenDao;
@Autowired
SecurityVerifier securityGroupVerifier;
@Autowired
CalendarAdapter calendarAdapter;
private ClubNavigator navi;
public void configure(UI mainUI) {
navi = new ClubNavigator().init(mainUI);
// Create and register the views
MainView mainView = new MainView(personDao, groupDao, eventBusiness, securityGroupVerifier);
navi.addView("", mainView);
navi.addView(ClubhelperViews.MainView.name(), mainView);
navi.addView(ClubhelperViews.LoginUI.name(), new LoginUI(personDao, securityGroupVerifier));
navi.addView(ClubhelperViews.PersonEditView.name(), new PersonEditView(groupDao, personDao));
navi.addView(ClubhelperViews.EventDetails.name(),
new EventDetails(personDao, groupDao, eventBusiness, pflichtenDao, calendarAdapter));
mainUI.getPage().addBrowserWindowResizeListener(ev -> {
int width = ev.getWidth();
int height = ev.getHeight();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Changed Window Size: [w={},h={}]", width, height);
Notification.show("Size Changed", "Changed Window Size: [w=" + width + ",h=" + height + "]",
Notification.Type.TRAY_NOTIFICATION);
}
});
}
public void navigateTo(String navigationState) {
navi.navigateTo(navigationState);
}
public class ClubNavigator extends Navigator {
private static final long serialVersionUID = -6503600786209888296L;
private final Stack<ClubhelperViews> navigationViewNames = new Stack<>();
ClubNavigator init(UI ui) {
init(ui, null, new SingleComponentContainerViewDisplay(ui));
return this;
}
@Override
public void navigateTo(String navigationState) {
ClubhelperViews byState = ClubhelperViews.byState(navigationState);
if (navigationViewNames.contains(byState)) {
int index = navigationViewNames.indexOf(byState);
LOGGER.warn("Navigating to previously visited View. Removing some history");
while (navigationViewNames.size() > index) {
navigationViewNames.remove(index);
}
}
int width = navi.getUI().getPage().getBrowserWindowWidth();
boolean loggedIn = securityGroupVerifier.isLoggedin();
if (!loggedIn && width < 1000) {
navigationViewNames.clear();
navigationViewNames.add(ClubhelperViews.MainView);
super.navigateTo(ClubhelperViews.LoginUI.name());
} else {
navigationViewNames.add(byState);
super.navigateTo(navigationState);
}
}
public void back() {
navigationViewNames.pop();
navigateTo(navigationViewNames.pop().name());
}
}
}

@ -0,0 +1,14 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation;
public enum ClubhelperViews {
MainView, EventDetails, PersonEditView, LoginUI;
public static ClubhelperViews byState(String state) {
for (ClubhelperViews v : values()) {
if (state.startsWith(v.name())) {
return v;
}
}
throw new IllegalArgumentException("View not found for state=" + state);
}
}

@ -1,4 +1,4 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui; package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation;
import java.io.IOException; import java.io.IOException;
import java.io.PipedInputStream; import java.io.PipedInputStream;
@ -19,7 +19,6 @@ import org.slf4j.LoggerFactory;
import com.vaadin.contextmenu.ContextMenu; import com.vaadin.contextmenu.ContextMenu;
import com.vaadin.icons.VaadinIcons; import com.vaadin.icons.VaadinIcons;
import com.vaadin.navigator.Navigator;
import com.vaadin.server.StreamResource; import com.vaadin.server.StreamResource;
import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
@ -38,6 +37,7 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.jasper.CalendarCreator;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityGroups; import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityGroups;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier; 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.CalendarComponent.ClubEventProvider;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation.ClubhelperNavigation.ClubNavigator;
import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperExportManager; import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperPrint;
@ -60,11 +60,11 @@ public class HeadView extends HorizontalLayout {
private Label personLabel; private Label personLabel;
private final Navigator navigator; private final ClubNavigator navigator;
private final SecurityVerifier securityVerifier; private final SecurityVerifier securityVerifier;
public HeadView(Navigator navigator, Supplier<ZonedDateTime> startTime, Supplier<ZonedDateTime> endTime, public HeadView(ClubNavigator navigator, Supplier<ZonedDateTime> startTime, Supplier<ZonedDateTime> endTime,
ClubEventProvider dataProvider, SecurityVerifier securityVerifier) { ClubEventProvider dataProvider, SecurityVerifier securityVerifier) {
this.navigator = navigator; this.navigator = navigator;
@ -122,14 +122,15 @@ public class HeadView extends HorizontalLayout {
contextMenu.addItem("Export Jahr", ev1 -> calendarExport(ev1)); contextMenu.addItem("Export Jahr", ev1 -> calendarExport(ev1));
if (securityVerifier.getLoggedinPerson() != null) { if (securityVerifier.getLoggedinPerson() != null) {
if (securityVerifier.isPermitted(SecurityGroups.ADMIN, SecurityGroups.UEBUNGSLEITER)) { if (securityVerifier.isPermitted(SecurityGroups.ADMIN, SecurityGroups.UEBUNGSLEITER)) {
contextMenu.addItem("Personen verwalten", ev1 -> navigator.navigateTo(PersonEditView.VIEW_NAME)); contextMenu.addItem("Personen verwalten",
ev1 -> navigator.navigateTo(ClubhelperViews.PersonEditView.name()));
} }
contextMenu.addItem("Abmelden", ev1 -> { contextMenu.addItem("Abmelden", ev1 -> {
securityVerifier.setLoggedinPerson(null); securityVerifier.setLoggedinPerson(null);
navigator.navigateTo(MainView.VIEW_NAME); navigator.navigateTo(ClubhelperViews.MainView.name());
}); });
} else { } else {
contextMenu.addItem("Anmelden", ev1 -> navigator.navigateTo(LoginUI.VIEW_NAME)); contextMenu.addItem("Anmelden", ev1 -> navigator.navigateTo(ClubhelperViews.LoginUI.name()));
} }
contextMenu.open(50, 50); contextMenu.open(50, 50);
} }

@ -1,9 +1,10 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui; package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.vaadin.navigator.Navigator; import com.vaadin.navigator.Navigator;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
import com.vaadin.ui.LoginForm; import com.vaadin.ui.LoginForm;
@ -14,9 +15,8 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier; import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
public class LoginUI extends VerticalLayout implements NamedView { public class LoginUI extends VerticalLayout implements View {
public static final String VIEW_NAME = "LoginUI";
private static final long serialVersionUID = 4339018452507960084L; private static final long serialVersionUID = 4339018452507960084L;
private final Logger logger = LoggerFactory.getLogger(getClass()); private final Logger logger = LoggerFactory.getLogger(getClass());
@ -34,7 +34,7 @@ public class LoginUI extends VerticalLayout implements NamedView {
try { try {
Person loggedin = personDao.findLoginUser(username, password); Person loggedin = personDao.findLoginUser(username, password);
securityGroupVerifier.setLoggedinPerson(loggedin); securityGroupVerifier.setLoggedinPerson(loggedin);
navigator.navigateTo(MainView.VIEW_NAME + '/' + parameters); navigator.navigateTo(ClubhelperViews.MainView.name() + '/' + parameters);
} catch (final Exception ex) { } catch (final Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
logger.error("Error on login for User={}", e.getLoginParameter("username"), ex); logger.error("Error on login for User={}", e.getLoginParameter("username"), ex);
@ -58,8 +58,4 @@ public class LoginUI extends VerticalLayout implements NamedView {
} }
} }
@Override
public String getViewName() {
return VIEW_NAME;
}
} }

@ -1,4 +1,4 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui; package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -10,7 +10,7 @@ import org.slf4j.LoggerFactory;
import org.vaadin.addon.calendar.ui.CalendarComponentEvents; import org.vaadin.addon.calendar.ui.CalendarComponentEvents;
import com.vaadin.event.selection.SelectionEvent; import com.vaadin.event.selection.SelectionEvent;
import com.vaadin.navigator.Navigator; import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.Grid.SelectionMode; import com.vaadin.ui.Grid.SelectionMode;
@ -26,13 +26,11 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier; import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarComponent; import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarComponent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarComponent.ClubEventProvider; import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarComponent.ClubEventProvider;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.EventDetails;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonGrid; 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.SingleEventView;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation.ClubhelperNavigation.ClubNavigator;
public class MainView extends VerticalLayout implements NamedView { public class MainView extends VerticalLayout implements View {
public static final String VIEW_NAME = "";
private static final long serialVersionUID = 4831071242146146399L; private static final long serialVersionUID = 4831071242146146399L;
private final Logger LOGGER = LoggerFactory.getLogger(getClass()); private final Logger LOGGER = LoggerFactory.getLogger(getClass());
@ -48,7 +46,7 @@ public class MainView extends VerticalLayout implements NamedView {
private SingleEventView eventView; private SingleEventView eventView;
private HorizontalLayout eventButtonLayout; private HorizontalLayout eventButtonLayout;
private Navigator navigator; private ClubNavigator navigator;
private VerticalLayout eastLayout; private VerticalLayout eastLayout;
@ -87,7 +85,7 @@ public class MainView extends VerticalLayout implements NamedView {
public void initUI(ViewChangeEvent event) { public void initUI(ViewChangeEvent event) {
navigator = event.getNavigator(); navigator = (ClubNavigator) event.getNavigator();
eventView = new SingleEventView(false); eventView = new SingleEventView(false);
eventView.setVisible(false); eventView.setVisible(false);
@ -104,7 +102,7 @@ public class MainView extends VerticalLayout implements NamedView {
close.setId("person.close"); close.setId("person.close");
Button eventDetails = new Button("Veranstaltung Details", ev -> { Button eventDetails = new Button("Veranstaltung Details", ev -> {
navigator.navigateTo(EventDetails.VIEW_NAME); navigator.navigateTo(ClubhelperViews.EventDetails.name());
}); });
eventDetails.setId("person.eventDetails"); eventDetails.setId("person.eventDetails");
@ -178,7 +176,7 @@ public class MainView extends VerticalLayout implements NamedView {
openPersonViewForEvent(ev); openPersonViewForEvent(ev);
} else { } else {
eventBusiness.setSelected(ev); eventBusiness.setSelected(ev);
navigator.navigateTo(LoginUI.VIEW_NAME + '/' + ev.getId()); navigator.navigateTo(ClubhelperViews.LoginUI.name() + '/' + ev.getId());
} }
} }
@ -202,9 +200,4 @@ public class MainView extends VerticalLayout implements NamedView {
eventBusiness.setSelected(ev); eventBusiness.setSelected(ev);
} }
@Override
public String getViewName() {
return VIEW_NAME;
}
} }

@ -1,4 +1,4 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui; package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
@ -6,6 +6,7 @@ import java.util.Optional;
import com.vaadin.event.selection.SelectionEvent; import com.vaadin.event.selection.SelectionEvent;
import com.vaadin.navigator.Navigator; import com.vaadin.navigator.Navigator;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalLayout;
@ -17,9 +18,8 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonEditDetails; import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonEditDetails;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonGrid; import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonGrid;
public class PersonEditView extends VerticalLayout implements NamedView { public class PersonEditView extends VerticalLayout implements View {
public static final String VIEW_NAME = "PersonEditView";
private static final long serialVersionUID = 1770993670570422036L; private static final long serialVersionUID = 1770993670570422036L;
private PersonGrid personGrid; private PersonGrid personGrid;
@ -51,7 +51,7 @@ public class PersonEditView extends VerticalLayout implements NamedView {
addComponent(addPerson); addComponent(addPerson);
Button backButton = new Button("Zurück"); Button backButton = new Button("Zurück");
backButton.addClickListener(ev -> navigator.navigateTo(MainView.VIEW_NAME)); backButton.addClickListener(ev -> navigator.navigateTo(ClubhelperViews.MainView.name()));
addComponent(backButton); addComponent(backButton);
} }
@ -72,13 +72,7 @@ public class PersonEditView extends VerticalLayout implements NamedView {
@Override @Override
public void enter(ViewChangeEvent event) { public void enter(ViewChangeEvent event) {
NamedView.super.enter(event);
this.navigator = event.getNavigator(); this.navigator = event.getNavigator();
} }
@Override
public String getViewName() {
return VIEW_NAME;
}
} }
Loading…
Cancel
Save