List of usage examples for com.vaadin.ui MenuBar MenuBar
public MenuBar()
From source file:lv.polarisit.demosidemenu.ValoThemeUI.java
License:Apache License
CssLayout buildMenu() { // Add items//from w w w . ja v a 2 s .c om 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:me.uni.emuseo.view.menu.MenuView.java
License:Open Source License
private CssLayout buildMenu() { // Add items//from ww w . j a v a 2 s . 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; }
From source file:module.pandabox.presentation.PandaBox.java
License:Open Source License
Layout getMenuBarPreviews() { Layout grid = getPreviewLayout("Menu bars"); MenuBar menubar = new MenuBar(); final MenuBar.MenuItem file = menubar.addItem("File", null); final MenuBar.MenuItem newItem = file.addItem("New", null); file.addItem("Open file...", null); file.addSeparator();// w w w. j a v a 2 s. co m newItem.addItem("File", null); newItem.addItem("Folder", null); newItem.addItem("Project...", null); file.addItem("Close", null); file.addItem("Close All", null); file.addSeparator(); file.addItem("Save", null); file.addItem("Save As...", null); file.addItem("Save All", null); final MenuBar.MenuItem edit = menubar.addItem("Edit", null); edit.addItem("Undo", null); edit.addItem("Redo", null).setEnabled(false); edit.addSeparator(); edit.addItem("Cut", null); edit.addItem("Copy", null); edit.addItem("Paste", null); edit.addSeparator(); final MenuBar.MenuItem find = edit.addItem("Find/Replace", null); // Actions can be added inline as well, of course find.addItem("Google Search", null); find.addSeparator(); find.addItem("Find/Replace...", null); find.addItem("Find Next", null); find.addItem("Find Previous", null); final MenuBar.MenuItem view = menubar.addItem("View", null); view.addItem("Show/Hide Status Bar", null); view.addItem("Customize Toolbar...", null); view.addSeparator(); view.addItem("Actual Size", null); view.addItem("Zoom In", null); view.addItem("Zoom Out", null); grid.addComponent(menubar); return grid; }
From source file:net.gvcc.jgoffice.components.CommandBar.java
License:Open Source License
private HorizontalLayout buildNavigationBar() { // common part: create layout navigationBar = new HorizontalLayout(); navigationBar.setStyleName("g-commandBar"); navigationBar.setImmediate(false);/*w ww .jav a 2 s . co m*/ navigationBar.setWidth("100.0%"); navigationBar.setHeight("-1px"); navigationBar.setMargin(true); // menuBar_1 menuBar_1 = new MenuBar(); menuBar_1.setImmediate(false); menuBar_1.setWidth("-1px"); menuBar_1.setHeight("-1px"); navigationBar.addComponent(menuBar_1); navigationBar.setComponentAlignment(menuBar_1, new Alignment(33)); // searchComponent searchComponent = SearchBarFactory.getInstance(); searchComponent.setWidth("100%"); navigationBar.addComponent(searchComponent); navigationBar.setExpandRatio(searchComponent, 1); return navigationBar; }
From source file:nz.co.senanque.bundle1.AppFactoryImpl.java
License:Apache License
@Override public App createApp(Blackboard blackboard) { App ret = new App(); final Layout layout = new Layout(); layout.setBlackboard(blackboard);//w w w . j a v a 2s. c o m ret.setComponentContainer(layout); MenuBar menuBar = new MenuBar(); final MenuBar.MenuItem file = menuBar.addItem("File", null); file.addItem("Close", new Command() { private static final long serialVersionUID = -1L; public void menuSelected(MenuItem selectedItem) { layout.close(); } }); final MenuBar.MenuItem save = menuBar.addItem("Edit", null); save.addItem("Save", new Command() { private static final long serialVersionUID = -1L; public void menuSelected(MenuItem selectedItem) { layout.close(); } }); ret.setMenuBar(menuBar); return ret; }
From source file:nz.co.senanque.pizzabundle.AppFactoryImpl.java
License:Apache License
public App createApp(Blackboard blackboard) { // Explicitly fetch this bean to ensure it is not instantiated until the session has started. m_maduraSessionManager = m_beanFactory.getBean("maduraSessionManager", MaduraSessionManager.class); App ret = new App(); MaduraFieldGroup fieldGroup = getMaduraSessionManager().createMaduraFieldGroup(); final Layout layout = new Layout(m_maduraSessionManager, fieldGroup); layout.setBlackboard(blackboard);/*from ww w. ja v a 2s . c o m*/ ret.setComponentContainer(layout); Pizza pizza = new Pizza(); m_maduraSessionManager.getValidationSession().bind(pizza); MenuBar menuBar = new MenuBar(); final MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(m_messageSource); final MenuBar.MenuItem edit = menuBar.addItem(messageSourceAccessor.getMessage("menu.edit", "Edit"), null); CommandExt command = fieldGroup.createMenuItemCommand(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { Notification.show(messageSourceAccessor.getMessage("message.clicked.cancel"), messageSourceAccessor.getMessage("message.noop"), Notification.Type.HUMANIZED_MESSAGE); } }); MenuItem menuItemSave = edit.addItem("menu.cancel", command); fieldGroup.bind(menuItemSave); command = fieldGroup.createMenuItemCommandSubmit(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { Notification.show(messageSourceAccessor.getMessage("message.clicked.submit"), messageSourceAccessor.getMessage("message.noop"), Notification.Type.HUMANIZED_MESSAGE); } }); MenuItem menuItemCancel = edit.addItem("menu.save", command); fieldGroup.bind(menuItemCancel); ret.setMenuBar(menuBar); layout.load(pizza); return ret; }
From source file:org.activiti.explorer.ui.mainlayout.MainMenuBar.java
License:Apache License
protected void initProfileButton() { final LoggedInUser user = ExplorerApp.get().getLoggedInUser(); // 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) { ExplorerApp.get().getViewManager().showProfilePopup(user.getId()); }/*from w ww .ja v a 2s . c o m*/ }); // Edit profile rootItem.addItem(i18nManager.getMessage(Messages.PROFILE_EDIT), new Command() { public void menuSelected(MenuItem selectedItem) { // TODO: Show in edit-mode ExplorerApp.get().getViewManager().showProfilePopup(user.getId()); } }); // Change password rootItem.addItem(i18nManager.getMessage(Messages.PASSWORD_CHANGE), new Command() { public void menuSelected(MenuItem selectedItem) { ExplorerApp.get().getViewManager().showPopupWindow(new ChangePasswordPopupWindow()); } }); rootItem.addSeparator(); } // Logout rootItem.addItem(i18nManager.getMessage(Messages.HEADER_LOGOUT), new Command() { public void menuSelected(MenuItem selectedItem) { ExplorerApp.get().close(); } }); addComponent(profileMenu); setComponentAlignment(profileMenu, Alignment.TOP_RIGHT); setExpandRatio(profileMenu, 1.0f); }
From source file:org.activiti.explorer.ui.MainMenuBar.java
License:Apache License
protected void initProfileButton() { final LoggedInUser user = ExplorerApp.get().getLoggedInUser(); // 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); // Show profile rootItem.addItem(i18nManager.getMessage(Messages.PROFILE_SHOW), new Command() { public void menuSelected(MenuItem selectedItem) { ExplorerApp.get().getViewManager().showProfilePopup(user.getId()); }//from w w w . j a v a2s.c o m }); // Edit profile rootItem.addItem(i18nManager.getMessage(Messages.PROFILE_EDIT), new Command() { public void menuSelected(MenuItem selectedItem) { // TODO: Show in edit-mode ExplorerApp.get().getViewManager().showProfilePopup(user.getId()); } }); // Change password rootItem.addItem(i18nManager.getMessage(Messages.PASSWORD_CHANGE), new Command() { public void menuSelected(MenuItem selectedItem) { ExplorerApp.get().getViewManager().showPopupWindow(new ChangePasswordPopupWindow()); } }); rootItem.addSeparator(); // Logout rootItem.addItem(i18nManager.getMessage(Messages.HEADER_LOGOUT), new Command() { public void menuSelected(MenuItem selectedItem) { ExplorerApp.get().close(); } }); addComponent(profileMenu); setComponentAlignment(profileMenu, Alignment.TOP_RIGHT); setExpandRatio(profileMenu, 1.0f); }
From source file:org.azrul.langkuik.Langkuik.java
public void initLangkuik(final EntityManagerFactory emf, final UI ui, final RelationManagerFactory relationManagerFactory, List<Class<?>> customTypeInterfaces) { List<Class<?>> rootClasses = new ArrayList<>(); for (ManagedType<?> entity : emf.getMetamodel().getManagedTypes()) { Class<?> clazz = entity.getJavaType(); if (clazz.getAnnotation(WebEntity.class).isRoot() == true) { rootClasses.add(clazz);//from w w w . j a v a2s . co m } } //Manage custom type if (customTypeInterfaces == null) { customTypeInterfaces = new ArrayList<>(); } //add system level custom type customTypeInterfaces.add(AttachmentCustomType.class); //create DAOs for custom types final List<DataAccessObject<?>> customTypeDaos = new ArrayList<>(); for (Class<?> clazz : customTypeInterfaces) { customTypeDaos.add(new HibernateGenericDAO(emf, clazz)); } //Setup page VerticalLayout main = new VerticalLayout(); VerticalLayout content = new VerticalLayout(); final Navigator navigator = new Navigator(ui, content); final HorizontalLayout breadcrumb = new HorizontalLayout(); MenuBar menubar = new MenuBar(); menubar.setId("MENUBAR"); main.addComponent(menubar); main.addComponent(breadcrumb); main.addComponent(content); final Deque<History> history = new ArrayDeque<>(); final Configuration config = Configuration.getInstance(); history.push(new History("START", "Start")); StartView startView = new StartView(history, breadcrumb); navigator.addView("START", startView); MenuBar.MenuItem create = menubar.addItem("Create", null); MenuBar.MenuItem view = menubar.addItem("View", null); final PageParameter pageParameter = new PageParameter(customTypeDaos, emf, relationManagerFactory, history, config, breadcrumb); for (final Class rootClass : rootClasses) { final WebEntity myObject = (WebEntity) rootClass.getAnnotation(WebEntity.class); final DataAccessObject<?> dao = new HibernateGenericDAO<>(emf, rootClass); create.addItem("New " + myObject.name(), new MenuBar.Command() { @Override public void menuSelected(MenuBar.MenuItem selectedItem) { Object object = dao.createNew(true); BeanView<Object, ?> createNewView = new BeanView<>(object, null, null, pageParameter); String targetView = "CREATE_NEW_APPLICATION_" + UUID.randomUUID().toString(); navigator.addView(targetView, (View) createNewView); history.clear(); history.push(new History("START", "Start")); History his = new History(targetView, "Create new " + myObject.name()); history.push(his); navigator.navigateTo(targetView); } }); view.addItem("View " + myObject.name(), new MenuBar.Command() { @Override public void menuSelected(MenuBar.MenuItem selectedItem) { PlainTableView<?> seeApplicationView = new PlainTableView<>(rootClass, pageParameter); String targetView = "VIEW_APPLICATION_" + UUID.randomUUID().toString(); navigator.addView(targetView, (View) seeApplicationView); history.clear(); history.push(new History("START", "Start")); History his = new History(targetView, "View " + myObject.name()); history.push(his); navigator.navigateTo(targetView); } }); } menubar.addItem("Logout", null).addItem("Logout", new MenuBar.Command() { @Override public void menuSelected(MenuBar.MenuItem selectedItem) { ConfirmDialog.show(ui, "Please Confirm:", "Are you really sure you want to log out?", "I am", "Not quite", new ConfirmDialog.Listener() { @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { HttpServletRequest req = (HttpServletRequest) VaadinService.getCurrentRequest(); HttpServletResponse resp = (HttpServletResponse) VaadinService .getCurrentResponse(); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); SecurityContextLogoutHandler ctxLogOut = new SecurityContextLogoutHandler(); ctxLogOut.logout(req, resp, auth); } } }); } }); navigator.navigateTo("START"); ui.setContent(main); }
From source file:org.balisunrise.vaadin.components.header.ModuleButton.java
private void init() { setStyleName("b-module-button"); setHeight("100%"); button = new MenuBar(); setCompositionRoot(button);/* w w w .j a v a2s . c o m*/ MenuBar.MenuItem modules = button.addItem("", null); //modules.setIcon(new ThemeResource("img/modules.png")); modules.setDescription("Clique e selecione um mdulo"); modules.addItem("Pessoas", c -> { Notification.show("Modulo: " + c.getText(), Notification.Type.TRAY_NOTIFICATION); }); modules.addItem("Vendas", c -> { Notification.show("Modulo: " + c.getText(), Notification.Type.TRAY_NOTIFICATION); }); modules.addItem("Financeiro", c -> { Notification.show("Modulo: " + c.getText(), Notification.Type.TRAY_NOTIFICATION); }); modules.addItem("Estoque", c -> { Notification.show("Modulo: " + c.getText(), Notification.Type.TRAY_NOTIFICATION); }); modules.addItem("Compras", c -> { Notification.show("Modulo: " + c.getText(), Notification.Type.TRAY_NOTIFICATION); }); }