Example usage for com.vaadin.ui MenuBar addStyleName

List of usage examples for com.vaadin.ui MenuBar addStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui MenuBar addStyleName.

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:fr.amapj.view.engine.menu.MenuPart.java

License:Open Source License

private CssLayout buildMenu(CssLayout menu, CssLayout menuItemsLayout, List<MenuDescription> allMenus,
        Navigator navigator, AmapUI ui) {

    final HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName("valo-menu-title");
    menu.addComponent(top);//from ww  w .  j a  va  2s. c o  m

    final Button showMenu = new Button("Menu", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            if (menu.getStyleName().contains("valo-menu-visible")) {
                menu.removeStyleName("valo-menu-visible");
            } else {
                menu.addStyleName("valo-menu-visible");
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName("valo-menu-toggle");
    showMenu.setIcon(FontAwesome.LIST);
    menu.addComponent(showMenu);

    String nomAmap = new ParametresService().getParametres().nomAmap;
    Label title = new Label("<h2>" + nomAmap + "</h2>", ContentMode.HTML);
    title.setSizeUndefined();
    top.addComponent(title);
    top.setExpandRatio(title, 1);

    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");

    SessionParameters p = SessionManager.getSessionParameters();
    MenuItem settingsItem = settings.addItem(p.userPrenom + " " + p.userNom, null, null);
    settingsItem.addItem("Se dconnecter", new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            new PasswordManager().disconnect();
            ui.buildLoginView(null, null, null);
        }
    });

    menu.addComponent(settings);

    menuItemsLayout.setPrimaryStyleName("valo-menuitems");
    menu.addComponent(menuItemsLayout);

    boolean first = true;
    String firstEntry = null;
    Button firstButton = null;

    for (MenuDescription menuDescription : allMenus) {
        final String view = menuDescription.getMenuName().name().toLowerCase();
        final String titleView = menuDescription.getMenuName().getTitle();

        if (menuDescription.getCategorie() != null) {
            Label l = new Label(menuDescription.getCategorie(), ContentMode.HTML);
            l.setPrimaryStyleName("valo-menu-subtitle");
            l.addStyleName("h4");
            l.setSizeUndefined();
            menuItemsLayout.addComponent(l);
        }

        final Button b = new Button(titleView, new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                setSelected(event.getButton(), menuItemsLayout);
                navigator.navigateTo("/" + view);
            }
        });

        b.setId("amapj.menu." + view);
        b.setHtmlContentAllowed(true);
        b.setPrimaryStyleName("valo-menu-item");
        b.setIcon(menuDescription.getMenuName().getFont());
        menuItemsLayout.addComponent(b);

        viewNameToMenuButton.put("/" + view, b);

        if (first) {
            first = false;
            firstButton = b;
            firstEntry = view;
        }
    }

    // Gestion de l'url
    String f = Page.getCurrent().getUriFragment();
    if (f != null && f.startsWith("!")) {
        f = f.substring(1);
    }
    if (f == null || f.equals("") || f.equals("/")) {
        navigateWithProtect(navigator, "/" + firstEntry);
        setSelected(firstButton, menuItemsLayout);
    } else {
        navigateWithProtect(navigator, f);
        setSelected(viewNameToMenuButton.get(f), menuItemsLayout);
    }

    return menu;
}

From source file:it.vige.greenarea.bpm.custom.ui.mainlayout.GreenareaMainMenuBar.java

License:Apache License

protected void initProfileButton() {

    if (useProfile()) {
        final LoggedInUser user = get().getLoggedInUser();

        // User name + link to profile
        MenuBar profileMenu = new MenuBar();
        UserConverter userConverter = new UserConverter();
        List<Group> groups = get().getLoggedInUser().getGroups();
        if (userConverter.isUserInGroup(groups, OPERATORE_LOGISTICO))
            profileMenu.addStyleName(STYLE_OPERATORE_LOGISTICO_HEADER_PROFILE_BOX);
        else if (userConverter.isUserInGroup(groups, SOCIETA_DI_TRASPORTO))
            profileMenu.addStyleName(STYLE_SOCIETA_DI_TRASPORTO_HEADER_PROFILE_BOX);
        else if (userConverter.isUserInGroup(groups, TRASPORTATORE_AUTONOMO))
            profileMenu.addStyleName(STYLE_SOCIETA_DI_TRASPORTO_HEADER_PROFILE_BOX);
        else/*from www  . j  a v  a  2 s. c o m*/
            profileMenu.addStyleName(STYLE_PA_HEADER_PROFILE_BOX);
        profileMenu.setHeight(14, UNITS_PIXELS);
        MenuItem rootItem = profileMenu.addItem(user.getFirstName() + " " + user.getLastName(), null);
        rootItem.setStyleName(STYLE_HEADER_PROFILE_MENU);

        // Show profile
        rootItem.addItem(i18nManager.getMessage(PROFILE_SHOW), new Command() {
            private static final long serialVersionUID = 8748698561304992624L;

            public void menuSelected(MenuItem selectedItem) {
                get().getViewManager().showProfilePopup(user.getId());
            }
        });

        // Edit profile
        rootItem.addItem(i18nManager.getMessage(PROFILE_EDIT), new Command() {
            private static final long serialVersionUID = -5815196339877745007L;

            public void menuSelected(MenuItem selectedItem) {
                // TODO: Show in edit-mode
                get().getViewManager().showProfilePopup(user.getId());
            }
        });

        // Change password
        rootItem.addItem(i18nManager.getMessage(PASSWORD_CHANGE), new Command() {
            private static final long serialVersionUID = -1060329084309607294L;

            public void menuSelected(MenuItem selectedItem) {
                get().getViewManager().showPopupWindow(new ChangePasswordPopupWindow());
            }
        });

        rootItem.addSeparator();

        // Logout
        rootItem.addItem(i18nManager.getMessage(HEADER_LOGOUT), new Command() {
            private static final long serialVersionUID = 1221427524106192724L;

            public void menuSelected(MenuItem selectedItem) {
                get().close();
            }
        });

        addComponent(profileMenu);
        // header.setComponentAlignment(profileMenu, TOP_RIGHT);
    }
}

From source file:lv.polarisit.demosidemenu.ValoThemeUI.java

License:Apache License

CssLayout buildMenu() {
    // Add items/*from ww w  . j  av a2 s.  c  om*/
    menuItems.put("MessageView", "First Message");
    menuItems.put("MessageView1", "Second Message");
    /*
    menuItems.put("labels", "Labels");
    menuItems.put("buttons-and-links", "Buttons & Links");
    menuItems.put("textfields", "Text Fields");
    menuItems.put("datefields", "Date Fields");
    menuItems.put("comboboxes", "Combo Boxes");
    menuItems.put("selects", "Selects");
    menuItems.put("checkboxes", "Check Boxes & Option Groups");
    menuItems.put("sliders", "Sliders & Progress Bars");
    menuItems.put("colorpickers", "Color Pickers");
    menuItems.put("menubars", "Menu Bars");
    menuItems.put("trees", "Trees");
    menuItems.put("tables", "Tables");
    menuItems.put("dragging", "Drag and Drop");
    menuItems.put("panels", "Panels");
    menuItems.put("splitpanels", "Split Panels");
    menuItems.put("tabs", "Tabs");
    menuItems.put("accordions", "Accordions");
    menuItems.put("popupviews", "Popup Views");
    // menuItems.put("calendar", "Calendar");
    menuItems.put("forms", "Forms");
    */
    final HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName("valo-menu-title");
    menu.addComponent(top);
    menu.addComponent(createThemeSelect());

    final Button showMenu = new Button("Menu", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            if (menu.getStyleName().contains("valo-menu-visible")) {
                menu.removeStyleName("valo-menu-visible");
            } else {
                menu.addStyleName("valo-menu-visible");
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName("valo-menu-toggle");
    showMenu.setIcon(FontAwesome.LIST);
    menu.addComponent(showMenu);

    final Label title = new Label("<h3>Vaadin <strong>Valo Theme</strong></h3>", ContentMode.HTML);
    title.setSizeUndefined();
    top.addComponent(title);
    top.setExpandRatio(title, 1);

    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");
    /*
    final StringGenerator sg = new StringGenerator();
    final MenuItem settingsItem = settings.addItem(sg.nextString(true)
        + " " + sg.nextString(true) + sg.nextString(false),
        new ThemeResource("../tests-valo/img/profile-pic-300px.jpg"),
        null);
            
    settingsItem.addItem("Edit Profile", null);
    settingsItem.addItem("Preferences", null);
    settingsItem.addSeparator();
    settingsItem.addItem("Sign Out", null);
                */
    menu.addComponent(settings);

    menuItemsLayout.setPrimaryStyleName("valo-menuitems");
    menu.addComponent(menuItemsLayout);

    Label label = null;
    int count = -1;
    for (final Entry<String, String> item : menuItems.entrySet()) {
        if (item.getKey().equals("labels")) {
            label = new Label("Components", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        if (item.getKey().equals("panels")) {
            label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");
            count = 0;
            label = new Label("Containers", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        if (item.getKey().equals("forms")) {
            label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");
            count = 0;
            label = new Label("Other", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        final Button b = new Button(item.getValue(), new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                navigator.navigateTo(item.getKey());
            }
        });
        if (count == 2) {
            b.setCaption(b.getCaption() + " <span class=\"valo-menu-badge\">123</span>");
        }
        b.setHtmlContentAllowed(true);
        b.setPrimaryStyleName("valo-menu-item");
        //            b.setIcon(testIcon.get());
        menuItemsLayout.addComponent(b);
        count++;
    }
    if (label != null)
        label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");

    return menu;
}

From source file:me.uni.emuseo.view.menu.MenuView.java

License:Open Source License

private CssLayout buildMenu() {
    // Add items/*from   w ww .j  a  va  2  s .com*/
    if (authManager.isAuthorizedTo(Permissions.MENU_USERS_VIEW)) {
        menuItems.put(Permissions.MENU_USERS_VIEW, "Uytkownicy");
    }
    if (authManager.isAuthorizedTo(Permissions.MENU_EXHIBIT_VIEW)) {
        menuItems.put(Permissions.MENU_EXHIBIT_VIEW, "Katalog eksponatw");
    }
    if (authManager.isAuthorizedTo(Permissions.MENU_CATEGORIES_VIEW)) {
        menuItems.put(Permissions.MENU_CATEGORIES_VIEW, "Kategorie");
    }
    if (authManager.isAuthorizedTo(Permissions.MENU_RESOURCES_VIEW)) {
        menuItems.put(Permissions.MENU_RESOURCES_VIEW, "Zasoby");
    }

    final HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName("valo-menu-title");
    menu.addComponent(top);
    final Button showMenu = new Button("Menu", new ClickListener() {
        private static final long serialVersionUID = -719702284721453362L;

        @Override
        public void buttonClick(final ClickEvent event) {
            if (menu.getStyleName().contains("valo-menu-visible")) {
                menu.removeStyleName("valo-menu-visible");
            } else {
                menu.addStyleName("valo-menu-visible");
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName("valo-menu-toggle");
    showMenu.setIcon(FontAwesome.LIST);
    menu.addComponent(showMenu);
    final Label title = new Label("<h3>e<strong>Museo</strong></h3>", ContentMode.HTML);
    title.setSizeUndefined();
    top.addComponent(title);
    top.setExpandRatio(title, 1);
    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");

    settingsItem = settings.addItem("Jan Kowalski", defaultIcon, null);
    if (authManager.isAuthorizedTo(Permissions.MENU_MY_ACCOUNT_VIEW)) {
        settingsItem.addItem("Moje konto", new MenuBar.Command() {
            private static final long serialVersionUID = 7015035735144235104L;

            @Override
            public void menuSelected(MenuItem selectedItem) {
                navigator.navigateTo(Permissions.MENU_MY_ACCOUNT_VIEW);
            }

        });
    }
    if (authManager.isAuthorizedTo(Permissions.MENU_SETTINGS_VIEW)) {
        settingsItem.addItem("Ustawienia", new MenuBar.Command() {
            private static final long serialVersionUID = 7015035735144235105L;

            @Override
            public void menuSelected(MenuItem selectedItem) {
                navigator.navigateTo(Permissions.MENU_SETTINGS_VIEW);
            }

        });
    }
    settingsItem.addSeparator();
    settingsItem.addItem("Wyloguj", new MenuBar.Command() {
        private static final long serialVersionUID = 1333473616079310225L;

        @Override
        public void menuSelected(MenuItem selectedItem) {
            final AuthManager authManager = EMuseoUtil.getAppContext().getBean(AuthManager.class);
            authManager.logout();
        }
    });
    menu.addComponent(settings);
    menuItemsLayout.setPrimaryStyleName("valo-menuitems");
    menu.addComponent(menuItemsLayout);

    for (final Entry<String, String> item : menuItems.entrySet()) {
        FontIcon icon = null;
        if (item.getKey().equals(Permissions.MENU_USERS_VIEW)) {
            icon = FontAwesome.USERS;
        } else if (item.getKey().endsWith(Permissions.MENU_EXHIBIT_VIEW)) {
            icon = FontAwesome.UNIVERSITY;
        } else if (item.getKey().endsWith(Permissions.MENU_CATEGORIES_VIEW)) {
            icon = FontAwesome.ARCHIVE;
        } else if (item.getKey().endsWith(Permissions.MENU_RESOURCES_VIEW)) {
            icon = FontAwesome.IMAGE;
        }
        final Button b = new Button(item.getValue(), new ClickListener() {
            private static final long serialVersionUID = -7089398070311521853L;

            @Override
            public void buttonClick(final ClickEvent event) {
                navigator.navigateTo(item.getKey());
            }
        });
        b.setHtmlContentAllowed(true);
        b.setPrimaryStyleName("valo-menu-item");
        if (icon != null) {
            b.setIcon(icon);
        }
        menuItemsLayout.addComponent(b);
    }
    return menu;
}

From source file:org.activiti.explorer.ui.mainlayout.MainMenuBar.java

License:Apache License

protected void initProfileButton() {
    final LoggedInUser user = ExplorerApp.get().getLoggedInUser();

    // User name + link to profile 
    MenuBar profileMenu = new MenuBar();
    profileMenu.addStyleName(ExplorerLayout.STYLE_HEADER_PROFILE_BOX);
    MenuItem rootItem = profileMenu.addItem(user.getFirstName() + " " + user.getLastName(), null);
    rootItem.setStyleName(ExplorerLayout.STYLE_HEADER_PROFILE_MENU);

    if (useProfile()) {
        // Show profile
        rootItem.addItem(i18nManager.getMessage(Messages.PROFILE_SHOW), new Command() {
            public void menuSelected(MenuItem selectedItem) {
                ExplorerApp.get().getViewManager().showProfilePopup(user.getId());
            }/*from  w  ww  .ja v  a2 s.  c  o  m*/
        });

        // Edit profile
        rootItem.addItem(i18nManager.getMessage(Messages.PROFILE_EDIT), new Command() {

            public void menuSelected(MenuItem selectedItem) {
                // TODO: Show in edit-mode
                ExplorerApp.get().getViewManager().showProfilePopup(user.getId());
            }
        });

        // Change password
        rootItem.addItem(i18nManager.getMessage(Messages.PASSWORD_CHANGE), new Command() {
            public void menuSelected(MenuItem selectedItem) {
                ExplorerApp.get().getViewManager().showPopupWindow(new ChangePasswordPopupWindow());
            }
        });

        rootItem.addSeparator();
    }

    // Logout
    rootItem.addItem(i18nManager.getMessage(Messages.HEADER_LOGOUT), new Command() {
        public void menuSelected(MenuItem selectedItem) {
            ExplorerApp.get().close();
        }
    });

    addComponent(profileMenu);
    setComponentAlignment(profileMenu, Alignment.TOP_RIGHT);
    setExpandRatio(profileMenu, 1.0f);
}

From source file:org.activiti.explorer.ui.MainMenuBar.java

License:Apache License

protected void initProfileButton() {
    final LoggedInUser user = ExplorerApp.get().getLoggedInUser();

    // User name + link to profile 
    MenuBar profileMenu = new MenuBar();
    profileMenu.addStyleName(ExplorerLayout.STYLE_HEADER_PROFILE_BOX);
    MenuItem rootItem = profileMenu.addItem(user.getFirstName() + " " + user.getLastName(), null);
    rootItem.setStyleName(ExplorerLayout.STYLE_HEADER_PROFILE_MENU);

    // Show profile
    rootItem.addItem(i18nManager.getMessage(Messages.PROFILE_SHOW), new Command() {
        public void menuSelected(MenuItem selectedItem) {
            ExplorerApp.get().getViewManager().showProfilePopup(user.getId());
        }/* w  w  w . j  a va  2  s.c o m*/
    });

    // Edit profile
    rootItem.addItem(i18nManager.getMessage(Messages.PROFILE_EDIT), new Command() {

        public void menuSelected(MenuItem selectedItem) {
            // TODO: Show in edit-mode
            ExplorerApp.get().getViewManager().showProfilePopup(user.getId());
        }
    });

    // Change password
    rootItem.addItem(i18nManager.getMessage(Messages.PASSWORD_CHANGE), new Command() {
        public void menuSelected(MenuItem selectedItem) {
            ExplorerApp.get().getViewManager().showPopupWindow(new ChangePasswordPopupWindow());
        }
    });

    rootItem.addSeparator();
    // Logout
    rootItem.addItem(i18nManager.getMessage(Messages.HEADER_LOGOUT), new Command() {
        public void menuSelected(MenuItem selectedItem) {
            ExplorerApp.get().close();
        }
    });

    addComponent(profileMenu);
    setComponentAlignment(profileMenu, Alignment.TOP_RIGHT);
    setExpandRatio(profileMenu, 1.0f);
}

From source file:org.bubblecloud.ilves.site.view.valo.DefaultValoView.java

License:Apache License

private CssLayout buildMenu() {

    final HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setWidth("100%");
    topLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    topLayout.addStyleName("valo-menu-title");
    menu.addComponent(topLayout);/*  w  w w. j  av  a 2 s  .  com*/

    final Button showMenu = new Button("Menu", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (menu.getStyleName().contains("valo-menu-visible")) {
                menu.removeStyleName("valo-menu-visible");
            } else {
                menu.addStyleName("valo-menu-visible");
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName("valo-menu-toggle");
    showMenu.setIcon(FontAwesome.LIST);
    menu.addComponent(showMenu);

    final Label title = new Label("<h3>" + Site.getCurrent().localize(getViewVersion().getTitle()) + "</h3>",
            ContentMode.HTML);
    title.setSizeUndefined();
    topLayout.addComponent(title);
    topLayout.setExpandRatio(title, 1);

    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");

    final String user = Site.getCurrent().getSecurityProvider().getUser();
    final String userMenuCaption;
    final Resource userMenuIcon;
    if (user == null) {
        userMenuCaption = Site.getCurrent().localize("page-link-login");
        userMenuIcon = new ThemeResource("ilves_logo.png");
    } else {
        final URL gravatarUrl = GravatarUtil.getGravatarUrl(user, 64);
        userMenuIcon = new ExternalResource(gravatarUrl);
        userMenuCaption = ((SecurityProviderSessionImpl) Site.getCurrent().getSecurityProvider())
                .getUserFromSession().getFirstName();
    }

    final MenuBar.MenuItem settingsItem = settings.addItem(userMenuCaption, userMenuIcon, null);
    if (user != null) {
        settingsItem.addItem(Site.getCurrent().localize("page-link-account"), new MenuBar.Command() {
            @Override
            public void menuSelected(MenuBar.MenuItem selectedItem) {
                UI.getCurrent().getNavigator().navigateTo("account");
            }
        });
        settingsItem.addSeparator();
        settingsItem.addItem(Site.getCurrent().localize("button-logout"), new MenuBar.Command() {
            @Override
            public void menuSelected(MenuBar.MenuItem selectedItem) {
                LoginService.logout(Site.getCurrent().getSiteContext());
                final Company company = Site.getCurrent().getSiteContext().getObject(Company.class);
                getUI().getPage().setLocation(company.getUrl());
                getSession().getSession().invalidate();
                getSession().close();
            }
        });
    } else {
        settingsItem.addItem(Site.getCurrent().localize("page-link-login"), new MenuBar.Command() {
            @Override
            public void menuSelected(MenuBar.MenuItem selectedItem) {
                UI.getCurrent().getNavigator().navigateTo("login");
            }
        });
    }
    menu.addComponent(settings);

    menuItemsLayout.setPrimaryStyleName("valo-menuitems");
    menu.addComponent(menuItemsLayout);

    final Site site = Site.getCurrent();
    final NavigationVersion navigationVersion = site.getCurrentNavigationVersion();

    for (final String pageName : navigationVersion.getRootPages()) {
        final ViewVersion pageVersion = site.getCurrentViewVersion(pageName);
        if (pageVersion == null) {
            throw new SiteException("Unknown page: " + pageName);
        }
        if (pageVersion.getViewerRoles().length > 0) {
            boolean roleMatch = false;
            for (final String role : pageVersion.getViewerRoles()) {
                if (site.getSecurityProvider().getRoles().contains(role)) {
                    roleMatch = true;
                    break;
                }
            }
            if (!roleMatch) {
                continue;
            }
        }

        if (navigationVersion.hasChildPages(pageName)) {

            final String localizedPageName = pageVersion.isDynamic() ? pageName
                    : site.localize("page-link-" + pageName);

            final Label label = new Label(localizedPageName, ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);

            final List<String> childPages = navigationVersion.getChildPages(pageName);
            for (final String childPage : childPages) {
                addMenuLink(navigationVersion, childPage);
            }

            label.setValue(
                    label.getValue() + " <span class=\"valo-menu-badge\">" + childPages.size() + "</span>");
        } else {
            addMenuLink(navigationVersion, pageName);
        }
    }

    return menu;
}

From source file:org.eclipse.hawkbit.ui.menu.DashboardMenu.java

License:Open Source License

private Component buildUserMenu(final UiProperties uiProperties) {
    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");
    settings.setHtmlContentAllowed(true);

    final MenuItem settingsItem = settings.addItem("", getImage(uiProperties.isGravatar()), null);

    final String formattedTenant = UserDetailsFormatter.formatCurrentTenant();
    if (!StringUtils.isEmpty(formattedTenant)) {
        settingsItem.setText(formattedTenant);
        UserDetailsFormatter.getCurrentTenant()
                .ifPresent(tenant -> settingsItem.setDescription(i18n.getMessage("menu.user.description",
                        tenant, UserDetailsFormatter.getCurrentUser().getUsername())));
    } else {/* w  ww .  ja va  2 s .  c  om*/
        settingsItem.setText("...");
    }

    settingsItem.setStyleName("user-menuitem");

    final String logoutUrl = generateLogoutUrl();

    settingsItem.addItem(i18n.getMessage("label.sign.out"),
            selectedItem -> Page.getCurrent().setLocation(logoutUrl));
    return settings;
}

From source file:org.ikasan.dashboard.ui.framework.panel.LandingViewPanel.java

License:BSD License

private Component createContentWrapper(final Component content) {
    final CssLayout slot = new CssLayout();
    slot.setWidth("100%");
    slot.addStyleName("dashboard-panel-slot");

    CssLayout card = new CssLayout();
    card.setWidth("100%");
    card.addStyleName(ValoTheme.LAYOUT_CARD);

    HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addStyleName("dashboard-panel-toolbar");
    toolbar.setWidth("100%");

    Label caption = new Label(content.getCaption());
    caption.addStyleName(ValoTheme.LABEL_H4);
    caption.addStyleName(ValoTheme.LABEL_COLORED);
    caption.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    content.setCaption(null);//from   w  w w . ja  v a  2 s.  c  o m

    MenuBar tools = new MenuBar();
    tools.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    MenuItem max = tools.addItem("", VaadinIcons.EXPAND, new Command() {

        @Override
        public void menuSelected(final MenuItem selectedItem) {
            if (!slot.getStyleName().contains("max")) {
                selectedItem.setIcon(FontAwesome.COMPRESS);
                toggleMaximized(slot, true);
            } else {
                slot.removeStyleName("max");
                selectedItem.setIcon(FontAwesome.EXPAND);
                toggleMaximized(slot, false);
            }
        }
    });
    max.setStyleName("icon-only");
    MenuItem root = tools.addItem("", VaadinIcons.COG, null);
    root.addItem("Configure", new Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    });
    root.addSeparator();
    root.addItem("Close", new Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    });

    toolbar.addComponents(caption, tools);
    toolbar.setExpandRatio(caption, 1);
    toolbar.setComponentAlignment(caption, Alignment.MIDDLE_LEFT);

    card.addComponents(toolbar, content);
    slot.addComponent(card);
    return slot;
}

From source file:org.ikasan.dashboard.ui.monitor.component.MonitorPanel.java

License:BSD License

protected Component createContentWrapper(final Component small, final Component large) {
    final CssLayout slot = new CssLayout();
    slot.setWidth("100%");
    slot.addStyleName("monitor-panel-slot");

    final CssLayout card1 = new CssLayout();
    card1.setWidth("100%");
    card1.addStyleName(ValoTheme.LAYOUT_CARD);

    final CssLayout card2 = new CssLayout();
    card2.setWidth("100%");
    card2.addStyleName(ValoTheme.LAYOUT_CARD);

    final HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addStyleName("dashboard-panel-toolbar");
    toolbar.setWidth("100%");

    Label caption = new Label(large.getCaption());
    caption.addStyleName(ValoTheme.LABEL_H4);
    caption.addStyleName(ValoTheme.LABEL_COLORED);
    caption.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    large.setCaption(null);//from  ww w .j  a  v  a  2 s.  c o  m

    MenuBar tools = new MenuBar();
    tools.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    MenuItem max = tools.addItem("", VaadinIcons.EXPAND, new Command() {

        @Override
        public void menuSelected(final MenuItem selectedItem) {
            if (!slot.getStyleName().contains("max")) {
                selectedItem.setIcon(FontAwesome.COMPRESS);
                slot.removeAllComponents();
                card2.removeAllComponents();
                card2.addComponents(toolbar, large);
                slot.addComponents(card2);
                toggleMaximized(slot, true);
            } else {
                slot.removeStyleName("max");
                selectedItem.setIcon(FontAwesome.EXPAND);
                toggleMaximized(slot, false);
                card1.removeAllComponents();
                card1.addComponents(toolbar, small);
                slot.removeAllComponents();
                slot.addComponents(card1);
            }
        }
    });
    max.setStyleName("icon-only");
    MenuItem root = tools.addItem("", VaadinIcons.COG, null);
    root.addItem("Configure", new Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    });
    root.addSeparator();
    root.addItem("Close", new Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    });

    toolbar.addComponents(caption, tools);
    toolbar.setExpandRatio(caption, 1);
    toolbar.setComponentAlignment(caption, Alignment.MIDDLE_LEFT);

    card1.addComponents(toolbar, small);
    //        card2.addComponents(toolbar, large);
    slot.addComponent(card1);
    return slot;
}