package app.views.navigation; import app.components.navigation.NavigationHeader; import app.data.service.MatchService; import app.data.service.MatchdayService; import app.data.service.SeasonService; import app.navigation.Navigation; import com.vaadin.flow.component.orderedlayout.FlexComponent; import com.vaadin.flow.component.orderedlayout.VerticalLayout; import com.vaadin.flow.router.BeforeEvent; import com.vaadin.flow.router.HasUrlParameter; import com.vaadin.flow.router.WildcardParameter; import org.springframework.beans.factory.annotation.Autowired; public abstract class NavigationViewBase extends VerticalLayout implements HasUrlParameter { protected final Navigation navigation; protected final NavigationHeader navigationHeader; protected NavigationViewBase(@Autowired SeasonService seasonService, @Autowired MatchdayService matchdayService, @Autowired MatchService matchService, boolean seasonEnabled, boolean matchdayEnabled, boolean matchEnabled) { this.navigation = new Navigation(seasonService, matchdayService, matchService); this.navigationHeader = new NavigationHeader(navigation); navigation.setRoute(getRoute()); navigation.setSeasonEnabled(seasonEnabled); navigation.setMatchdayEnabled(matchdayEnabled); navigation.setMatchEnabled(matchEnabled); add(navigationHeader); setAlignItems(FlexComponent.Alignment.CENTER); navigation.addRunnableToBeRunAfterSelection(this::configureContent); } protected abstract String getRoute(); protected abstract void configureContent(); @Override public void removeAll() { super.removeAll(); add(navigationHeader); } @Override public void setParameter(BeforeEvent event, @WildcardParameter String param) { navigation.setParameter(event, param); } }