List of usage examples for com.vaadin.ui MenuBar addItem
public MenuBar.MenuItem addItem(String caption, Resource icon, MenuBar.Command command)
From source file:com.lst.deploymentautomation.vaadin.page.TodoView.java
License:Open Source License
@SuppressWarnings("serial") @Override//from w w w. j a v a 2s . co m protected Component createHeader(Component titleComponent) { LspsUI ui = (LspsUI) getUI(); MenuBar menu = new MenuBar(); menu.addStyleName("menu-button-action"); MenuItem actions = menu.addItem("", new ThemeResource("../icons/popup-menu.png"), null); final ViewAction closeView = new ViewAction() { @Override public void invoke() { close(); //maybe close only if the to-do is not allocated to the user anymore } }; final ViewAction refreshAnnotations = new ViewAction() { @Override public void invoke() { Todo todo = todoService.getTodo(todoHolder.getTodo().getId()); refreshAnnotations(todo); } }; actions.addItem(ui.getMessage("action.info"), new Command() { @Override public void menuSelected(MenuItem selectedItem) { //get fresh info Todo todo = todoService.getTodo(todoHolder.getTodo().getId()); getUI().addWindow(new TodoDetails(todo)); } }); actions.addSeparator(); actions.addItem(ui.getMessage("action.annotate") + "...", new Command() { @Override public void menuSelected(MenuItem selectedItem) { //get fresh info Todo todo = todoService.getTodo(todoHolder.getTodo().getId()); getUI().addWindow(new TodoAnnotation(todo, refreshAnnotations)); } }); actions.addSeparator(); actions.addItem(ui.getMessage("action.unlock"), new Command() { @Override public void menuSelected(MenuItem selectedItem) { unlock(); } }); actions.addItem(ui.getMessage("action.reject") + "...", new Command() { @Override public void menuSelected(MenuItem selectedItem) { getUI().addWindow(new TodoRejection(todoHolder.getTodo().getId(), closeView)); } }); actions.addItem(ui.getMessage("action.delegate") + "...", new Command() { @Override public void menuSelected(MenuItem selectedItem) { getUI().addWindow(new TodoDelegation(todoHolder.getTodo().getId(), closeView)); } }); actions.addItem(ui.getMessage("action.escalate") + "...", new Command() { @Override public void menuSelected(MenuItem selectedItem) { getUI().addWindow(new TodoEscalation(todoHolder.getTodo().getId(), closeView)); } }); HorizontalLayout layout = new HorizontalLayout(); layout.setWidth("100%"); layout.addComponent(titleComponent); layout.setExpandRatio(titleComponent, 1); layout.addComponent(menu); layout.setComponentAlignment(menu, Alignment.MIDDLE_RIGHT); return layout; }
From source file:com.mcparland.john.vaadin_mvn_arch.samples.Menu.java
License:Apache License
public Menu(Navigator navigator) { this.navigator = navigator; setPrimaryStyleName(ValoTheme.MENU_ROOT); menuPart = new CssLayout(); menuPart.addStyleName(ValoTheme.MENU_PART); // header of the menu final HorizontalLayout top = new HorizontalLayout(); top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); top.addStyleName(ValoTheme.MENU_TITLE); top.setSpacing(true);//from w w w.j a v a2 s . c om Label title = new Label("My CRUD"); title.addStyleName(ValoTheme.LABEL_H3); title.setSizeUndefined(); Image image = new Image(null, new ThemeResource("img/table-logo.png")); image.setStyleName("logo"); top.addComponent(image); top.addComponent(title); menuPart.addComponent(top); // logout menu item MenuBar logoutMenu = new MenuBar(); logoutMenu.addItem("Logout", FontAwesome.SIGN_OUT, new Command() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void menuSelected(MenuItem selectedItem) { VaadinSession.getCurrent().getSession().invalidate(); Page.getCurrent().reload(); } }); logoutMenu.addStyleName("user-menu"); menuPart.addComponent(logoutMenu); // button for toggling the visibility of the menu when on a small screen final Button showMenu = new Button("Menu", new ClickListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) { menuPart.removeStyleName(VALO_MENU_VISIBLE); } else { menuPart.addStyleName(VALO_MENU_VISIBLE); } } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); showMenu.addStyleName(ValoTheme.BUTTON_SMALL); showMenu.addStyleName(VALO_MENU_TOGGLE); showMenu.setIcon(FontAwesome.NAVICON); menuPart.addComponent(showMenu); // container for the navigation buttons, which are added by addView() menuItemsLayout = new CssLayout(); menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS); menuPart.addComponent(menuItemsLayout); addComponent(menuPart); }
From source file:com.selzlein.lojavirtual.vaadin.core.NavigationMenu.java
License:Open Source License
private void buildUserMenu() { Command logoutCmd = new Command() { private static final long serialVersionUID = 1L; @Override/* w w w. ja va 2 s . c om*/ public void menuSelected(MenuItem selectedItem) { ui.logout(); } }; Command settingsCmd = new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(MenuItem selectedItem) { ui.navigateTo(SettingsView.ID); } }; Command mobileMenu = new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(MenuItem selectedItem) { removeMenuStyles(); ui.addStyleName(MENU_MOBILE); user.setSetting("l-menu", MENU_MOBILE); mobileMenuStyleItem.setStyleName("l-hidden"); } }; Command tabletMenu = new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(MenuItem selectedItem) { removeMenuStyles(); ui.addStyleName(MENU_TABLET); user.setSetting("l-menu", MENU_TABLET); tabletMenuStyleItem.setStyleName("l-hidden"); } }; Command desktopMenu = new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(MenuItem selectedItem) { removeMenuStyles(); user.setSetting("l-menu", ""); desktopMenuStyleItem.setStyleName("l-hidden"); } }; final MenuBar userMenu = new MenuBar(); userMenu.addStyleName("user-menu"); final MenuItem userMenuItem = userMenu.addItem(user.getPerson().getFullName(), new ThemeResource("../lsps-valo-base/img/profile-pic-300px.jpg"), null); mobileMenuStyleItem = userMenuItem.addItem("Mobile Menu", mobileMenu); tabletMenuStyleItem = userMenuItem.addItem("Tablet Menu", tabletMenu); desktopMenuStyleItem = userMenuItem.addItem("Desktop Menu", desktopMenu); userMenuItem.addSeparator(); MenuItem currentItem = userMenuItem.addItem(ui.getMessage(SettingsView.TITLE), settingsCmd); currentItem.setStyleName("l-menu-settings"); currentItem = userMenuItem.addItem(ui.getMessage("nav.logout", ""), logoutCmd); currentItem.setStyleName("l-menu-logout"); this.addComponent(userMenu); }
From source file:com.studiodojo.qwikinvoice.QwikInvoiceApplication.java
License:Apache License
@Override public void init() { this.mainWindow = new Window( "QwikInvoice CRM Tools - Developed by StudioDojo. Engineered by Vaadin. Powered by Google."); setMainWindow(mainWindow);/*from w w w. j av a2 s . c o m*/ // // Check if a user is logged in // UserService us = UserServiceFactory.getUserService(); this.logoutURL = us.createLogoutURL(super.getURL().toExternalForm()); if (us.getCurrentUser() == null || us.getCurrentUser().getEmail() == null) { super.setLogoutURL(logoutURL); super.close(); return; } String login = us.getCurrentUser().getEmail(); this.userKey = KeyFactory.createKey(TokenBean.class.getSimpleName(), us.getCurrentUser().getEmail()); // Key ucKey = KeyFactory.createKey(UserCompanyBean.class.getSimpleName(), us.getCurrentUser().getEmail()); UserCompanyBean ucBean = UserDAO.getUserCompanyBean(us.getCurrentUser().getEmail()); this.theSession = new SessionBean(login, ucBean); // // SETUP WORKING AREA // HorizontalLayout appLayout = new HorizontalLayout(); appLayout.setSizeFull(); // The Main Layout VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setWidth(APP_WIDTH); mainLayout.setHeight(APP_HEIGHT); appLayout.addComponent(mainLayout); appLayout.setComponentAlignment(mainLayout, Alignment.TOP_CENTER); appLayout.setExpandRatio(mainLayout, 2); // // Setup Header (Welcome Message) // Label welcome = new Label( "<h1>QWIK!NVOICE</h1> You are " + (us.isUserLoggedIn() ? "logged in" : "logged out") + " as <b>" + us.getCurrentUser().getNickname() + "</b>", Label.CONTENT_XHTML); mainLayout.addComponent(welcome); mainLayout.setComponentAlignment(welcome, Alignment.TOP_LEFT); // // Menu Bar // MenuBar menuBar = new MenuBar(); menuBar.setWidth(APP_WIDTH); MenuBar.MenuItem fileMenuItem = menuBar.addItem("File", null, null); MenuItem newMenuItem = fileMenuItem.addItem("New...", null, null); newMenuItem.addItem("Invoice/Quote", new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { try { QwikInvoiceApplication.this.showPanel(InvoiceApplicationPanel.class); } catch (Exception e) { Log.log(Level.SEVERE, "Error loading panel", e); QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); newMenuItem.addItem("Order", new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { try { QwikInvoiceApplication.this.showPanel(FFOrderApplicationPanel.class); } catch (Exception e) { Log.log(Level.SEVERE, "Error loading panel", e); QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); /** SAVE */ fileMenuItem.addItem("Save", new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { try { TokenBean userTokenBean = TokenStore.getToken(QwikInvoiceApplication.this.userKey); // User must have an OAuth AUTH Token to access Google Doc service if (userTokenBean != null) { /* GDocFileWindow saveWindow = new GDocFileWindow("Save As..."); saveWindow.init(QwikInvoiceApplication.this, PdfWriter.getFilename(QwikInvoiceApplication.this.theSession)); QwikInvoiceApplication.this.mainWindow.addWindow(saveWindow); */ QwikInvoiceApplication.this.activePanel.validate(); QwikInvoiceApplication.this.activePanel.onSave(); } else { AuthSubWindow authsubWindow = new AuthSubWindow("Service Authorization Required"); authsubWindow.init(QwikInvoiceApplication.this.userKey); QwikInvoiceApplication.this.mainWindow.addWindow(authsubWindow); } } catch (Exception e) { Log.log(Level.SEVERE, "Error Saving file", e); QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); /** * SETTINGS */ fileMenuItem.addSeparator(); MenuItem settingsMenuItem = fileMenuItem.addItem("Settings...", null, null); settingsMenuItem.addItem("Profile", new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { try { UserCompanySetupWindow aWindow = new UserCompanySetupWindow(); aWindow.init(QwikInvoiceApplication.this); QwikInvoiceApplication.this.mainWindow.addWindow(aWindow); } catch (Exception e) { Log.log(Level.SEVERE, "Error Saving Profile", e); QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); fileMenuItem.addSeparator(); fileMenuItem.addItem("Logout", new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { QwikInvoiceApplication.this.setLogoutURL(logoutURL); QwikInvoiceApplication.this.close(); } }); /** * Products */ MenuBar.MenuItem productsMenuItem = menuBar.addItem("Products", null, null); productsMenuItem.addItem("Products", null, new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { try { QwikInvoiceApplication.this.showPanel(ProductApplicationPanel.class); } catch (Exception e) { Log.log(Level.SEVERE, "Error loading products", e); QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); productsMenuItem.addItem("Categories", null, new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { try { ProductCategorySettingsWindow window = new ProductCategorySettingsWindow(); window.setCaption("Product Category"); window.init(QwikInvoiceApplication.this.theSession, QwikInvoiceApplication.this); QwikInvoiceApplication.this.mainWindow.addWindow(window); } catch (Exception e) { Log.log(Level.SEVERE, "Error Loading Products", e); QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); productsMenuItem.addItem("Catalogs", null, new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { try { QwikInvoiceApplication.this.showPanel(CatalogApplicationPanel.class); } catch (Exception e) { Log.log(Level.SEVERE, "Error loading catalogs", e); QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); /** * Help */ MenuBar.MenuItem helpMenuItem = menuBar.addItem("Help", null, new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { AboutWindow aboutWindow = new AboutWindow(); aboutWindow.init(); QwikInvoiceApplication.this.mainWindow.addWindow(aboutWindow); } }); helpMenuItem.addItem("About...", null, null); mainLayout.addComponent(menuBar); mainLayout.setComponentAlignment(menuBar, Alignment.TOP_CENTER); // // Load Main Panel // IApplicationPanel invoiceApplicationPanel = (IApplicationPanel) this.map.get(InvoiceApplicationPanel.class); try { invoiceApplicationPanel.init(this.theSession, this); mainLayout.addComponent((Component) invoiceApplicationPanel); mainLayout.setComponentAlignment((Component) invoiceApplicationPanel, Alignment.TOP_CENTER); this.activePanel = invoiceApplicationPanel; } catch (Exception e) { } // // Setup Footer // //Label footerMessage = new Label("QwikInvoice <b>version "+_VERSION_+"</b>. This service is provided as is. E&O accepted. Developed by <a href='mailto:public@studiodojo.com?subject=QwikInvoice' target='_blank'>StudioDojo</a>. Engineered by Vaadin. Powered by Google. Apache License 2.0", Label.CONTENT_XHTML); //mainLayout.addComponent(footerMessage); //mainLayout.setComponentAlignment(footerMessage, Alignment.TOP_CENTER); Panel mainPanel = new Panel(); mainPanel.setScrollable(true); mainPanel.setContent(appLayout); this.mainWindow.setContent(mainPanel); }
From source file:com.wintindustries.pfserver.interfaces.view.dashboard.DashboardMenu.java
private Component buildUserMenu() { final MenuBar settings = new MenuBar(); settings.addStyleName("user-menu"); final PFUser user = getCurrentUser(); settingsItem = settings.addItem("", new ThemeResource("img/profile-pic-300px.jpg"), null); // updateUserName(null); settingsItem.addItem("Edit Profile", new Command() { @Override/* w w w .j a v a2 s . co m*/ public void menuSelected(final MenuItem selectedItem) { // ProfilePreferencesWindow.open(user, false); } }); settingsItem.addItem("Preferences", new Command() { @Override public void menuSelected(final MenuItem selectedItem) { // ProfilePreferencesWindow.open(user, true); } }); settingsItem.addSeparator(); settingsItem.addItem("Sign Out", new Command() { @Override public void menuSelected(final MenuItem selectedItem) { // DashboardEventBus.post(new UserLoggedOutEvent()); } }); return settings; }
From source file:de.gedoplan.webclients.vaadin.VaadinDemoUi.java
public MenuBar createMenu() { User user = userProvider.get();//w ww.j a v a2 s. com MenuBar mainMenu = new MenuBar(); mainMenu.setWidth(100, Unit.PERCENTAGE); mainMenu.setStyleName("main"); mainMenu.addItem("", new ThemeResource("images/vaadin-logo.png"), e -> navigator.navigateTo(Konstanten.VAADIN_VIEW_INDEX)).setStyleName("logo"); if (user.isInRole(User.UserRole.ADMIN)) { mainMenu.addItem(Messages.menu_customer.value(), e -> navigator.navigateTo(Konstanten.VAADIN_VIEW_CUSTOMERS)); } mainMenu.addItem(Messages.menu_orders.value(), e -> navigator.navigateTo(Konstanten.VAADIN_VIEW_ORDERS)); if (user.isInRole(User.UserRole.CUSTOMER)) { mainMenu.addItem(Messages.menu_customerdetails.value(), e -> navigator .navigateTo(Konstanten.VAADIN_VIEW_CUSTOMER_DETAILS + "/" + user.getCustomerID())); } MenuBar.MenuItem userMenu = mainMenu.addItem(user.getLogin(), null); userMenu.setStyleName("align-right"); userMenu.addItem(Messages.logout.value(), e -> { try { JaasAccessControl.logout(); VaadinSession.getCurrent().close(); Page.getCurrent().setLocation(Konstanten.VAADIN_LOGIN_PATH); } catch (ServletException ex) { Logger.getLogger(VaadinDemoUi.class.getName()).log(Level.SEVERE, null, ex); } }); return mainMenu; }
From source file:de.informera.dev.nutchManager.MyVaadinApplication.java
License:Apache License
@Override public void init() { File settings_folder = new File(System.getProperty("user.home") + "/.nutchManager"); if (!settings_folder.isDirectory()) { settings_folder.mkdir();//from www .j ava 2 s.c o m new File(settings_folder.getAbsolutePath() + "/backups").mkdir(); new File(settings_folder.getAbsolutePath() + "/instances").mkdir(); } window = new Window("nutchManager"); setMainWindow(window); this.setTheme("nutchManager"); final HorizontalLayout technologies = new HorizontalLayout(); technologies.setSpacing(true); technologies.addComponent(new Embedded("", new ThemeResource("images/nutch_logo_tm.gif"))); technologies.addComponent(new Embedded("", new ThemeResource("images/vaadin.png"))); final MenuBar mainMenu = new MenuBar(); mainMenu.setWidth("100%"); MenuItem menuFile = mainMenu.addItem("File", null, null); MenuItem subMenuFile = menuFile.addItem("Add new instance", null, null); // Define a common menu command for all the menu items. MenuBar.Command addNewInstanceFromMenu = new MenuBar.Command() { public void menuSelected(MenuItem selectedItem) { window.removeAllComponents(); window.addComponent(technologies); window.addComponent(mainMenu); window.addWindow(new AddInstanceDialog()); } }; subMenuFile.setCommand(addNewInstanceFromMenu); window.addComponent(technologies); window.addComponent(mainMenu); // Begin the checkout of an old configuration // Check waether configuration has entries for nutch instances or not // File settings_folder = new File( this.getClass().getClassLoader().getResource("/instance_conf").getPath() ); File instances_folder = new File(settings_folder + "/instances"); // If not: prompt to add an instance if (instances_folder.list().length < 1) { window.showNotification("ERROR", "No previous configuration found. Please add a nutch instance.", Notification.TYPE_ERROR_MESSAGE); Window addInstance = new AddInstanceDialog(); window.addWindow(addInstance); } else { window.addComponent(new InstanceSelectionView()); } }
From source file:de.kaiserpfalzEdv.vaadin.menu.impl.MenuImpl.java
License:Apache License
@Inject public MenuImpl(final Authenticator accessControl, final EventBus bus, final I18NHandler i18n, final List<View> allViews) { this.accessControl = accessControl; this.bus = bus; this.i18n = i18n; this.allViews = allViews; setPrimaryStyleName(ValoTheme.MENU_ROOT); menuPart = new CssLayout(); menuPart.addStyleName(ValoTheme.MENU_PART); // header of the menu final HorizontalLayout top = new HorizontalLayout(); top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); top.addStyleName(ValoTheme.MENU_TITLE); top.setSpacing(true);// www .j av a 2s. c o m Label title = new Label(translate("application.name")); title.addStyleName(ValoTheme.LABEL_H3); title.setSizeUndefined(); Image image = new Image(null, new ThemeResource("img/table-logo.png")); image.setStyleName("logo"); top.addComponent(image); top.addComponent(title); menuPart.addComponent(top); // logout menu item MenuBar logoutMenu = new MenuBar(); logoutMenu.addItem(translate("button.logout.caption"), FontAwesome.valueOf(translate("button.logout.icon")), selectedItem -> { VaadinSession.getCurrent().getSession().invalidate(); Page.getCurrent().reload(); }); logoutMenu.addStyleName("user-menu"); menuPart.addComponent(logoutMenu); // button for toggling the visibility of the menu when on a small screen final Button showMenu = new Button(translate("application.name"), new ClickListener() { @Override public void buttonClick(final ClickEvent event) { if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) { menuPart.removeStyleName(VALO_MENU_VISIBLE); } else { menuPart.addStyleName(VALO_MENU_VISIBLE); } } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); showMenu.addStyleName(ValoTheme.BUTTON_SMALL); showMenu.addStyleName(VALO_MENU_TOGGLE); showMenu.setIcon(FontAwesome.NAVICON); menuPart.addComponent(showMenu); // container for the navigation buttons, which are added by addView() menuItemsLayout = new CssLayout(); menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS); menuPart.addComponent(menuItemsLayout); addComponent(menuPart); }
From source file:de.mendelson.comm.as2.webclient2.AS2WebUI.java
private MenuBar createMenuBar() { MenuBar.Command logoutCommand = new MenuBar.Command() { @Override//w w w. j ava 2s. c o m public void menuSelected(MenuItem selectedItem) { logout(); } }; MenuBar.Command stateCommand = new MenuBar.Command() { @Override public void menuSelected(MenuItem selectedItem) { OkDialog dialog = new StateDialog(); dialog.init(); AS2WebUI.this.mainWindow.addWindow(dialog); } }; MenuBar.Command aboutCommand = new MenuBar.Command() { @Override public void menuSelected(MenuItem selectedItem) { OkDialog dialog = new AboutDialog(); dialog.init(); AS2WebUI.this.mainWindow.addWindow(dialog); } }; MenuBar menubar = new MenuBar(); MenuBar.MenuItem fileItem = menubar.addItem("AS2 server", null, null); fileItem.addItem("State", null, stateCommand); fileItem.addItem("Logout", null, logoutCommand); MenuBar.MenuItem helpItem = menubar.addItem("Help", null, null); helpItem.addItem("About", null, aboutCommand); menubar.setSizeFull(); return (menubar); }
From source file:de.symeda.sormas.ui.Menu.java
License:Open Source License
public Menu(Navigator navigator) { this.navigator = navigator; setPrimaryStyleName(ValoTheme.MENU_ROOT); menuPart = new CssLayout(); menuPart.addStyleName(ValoTheme.MENU_PART); // header of the menu final HorizontalLayout top = new HorizontalLayout(); top.setDefaultComponentAlignment(Alignment.TOP_CENTER); top.addStyleName(ValoTheme.MENU_TITLE); top.setSpacing(true);/* w w w .j a va 2 s . c o m*/ Label title = new Label("SORMAS"); title.setSizeUndefined(); Image image = new Image(null, new ThemeResource("img/sormas-logo.png")); CssStyles.style(image, ValoTheme.MENU_LOGO, ValoTheme.BUTTON_LINK); image.addClickListener(new MouseEvents.ClickListener() { @Override public void click(MouseEvents.ClickEvent event) { SormasUI.get().getNavigator().navigateTo(SurveillanceDashboardView.VIEW_NAME); } }); top.addComponent(image); top.addComponent(title); menuPart.addComponent(top); // logout menu item MenuBar logoutMenu = new MenuBar(); logoutMenu.addItem(I18nProperties.getCaption(Captions.actionLogout) + " (" + UserProvider.getCurrent().getUserName() + ")", VaadinIcons.SIGN_OUT, new Command() { @Override public void menuSelected(MenuItem selectedItem) { LoginHelper.logout(); } }); logoutMenu.addStyleName("user-menu"); menuPart.addComponent(logoutMenu); // button for toggling the visibility of the menu when on a small screen final Button showMenu = new Button(I18nProperties.getCaption(Captions.menu), new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) { menuPart.removeStyleName(VALO_MENU_VISIBLE); } else { menuPart.addStyleName(VALO_MENU_VISIBLE); } } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); showMenu.addStyleName(VALO_MENU_TOGGLE); showMenu.setIcon(VaadinIcons.MENU); menuPart.addComponent(showMenu); // container for the navigation buttons, which are added by addView() menuItemsLayout = new CssLayout(); menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS); menuPart.addComponent(menuItemsLayout); addComponent(menuPart); }