Search in sources :

Example 1 with SubmenuNavigationElement

use of com.github.appreciated.app.layout.builder.elements.SubmenuNavigationElement in project vaadin-app-layout by appreciated.

the class AppLayoutConfiguration method prepareNavigationElement.

private void prepareNavigationElement(AbstractNavigationElement element) {
    if (element instanceof HasCaptionInterceptor) {
        ((HasCaptionInterceptor) element).setCaptionInterceptor(captionInterceptor);
    }
    if (element instanceof NavigatorNavigationElement) {
        NavigatorNavigationElement nElement = (NavigatorNavigationElement) element;
        nElement.setCDI(isCDI);
        nElement.setNavigationElementInfoProvider(navigationElementInfoProvider);
        if ((isCDI == false && nElement.getViewClassName() == defaultNavigationElement.getViewClassName()) || (isCDI == true && nElement.getViewName().equals(""))) {
            AppLayoutSessionHelper.updateActiveElementSessionData(nElement);
        }
        nElement.setViewNameInterceptor(viewNameInterceptor);
        if (isNavigatorEnabled) {
            nElement.addViewToNavigator(navigator);
        } else {
            nElement.addViewToComponentNavigator(componentNavigator);
        }
        navigatorElements.add(nElement);
    } else if (element instanceof SubmenuNavigationElement) {
        SubmenuNavigationElement sElement = (SubmenuNavigationElement) element;
        sElement.getSubmenuElements().forEach(element1 -> prepareNavigationElement(element1));
    }
}
Also used : Panel(com.vaadin.ui.Panel) AppLayoutSessionHelper(com.github.appreciated.app.layout.session.AppLayoutSessionHelper) SectionNavigationElement(com.github.appreciated.app.layout.builder.elements.SectionNavigationElement) Behaviour(com.github.appreciated.app.layout.behaviour.Behaviour) NavigationElementComponent(com.github.appreciated.app.layout.builder.interfaces.NavigationElementComponent) UI(com.vaadin.ui.UI) ComponentFactory(com.github.appreciated.app.layout.builder.interfaces.ComponentFactory) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) HasCaptionInterceptor(com.github.appreciated.app.layout.builder.interfaces.HasCaptionInterceptor) SubmenuNavigationElement(com.github.appreciated.app.layout.builder.elements.SubmenuNavigationElement) DefaultLeftSectionElementComponentFactory(com.github.appreciated.app.layout.builder.factories.left.DefaultLeftSectionElementComponentFactory) AbstractNavigationElement(com.github.appreciated.app.layout.builder.elements.AbstractNavigationElement) NavigatorNavigationElement(com.github.appreciated.app.layout.builder.elements.NavigatorNavigationElement) AppLayoutDesign(com.github.appreciated.app.layout.builder.design.AppLayoutDesign) NavigationElementInfo(com.github.appreciated.app.layout.builder.entities.NavigationElementInfo) DefaultLeftNavigationBadgeElementComponentFactory(com.github.appreciated.app.layout.builder.factories.left.DefaultLeftNavigationBadgeElementComponentFactory) Navigator(com.vaadin.navigator.Navigator) Consumer(java.util.function.Consumer) List(java.util.List) AppLayoutComponent(com.github.appreciated.app.layout.behaviour.AppLayoutComponent) ComponentNavigator(com.github.appreciated.app.layout.navigator.ComponentNavigator) Factory(com.github.appreciated.app.layout.builder.interfaces.Factory) Optional(java.util.Optional) DefaultTopSubmenuNavigationElementFactory(com.github.appreciated.app.layout.builder.factories.top.DefaultTopSubmenuNavigationElementFactory) DefaultLeftClickableNavigationElementFactory(com.github.appreciated.app.layout.builder.factories.left.DefaultLeftClickableNavigationElementFactory) DefaultLeftSubmenuNavigationElementFactory(com.github.appreciated.app.layout.builder.factories.left.DefaultLeftSubmenuNavigationElementFactory) ViewProvider(com.vaadin.navigator.ViewProvider) View(com.vaadin.navigator.View) Component(com.vaadin.ui.Component) NavigatorNavigationElement(com.github.appreciated.app.layout.builder.elements.NavigatorNavigationElement) SubmenuNavigationElement(com.github.appreciated.app.layout.builder.elements.SubmenuNavigationElement) HasCaptionInterceptor(com.github.appreciated.app.layout.builder.interfaces.HasCaptionInterceptor)

Example 2 with SubmenuNavigationElement

use of com.github.appreciated.app.layout.builder.elements.SubmenuNavigationElement in project vaadin-app-layout by appreciated.

the class DefaultTopSubmenuNavigationElementFactory method addToMenuBar.

private void addToMenuBar(MenuBar menuBar, AbstractNavigationElement element) {
    if (element instanceof SubmenuNavigationElement) {
        SubmenuNavigationElement submenu = (SubmenuNavigationElement) element;
        MenuBar.MenuItem submenuItem = menuBar.addItem(submenu.getTitle(), submenu.getIcon(), null);
        submenu.getSubmenuElements().forEach(element1 -> {
            addToMenuBar(submenuItem, element1);
        });
    }
    if (element instanceof NavigatorNavigationElement) {
        NavigatorNavigationElement submenu = (NavigatorNavigationElement) element;
        menuBar.addItem(submenu.getCaption(), submenu.getIcon(), menuItem -> UI.getCurrent().getNavigator().navigateTo(submenu.getViewName()));
    }
    if (element instanceof ClickableNavigationElement) {
        ClickableNavigationElement submenu = (ClickableNavigationElement) element;
        menuBar.addItem(submenu.getName(), submenu.getIcon(), menuItem -> submenu.getListener().buttonClick(null));
    }
}
Also used : NavigatorNavigationElement(com.github.appreciated.app.layout.builder.elements.NavigatorNavigationElement) ClickableNavigationElement(com.github.appreciated.app.layout.builder.elements.ClickableNavigationElement) SubmenuNavigationElement(com.github.appreciated.app.layout.builder.elements.SubmenuNavigationElement) MenuBar(com.vaadin.ui.MenuBar)

Example 3 with SubmenuNavigationElement

use of com.github.appreciated.app.layout.builder.elements.SubmenuNavigationElement in project vaadin-app-layout by appreciated.

the class DefaultTopSubmenuNavigationElementFactory method addToMenuBar.

private void addToMenuBar(MenuBar.MenuItem menuBar, AbstractNavigationElement element) {
    if (element instanceof SubmenuNavigationElement) {
        SubmenuNavigationElement submenu = (SubmenuNavigationElement) element;
        MenuBar.MenuItem submenuItem = menuBar.addItem(submenu.getTitle(), submenu.getIcon(), null);
        submenu.getSubmenuElements().forEach(element1 -> {
            addToMenuBar(submenuItem, element1);
        });
    }
    if (element instanceof NavigatorNavigationElement) {
        NavigatorNavigationElement submenu = (NavigatorNavigationElement) element;
        menuBar.addItem(submenu.getCaption(), submenu.getIcon(), menuItem -> UI.getCurrent().getNavigator().navigateTo(submenu.getViewName()));
    }
    if (element instanceof ClickableNavigationElement) {
        ClickableNavigationElement submenu = (ClickableNavigationElement) element;
        menuBar.addItem(submenu.getName(), submenu.getIcon(), menuItem -> submenu.getListener().buttonClick(null));
    }
}
Also used : NavigatorNavigationElement(com.github.appreciated.app.layout.builder.elements.NavigatorNavigationElement) ClickableNavigationElement(com.github.appreciated.app.layout.builder.elements.ClickableNavigationElement) SubmenuNavigationElement(com.github.appreciated.app.layout.builder.elements.SubmenuNavigationElement) MenuBar(com.vaadin.ui.MenuBar)

Aggregations

NavigatorNavigationElement (com.github.appreciated.app.layout.builder.elements.NavigatorNavigationElement)3 SubmenuNavigationElement (com.github.appreciated.app.layout.builder.elements.SubmenuNavigationElement)3 ClickableNavigationElement (com.github.appreciated.app.layout.builder.elements.ClickableNavigationElement)2 MenuBar (com.vaadin.ui.MenuBar)2 AppLayoutComponent (com.github.appreciated.app.layout.behaviour.AppLayoutComponent)1 Behaviour (com.github.appreciated.app.layout.behaviour.Behaviour)1 AppLayoutDesign (com.github.appreciated.app.layout.builder.design.AppLayoutDesign)1 AbstractNavigationElement (com.github.appreciated.app.layout.builder.elements.AbstractNavigationElement)1 SectionNavigationElement (com.github.appreciated.app.layout.builder.elements.SectionNavigationElement)1 NavigationElementInfo (com.github.appreciated.app.layout.builder.entities.NavigationElementInfo)1 DefaultLeftClickableNavigationElementFactory (com.github.appreciated.app.layout.builder.factories.left.DefaultLeftClickableNavigationElementFactory)1 DefaultLeftNavigationBadgeElementComponentFactory (com.github.appreciated.app.layout.builder.factories.left.DefaultLeftNavigationBadgeElementComponentFactory)1 DefaultLeftSectionElementComponentFactory (com.github.appreciated.app.layout.builder.factories.left.DefaultLeftSectionElementComponentFactory)1 DefaultLeftSubmenuNavigationElementFactory (com.github.appreciated.app.layout.builder.factories.left.DefaultLeftSubmenuNavigationElementFactory)1 DefaultTopSubmenuNavigationElementFactory (com.github.appreciated.app.layout.builder.factories.top.DefaultTopSubmenuNavigationElementFactory)1 ComponentFactory (com.github.appreciated.app.layout.builder.interfaces.ComponentFactory)1 Factory (com.github.appreciated.app.layout.builder.interfaces.Factory)1 HasCaptionInterceptor (com.github.appreciated.app.layout.builder.interfaces.HasCaptionInterceptor)1 NavigationElementComponent (com.github.appreciated.app.layout.builder.interfaces.NavigationElementComponent)1 ComponentNavigator (com.github.appreciated.app.layout.navigator.ComponentNavigator)1