List of usage examples for com.vaadin.ui MenuBar addStyleName
@Override public void addStyleName(String style)
From source file:com.klwork.explorer.ui.mainlayout.MainMenuBar.java
License:Apache License
protected void initProfileButton() { final LoggedInUser user = LoginHandler.getLoggedInUser(); // LoggedInUser user = new LoggedInUser(); // 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) { ViewToolManager.showPopupWindow(new ProfilePopupWindow(user.getId())); }//w ww . j a va2 s. c om }); // Edit profile rootItem.addItem("?", new Command() { public void menuSelected(MenuItem selectedItem) { ViewToolManager.showPopupWindow(new ProfilePopupWindow(user.getId())); } }); // Change password rootItem.addItem(i18nManager.getMessage(Messages.PASSWORD_CHANGE), new Command() { public void menuSelected(MenuItem selectedItem) { ViewToolManager.showPopupWindow(new ChangePasswordPopupWindow()); } }); } // Logout rootItem.addItem(i18nManager.getMessage(Messages.HEADER_LOGOUT), new Command() { public void menuSelected(MenuItem selectedItem) { // xx.close(); ViewToolManager.logout(); } }); rootItem.addSeparator(); // ? rootItem.addItem("?", new Command() { public void menuSelected(MenuItem selectedItem) { // xx.close(); // ViewToolManager.logout(); } }); // rootItem.addItem("", new Command() { public void menuSelected(MenuItem selectedItem) { // xx.close(); // ViewToolManager.logout(); } }); addComponent(profileMenu); setComponentAlignment(profileMenu, Alignment.TOP_RIGHT); // setExpandRatio(profileMenu, 1.0f); }
From source file:com.lst.deploymentautomation.vaadin.page.TodoView.java
License:Open Source License
@SuppressWarnings("serial") @Override//from w w w.j av a 2 s . c o 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. ja v a 2s.c o m*/ 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/*ww w .java 2 s . com*/ 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.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/*from w w w . j av a 2 s . c om*/ 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.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);//from ww w . j av a 2s . com 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.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);/*from w w w . jav a 2 s. co 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); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ToolBar.java
License:Open Source License
void init() { // setWidth(100.0f, Unit.PERCENTAGE); // addStyleName("user-menu"); // setWidth((UI.getCurrent().getPage().getBrowserWindowWidth() * 0.6f), Unit.PIXELS); MenuBar menuBar = new MenuBar(); menuBar.addStyleName("user-menu"); menuBar.setHtmlContentAllowed(true); download = menuBar.addItem("Download your data", null, null); download.setEnabled(false);//from w w w . ja v a2 s . co m download.setIcon(new ThemeResource("computer_higher.png")); download.addSeparator(); this.downloadwhole = download.addItem("<a href=\"" + resourceUrl + "\" target=\"_blank\" style=\"text-decoration: none ; color:#2c2f34\">Download everything belonging to this entity.</a>", null); this.downloadwhole.setEnabled(false); // Open DatasetView this.datasetoverview = download.addItem("Dataset Overview", null); this.datasetoverview.setEnabled(false); manage = menuBar.addItem("Manage your data", null, null); manage.setIcon(new ThemeResource("barcode_higher.png")); manage.setEnabled(false); // Another submenu item with a sub-submenu this.createBarcodes = manage.addItem("Create Barcodes", null, null); createBarcodes.setEnabled(false); workflows = menuBar.addItem("Run workflows", null, null); workflows.setIcon(new ThemeResource("dna_higher.png")); workflows.setEnabled(false); addComponent(menuBar); // menuBar.setWidth((UI.getCurrent().getPage().getBrowserWindowWidth() * 0.3f), Unit.PIXELS); // searchEngineView.setWidth((UI.getCurrent().getPage().getBrowserWindowWidth() * 0.2f), // Unit.PIXELS); // searchEngineView.setWidth("100%"); addComponent(searchEngineView); setComponentAlignment(searchEngineView, Alignment.TOP_RIGHT); // setExpandRatio(menuBar, 0.7f); // setExpandRatio(searchEngineView, 0.3f); }
From source file:es.mdef.clientmanager.ui.GestionClientesUI.java
License:Apache License
CssLayout buildMenu() { // Add items/*from ww w. j a v a 2s . co m*/ menuItems.put("common", "Common UI Elements"); menu.setSizeFull(); menu.addComponent(getMenuTitleComponent()); final MenuBar settings = new MenuBar(); settings.addStyleName("user-menu"); // TODO Actualizar nombre de usuario cuando se logee con exito final MenuBar.MenuItem userMenuItem = settings.addItem(getNombreUsuario(), new ThemeResource("icons/usuario.svg"), null); userMenuItem.addItem("Cambiar contrasea", new MenuBar.Command() { @Override public void menuSelected(MenuBar.MenuItem selectedItem) { ChangePasswordWindow changePasswordWindow = new ChangePasswordWindow(); changePasswordWindow.center(); addWindow(changePasswordWindow); } }); userMenuItem.addSeparator(); userMenuItem.addItem("Salir", new MenuBar.Command() { @Override public void menuSelected(MenuBar.MenuItem selectedItem) { SecurityContextHolder.clearContext(); //UI.getCurrent().close(); Navigator navigator = UI.getCurrent().getNavigator(); navigator.navigateTo(""); } }); menu.addComponent(settings); menuItemsLayout.setPrimaryStyleName("valo-menuitems"); menu.addComponent(menuItemsLayout); final Button clientesButton = new Button("Clientes", new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { navigator.navigateTo(CLIENT_LIST_VIEW); } }); clientesButton.setHtmlContentAllowed(true); clientesButton.setPrimaryStyleName("valo-menu-item"); clientesButton.setIcon(new ThemeResource("icons/clientes2.svg")); menuItemsLayout.addComponent(clientesButton); final Button budgetButton = new Button("Presupuesto", new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { navigator.navigateTo(BUDGETS_VIEW); } }); budgetButton.setHtmlContentAllowed(true); budgetButton.setPrimaryStyleName("valo-menu-item"); budgetButton.setIcon(new ThemeResource("icons/money.svg")); menuItemsLayout.addComponent(budgetButton); final Button subscripcionButton = new Button("Suscripciones", new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { navigator.navigateTo(PROVIDERS_VIEW); } }); subscripcionButton.setHtmlContentAllowed(true); subscripcionButton.setPrimaryStyleName("valo-menu-item"); subscripcionButton.setIcon(new ThemeResource("icons/suscripciones.svg")); menuItemsLayout.addComponent(subscripcionButton); return menu; }
From source file:eu.lod2.stat.dsdrepo.DSDRepoComponent.java
public DSDRepoComponent(Repository repository, String dataGraph, String repoGraph) { this.repository = repository; this.dataGraph = dataGraph; this.repoGraph = repoGraph; initializeRepoGraph();//www. ja va 2 s.c om dcRepo = new SparqlDCRepository(repository); graph = new SparqlDCGraph(repository, dataGraph); setSizeFull(); VerticalLayout rootLayout = new VerticalLayout(); rootLayout.setSizeFull(); rootLayout.setSpacing(true); setDebugId("dsd-repo"); mainLayout = new VerticalLayout(); mainLayout.setSizeUndefined(); mainLayout.setWidth("100%"); // mainLayout.setHeight("800px"); mainLayout.setSpacing(true); HorizontalLayout menuLayout = new HorizontalLayout(); menuLayout.setSpacing(true); menuLayout.setWidth("100%"); rootLayout.addComponent(menuLayout); rootLayout.setExpandRatio(menuLayout, 0.0f); final MenuBar menu = new MenuBar(); menu.addStyleName("dsd"); cmdFindDSD = new MenuBar.Command() { public void menuSelected(MenuBar.MenuItem selectedItem) { for (MenuBar.MenuItem item : menu.getItems()) { if (item == selectedItem) { if (!item.getStyleName().contains("selected")) { if (ds != null) item.setStyleName("selected"); findDSDs(); } } else item.setStyleName("bleja"); } } }; menu.addItem("Find Suitable DSDs", cmdFindDSD).setStyleName("bleja"); cmdCreateDSD = new MenuBar.Command() { public void menuSelected(MenuBar.MenuItem selectedItem) { for (MenuBar.MenuItem item : menu.getItems()) { if (item == selectedItem) { if (!item.getStyleName().contains("selected")) { if (ds != null) item.setStyleName("selected"); createDSD(); } } else item.setStyleName("bleja"); } } }; menu.addItem("Create DSD", cmdCreateDSD).setStyleName("bleja"); cmdStoreDSD = new MenuBar.Command() { public void menuSelected(MenuBar.MenuItem selectedItem) { for (MenuBar.MenuItem item : menu.getItems()) { if (item == selectedItem) { if (!item.getStyleName().contains("selected")) { if (ds != null) item.setStyleName("selected"); storeDSD(); } } else item.setStyleName("bleja"); } } }; menu.addItem("Store DSD", cmdStoreDSD).setStyleName("bleja"); menuLayout.addComponent(menu); Label spaceLbl = new Label(""); menuLayout.addComponent(spaceLbl); menuLayout.setExpandRatio(spaceLbl, 2.0f); Label lbl = new Label("Choose dataset: "); lbl.setSizeUndefined(); menuLayout.addComponent(lbl); Collection<DataSet> colDataSets = graph.getDataSets(); if (colDataSets == null) colDataSets = new LinkedList<DataSet>(); selectDataSet = new ComboBox(null, colDataSets); selectDataSet.setImmediate(true); selectDataSet.setNewItemsAllowed(false); selectDataSet.setNullSelectionAllowed(false); selectDataSet.setWidth("300px"); selectDataSet.addListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent event) { ds = (DataSet) event.getProperty().getValue(); } }); menuLayout.addComponent(selectDataSet); Panel mainPanel = new Panel(mainLayout); mainPanel.setSizeFull(); mainPanel.setScrollable(true); mainPanel.setStyleName(Reindeer.PANEL_LIGHT); Label hrLabel = new Label("<hr/>", Label.CONTENT_XHTML); rootLayout.addComponent(hrLabel); rootLayout.setExpandRatio(hrLabel, 0.0f); rootLayout.addComponent(mainPanel); rootLayout.setExpandRatio(mainPanel, 2.0f); rootLayout.setMargin(true, false, true, false); setCompositionRoot(rootLayout); }