Example usage for com.vaadin.ui Label setPrimaryStyleName

List of usage examples for com.vaadin.ui Label setPrimaryStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui Label setPrimaryStyleName.

Prototype

@Override
    public void setPrimaryStyleName(String style) 

Source Link

Usage

From source file:com.cavisson.gui.dashboard.components.controls.ValoThemeUI.java

License:Apache License

Component buildTestMenu() {
    final CssLayout menu = new CssLayout();
    menu.addStyleName("large-icons");

    final Label logo = new Label("Va");
    logo.setSizeUndefined();/*from  w w w .j ava 2s.c om*/
    logo.setPrimaryStyleName("valo-menu-logo");
    menu.addComponent(logo);

    Button b = new Button("Reference <span class=\"valo-menu-badge\">3</span>");
    b.setIcon(FontAwesome.TH_LIST);
    b.setPrimaryStyleName("valo-menu-item");
    b.addStyleName("selected");
    b.setHtmlContentAllowed(true);
    menu.addComponent(b);

    b = new Button("API");
    b.setIcon(FontAwesome.BOOK);
    b.setPrimaryStyleName("valo-menu-item");
    menu.addComponent(b);

    b = new Button("Examples <span class=\"valo-menu-badge\">12</span>");
    b.setIcon(FontAwesome.TABLE);
    b.setPrimaryStyleName("valo-menu-item");
    b.setHtmlContentAllowed(true);
    menu.addComponent(b);

    return menu;
}

From source file:com.cavisson.gui.dashboard.components.controls.ValoThemeUI.java

License:Apache License

CssLayout buildMenu() {
    // Add items/*  ww w. ja  v a2s.  c om*/
    menuItems.put("common", "Common UI Elements");
    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++;
    }
    label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");

    return menu;
}

From source file:com.selzlein.lojavirtual.vaadin.core.NavigationMenu.java

License:Open Source License

/**
 * Adds menu separator item.//from w  w w  .  ja  va2s  .  c  om
 * Possible to add number badge for this item for showing active to-dos for example.
 * 
 * @param titleKey
 * @param badgeValue number that will appear in upper right corner of menu item
 */
public void addMenuSeparator(String titleKey, Integer badgeValue) {
    Label label = new Label(ui.getMessage(titleKey), ContentMode.HTML);
    if (badgeValue != null) {
        label.setValue(label.getValue() + "<span class=\"valo-menu-badge\">" + badgeValue + "</span>");
    }
    label.setPrimaryStyleName("valo-menu-subtitle");
    label.addStyleName("h4");
    label.setSizeUndefined();
    mainMenu.addComponent(label);
}

From source file:com.wintindustries.pfserver.interfaces.view.dashboard.DashboardMenu.java

private Component buildFolderTree() {

    CssLayout treeLayout = new CssLayout();
    treeLayout.setWidth("100%");
    if (treeLayout.getComponentCount() > 0) {
        treeLayout.removeAllComponents();
    }//www  .j  a v  a 2 s .  c o m

    System.out.println("Init Dataasource");

    for (PFDataSource source : PFCore.core.getDataSources()) {
        System.out.println("NEW TREE");

        Label label = new Label(source.getName(), ContentMode.HTML);
        label.setPrimaryStyleName("valo-menu-subtitle");
        label.addStyleName("h4");

        label.setSizeUndefined();
        treeLayout.addComponent(label);
        //      label.setIcon(FontAwesome.LAPTOP);
        treeLayout.addStyleName("valo-menuitems");

        Tree tree = new Tree();
        //tree.setIcon(FontAwesome.LAPTOP);
        // tree.setWidth("100%");

        // container.setItemSorter(new l);

        source.Session().OpenSession();
        source.Session().getSession().beginTransaction();
        source.Session().getSession().getTransaction().setTimeout(4);

        System.out.println(": " + source.getDatabase().getSessionManager());

        Set<PFFolder> rootFolders = PFLocation.getRootDirectoriesFromDatabase(source.getDatabase());

        System.out.println(": " + source.getDatabase().getSessionManager());

        final PFFolderProxyContainer container = new PFFolderProxyContainer(rootFolders, source);

        container.setSortAlphabetic(true);
        tree.setContainerDataSource(container);
        tree.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
        tree.setItemCaptionPropertyId("Name");
        tree.setItemIconPropertyId("Icon");

        ItemClickListener treeclick;
        treeclick = new ItemClickListener() {

            @Override
            public void itemClick(final ItemClickEvent event) {

                //  Notification note = new Notification("Notificaton", event.getItemId().toString(), Notification.Type.ERROR_MESSAGE);
                // note.show(Page.getCurrent());
                PFFolderProxy proxyFolder = (PFFolderProxy) event.getItemId();
                MyUI.getPFNavigator().navigateTo(MyUI.PAGE_FOLDERVIEW + "/" + proxyFolder.getIdentifier());
            }
        };

        tree.addItemClickListener(treeclick);

        // Allow all nodes to have children
        //   .dashboard-menu-folder-wrapper
        // all these wrappers are a hacky workaround to a Vaadin CSS glitch
        CssLayout treeWrapper = new CssLayout();
        treeWrapper.setStyleName(".dashboard-menu-folder-wrapper");
        treeWrapper.addComponent(tree);
        treeWrapper.setWidth("40px");
        tree.setWidth("800px");
        tree.setStyleName(".dashboard-menu-folder-tree");

        treeLayout.addComponent(treeWrapper);
        source.Session().getSession().getTransaction().commit();
        source.getDatabase().getSessionManager().CloseSession();
    }

    return treeLayout;

}

From source file:de.metas.ui.web.vaadin.window.view.WindowRecordIndicators.java

License:Open Source License

private Component createIndicatorComp(final String label, final String color) {
    final String indicatorId = STYLE_Indicator + "-" + (nextIndicatorId++);

    final Label comp = new Label();
    comp.setId(indicatorId);/*ww  w.jav  a 2s  .com*/
    comp.setPrimaryStyleName(STYLE_Indicator);
    comp.setValue(label);

    indicatorId2color.put(indicatorId, color);

    return comp;
}

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 www.  j  a  va 2  s.  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:io.mateu.ui.vaadin.framework.MyUI.java

License:Apache License

/**
 * crea el men pa un rea concreta//www  .  j av a2s.c  o m
 *
 * @param a
 */
private void buildMenuOptions(AbstractArea a) {

    Label label = null;

    // recger la opcin de men selecionada de la url
    String s = navigator.getState();
    System.out.println("state=" + s);

    for (AbstractModule m : a.getModules()) {

        label = new Label(m.getName(), ContentMode.HTML);
        label.setPrimaryStyleName(ValoTheme.MENU_SUBTITLE);
        label.addStyleName(ValoTheme.LABEL_H4);
        label.setSizeUndefined();
        menuItemsLayout.addComponent(label);

        for (MenuEntry e : m.getMenu()) {

            addMenu(a, e);

        }
    }
}

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

License:Apache License

CssLayout buildMenu() {
    // Add items//  w ww  .j a  v  a2 s  .  c  o m
    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: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);/*from  ww  w  .j  a  v  a  2s. c  o  m*/

    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.ikasan.dashboard.ui.Menu.java

License:BSD License

protected void buildMenu() {
    menuItemsLayout.setPrimaryStyleName("valo-menuitems");
    this.addComponent(menuItemsLayout);

    Label label = null;

    label = new Label("General", ContentMode.HTML);
    label.setPrimaryStyleName("valo-menu-subtitle");
    label.addStyleName("h4");
    label.setSizeUndefined();//from ww  w  .  ja va 2  s .c  o  m
    menuItemsLayout.addComponent(label);

    final Button dashboardMenuItem = new Button("Dashboard", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            loadTopLevelNavigator();
            UI.getCurrent().getNavigator().navigateTo("landingView");
        }
    });

    dashboardMenuItem.setHtmlContentAllowed(true);
    dashboardMenuItem.setPrimaryStyleName("valo-menu-item");
    dashboardMenuItem.setIcon(VaadinIcons.DASHBOARD);
    menuItemsLayout.addComponent(dashboardMenuItem);

    label = null;

    final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
            .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

    if (authentication != null && (authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)
            || authentication.hasGrantedAuthority(SecurityConstants.VIEW_TOPOLOGY_AUTHORITY)
            || authentication.hasGrantedAuthority(SecurityConstants.VIEW_MAPPING_AUTHORITY))) {
        label = new Label("Services", ContentMode.HTML);
        label.setPrimaryStyleName("valo-menu-subtitle");
        label.addStyleName("h4");
        label.setSizeUndefined();
        menuItemsLayout.addComponent(label);
    }

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

    this.menuComponents.put(label, SecurityConstants.ALL_AUTHORITY);
    this.menuComponents.put(label, SecurityConstants.VIEW_TOPOLOGY_AUTHORITY);
    this.menuComponents.put(label, SecurityConstants.VIEW_MAPPING_AUTHORITY);

    final Button topologyMenuItem = new Button("Topology", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            loadTopLevelNavigator();
            UI.getCurrent().getNavigator().navigateTo("topologyView");
        }
    });

    topologyMenuItem.setHtmlContentAllowed(true);
    topologyMenuItem.setPrimaryStyleName("valo-menu-item");
    topologyMenuItem.setIcon(VaadinIcons.CONNECT_O);
    menuItemsLayout.addComponent(topologyMenuItem);
    this.menuComponents.put(topologyMenuItem, SecurityConstants.VIEW_TOPOLOGY_AUTHORITY);

    final Button mappingMenuItem = new Button("Mapping", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            loadTopLevelNavigator();
            UI.getCurrent().getNavigator().navigateTo("mappingView");

            loadNavigator("mapping");
        }
    });

    mappingMenuItem.setHtmlContentAllowed(true);
    mappingMenuItem.setPrimaryStyleName("valo-menu-item");
    mappingMenuItem.setIcon(VaadinIcons.COPY_O);
    menuItemsLayout.addComponent(mappingMenuItem);
    this.menuComponents.put(mappingMenuItem, SecurityConstants.VIEW_MAPPING_AUTHORITY);

    final Button monitoringMenuItem = new Button("Monitoring", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            loadTopLevelNavigator();
            UI.getCurrent().getNavigator().navigateTo("monitorView");
        }
    });

    monitoringMenuItem.setHtmlContentAllowed(true);
    monitoringMenuItem.setPrimaryStyleName("valo-menu-item");
    monitoringMenuItem.setIcon(VaadinIcons.DESKTOP);
    menuItemsLayout.addComponent(monitoringMenuItem);
    this.menuComponents.put(monitoringMenuItem, SecurityConstants.VIEW_MONITORING_AUTHORITY);

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

    this.menuComponents.put(label, SecurityConstants.ALL_AUTHORITY);

    final Button usersItem = new Button("Users", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            loadTopLevelNavigator();
            UI.getCurrent().getNavigator().navigateTo("userPanel");
        }
    });

    usersItem.setHtmlContentAllowed(true);
    usersItem.setPrimaryStyleName("valo-menu-item");
    usersItem.setIcon(VaadinIcons.USER);
    menuItemsLayout.addComponent(usersItem);

    this.menuComponents.put(usersItem, SecurityConstants.ALL_AUTHORITY);

    final Button groupsItem = new Button("Groups", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            loadTopLevelNavigator();
            UI.getCurrent().getNavigator().navigateTo("principalManagementPanel");
        }
    });

    groupsItem.setHtmlContentAllowed(true);
    groupsItem.setPrimaryStyleName("valo-menu-item");
    groupsItem.setIcon(VaadinIcons.USERS);
    menuItemsLayout.addComponent(groupsItem);

    this.menuComponents.put(groupsItem, SecurityConstants.ALL_AUTHORITY);

    final Button rolesItem = new Button("Roles", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            loadTopLevelNavigator();
            UI.getCurrent().getNavigator().navigateTo("roleManagementPanel");
        }
    });

    rolesItem.setHtmlContentAllowed(true);
    rolesItem.setPrimaryStyleName("valo-menu-item");
    rolesItem.setIcon(VaadinIcons.SPECIALIST);
    menuItemsLayout.addComponent(rolesItem);

    this.menuComponents.put(rolesItem, SecurityConstants.ALL_AUTHORITY);

    final Button policyItem = new Button("Policies", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            loadTopLevelNavigator();
            UI.getCurrent().getNavigator().navigateTo("policyManagementPanel");
        }
    });

    policyItem.setHtmlContentAllowed(true);
    policyItem.setPrimaryStyleName("valo-menu-item");
    policyItem.setIcon(VaadinIcons.SAFE);
    menuItemsLayout.addComponent(policyItem);

    this.menuComponents.put(policyItem, SecurityConstants.ALL_AUTHORITY);

    final Button authItem = new Button("User Directories", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            loadTopLevelNavigator();
            UI.getCurrent().getNavigator().navigateTo("authenticationMethodView");
        }
    });

    authItem.setHtmlContentAllowed(true);
    authItem.setPrimaryStyleName("valo-menu-item");
    authItem.setIcon(VaadinIcons.COG);
    menuItemsLayout.addComponent(authItem);

    this.menuComponents.put(authItem, SecurityConstants.ALL_AUTHORITY);

    final Button platformConfigItem = new Button("Platform Configuration", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            loadTopLevelNavigator();
            UI.getCurrent().getNavigator().navigateTo("platformConfigurationView");
        }
    });

    platformConfigItem.setHtmlContentAllowed(true);
    platformConfigItem.setPrimaryStyleName("valo-menu-item");
    platformConfigItem.setIcon(VaadinIcons.LIST);
    menuItemsLayout.addComponent(platformConfigItem);

    this.menuComponents.put(platformConfigItem, SecurityConstants.ALL_AUTHORITY);

}