Example usage for com.vaadin.ui MenuBar setHeight

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

Introduction

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

Prototype

@Override
    public void setHeight(float height, Unit unit) 

Source Link

Usage

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 w  ww  .j  a v a2 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);
    }
}