Example usage for com.vaadin.server FontAwesome UNIVERSITY

List of usage examples for com.vaadin.server FontAwesome UNIVERSITY

Introduction

In this page you can find the example usage for com.vaadin.server FontAwesome UNIVERSITY.

Prototype

FontAwesome UNIVERSITY

To view the source code for com.vaadin.server FontAwesome UNIVERSITY.

Click Source Link

Usage

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  2s.c o m*/
    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;
}