List of usage examples for com.vaadin.ui MenuBar MenuBar
public MenuBar()
From source file:de.catma.ui.repository.TagLibraryPanel.java
License:Open Source License
private Component createTagLibraryButtonPanel() { HorizontalLayout tagLibraryButtonPanel = new HorizontalLayout(); tagLibraryButtonPanel.setSpacing(true); btOpenTagLibrary = new Button("Open Tag Library"); btOpenTagLibrary.setEnabled(false);//from w w w .jav a 2 s . c o m tagLibraryButtonPanel.addComponent(btOpenTagLibrary); btCreateTagLibrary = new Button("Create Tag Library"); tagLibraryButtonPanel.addComponent(btCreateTagLibrary); MenuBar menuMoreTagLibraryActions = new MenuBar(); miMoreTagLibraryActions = menuMoreTagLibraryActions.addItem("More actions...", null); tagLibraryButtonPanel.addComponent(menuMoreTagLibraryActions); return tagLibraryButtonPanel; }
From source file:de.fzi.fhemapi.view.vaadin.ui.HWindow.java
License:Apache License
private MenuBar buildMenuBar() { MenuBar menubar = new MenuBar(); menubar.setWidth("100%"); MenuBar.MenuItem file = menubar.addItem("Neu..", null); file.addItem("Neue Struktur", menuCommand); file.addItem("Neues Gert", menuCommand); MenuBar.MenuItem data = menubar.addItem("Dateien", null); data.addItem("ffne Config", menuCommand); data.addItem("Autocreate an", menuCommand); data.addItem("Autocreate aus", menuCommand); MenuBar.MenuItem save = menubar.addItem("Speichern", null); return menubar; }
From source file:de.gedoplan.webclients.vaadin.VaadinDemoUi.java
public MenuBar createMenu() { User user = userProvider.get();/* w w w .jav a2s.c o m*/ 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();/* www.j a v a 2 s . com*/ 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);//from ww w . ja va2s . 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.lmu.ifi.dbs.knowing.vaadin.MainApplication.java
License:Apache License
@SuppressWarnings("serial") private MenuBar getMenu() { MenuBar menubar = new MenuBar(); menubar.setWidth("100%"); homeMenu = menubar.addItem("Home", null); homeMenu.addItem("Run Process", new Command() { @Override//from w w w . j a va 2s. c om public void menuSelected(MenuItem selectedItem) { contentPanel.removeAllComponents(); contentPanel.addComponent(new DPUSelection()); } }); homeMenu.addItem("Show Services", new Command() { @Override public void menuSelected(MenuItem selectedItem) { contentPanel.removeAllComponents(); contentPanel.addComponent(ComponentFactory.processorTable()); } }); homeMenu.addSeparator(); homeMenu.addItem("Logout", new Command() { @Override public void menuSelected(MenuItem selectedItem) { main.showNotification("Run your own DPU soon!"); } }); final MenuBar.MenuItem viewMenu = menubar.addItem("Help", null); viewMenu.addItem("About...", new Command() { @Override public void menuSelected(MenuItem selectedItem) { main.addWindow(getAboutDialog()); } }); return menubar; }
From source file:de.mendelson.comm.as2.webclient2.AS2WebUI.java
private MenuBar createMenuBar() { MenuBar.Command logoutCommand = new MenuBar.Command() { @Override// w w w . j av a 2 s . com 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.caze.CaseContactsView.java
License:Open Source License
public HorizontalLayout createStatusFilterBar() { HorizontalLayout statusFilterLayout = new HorizontalLayout(); statusFilterLayout.setSpacing(true); statusFilterLayout.setWidth("100%"); statusFilterLayout.addStyleName(CssStyles.VSPACE_3); statusButtons = new HashMap<>(); Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> { criteria.contactStatus(null);/* ww w .ja v a2 s . com*/ navigateTo(criteria); }); CssStyles.style(statusAll, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER); statusAll.setCaptionAsHtml(true); statusFilterLayout.addComponent(statusAll); statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all)); activeStatusButton = statusAll; for (ContactStatus status : ContactStatus.values()) { Button statusButton = new Button(status.toString(), e -> { criteria.contactStatus(status); navigateTo(criteria); }); statusButton.setData(status); CssStyles.style(statusButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT); statusButton.setCaptionAsHtml(true); statusFilterLayout.addComponent(statusButton); statusButtons.put(statusButton, status.toString()); } statusFilterLayout .setExpandRatio(statusFilterLayout.getComponent(statusFilterLayout.getComponentCount() - 1), 1); // Bulk operation dropdown if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { statusFilterLayout.setWidth(100, Unit.PERCENTAGE); MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command changeCommand = selectedItem -> { ControllerProvider.getContactController().showBulkContactDataEditComponent( grid.asMultiSelect().getSelectedItems(), getCaseRef().getUuid()); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, changeCommand); Command cancelFollowUpCommand = selectedItem -> { ControllerProvider.getContactController() .cancelFollowUpOfAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.deselectAll(); grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkCancelFollowUp), VaadinIcons.CLOSE, cancelFollowUpCommand); Command lostToFollowUpCommand = selectedItem -> { ControllerProvider.getContactController().setAllSelectedItemsToLostToFollowUp( grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.deselectAll(); grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkLostToFollowUp), VaadinIcons.UNLINK, lostToFollowUpCommand); Command deleteCommand = selectedItem -> { ControllerProvider.getContactController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.deselectAll(); grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); statusFilterLayout.addComponent(bulkOperationsDropdown); statusFilterLayout.setComponentAlignment(bulkOperationsDropdown, Alignment.TOP_RIGHT); statusFilterLayout.setExpandRatio(bulkOperationsDropdown, 1); } if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_EXPORT)) { Button exportButton = new Button(I18nProperties.getCaption(Captions.export)); exportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); exportButton.setIcon(VaadinIcons.DOWNLOAD); StreamResource streamResource = new GridExportStreamResource(grid, "sormas_contacts", "sormas_contacts_" + DateHelper.formatDateForExport(new Date()) + ".csv"); FileDownloader fileDownloader = new FileDownloader(streamResource); fileDownloader.extend(exportButton); statusFilterLayout.addComponent(exportButton); statusFilterLayout.setComponentAlignment(exportButton, Alignment.MIDDLE_RIGHT); if (!UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { statusFilterLayout.setExpandRatio(exportButton, 1); } } if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_CREATE)) { newButton = new Button( I18nProperties.getPrefixCaption(ContactDto.I18N_PREFIX, Captions.contactNewContact)); newButton.addStyleName(ValoTheme.BUTTON_PRIMARY); newButton.setIcon(VaadinIcons.PLUS_CIRCLE); newButton.addClickListener(e -> ControllerProvider.getContactController().create(this.getCaseRef())); statusFilterLayout.addComponent(newButton); statusFilterLayout.setComponentAlignment(newButton, Alignment.MIDDLE_RIGHT); } statusFilterLayout.addStyleName("top-bar"); activeStatusButton = statusAll; return statusFilterLayout; }
From source file:de.symeda.sormas.ui.caze.CasesView.java
License:Open Source License
public HorizontalLayout createStatusFilterBar() { HorizontalLayout statusFilterLayout = new HorizontalLayout(); statusFilterLayout.setSpacing(true); statusFilterLayout.setMargin(false); statusFilterLayout.setWidth(100, Unit.PERCENTAGE); statusFilterLayout.addStyleName(CssStyles.VSPACE_3); statusButtons = new HashMap<>(); Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> { criteria.investigationStatus(null); navigateTo(criteria);/*from w w w .j ava2 s .c o m*/ }); CssStyles.style(statusAll, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER); statusAll.setCaptionAsHtml(true); statusFilterLayout.addComponent(statusAll); statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all)); activeStatusButton = statusAll; for (InvestigationStatus status : InvestigationStatus.values()) { Button statusButton = new Button(status.toString(), e -> { criteria.investigationStatus(status); navigateTo(criteria); }); statusButton.setData(status); CssStyles.style(statusButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT); statusButton.setCaptionAsHtml(true); statusFilterLayout.addComponent(statusButton); statusButtons.put(statusButton, status.toString()); } HorizontalLayout actionButtonsLayout = new HorizontalLayout(); actionButtonsLayout.setSpacing(true); { // Show archived/active cases button if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW_ARCHIVED)) { switchArchivedActiveButton = new Button(I18nProperties.getCaption(Captions.caseShowArchived)); switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK); switchArchivedActiveButton.addClickListener(e -> { criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE); navigateTo(criteria); }); actionButtonsLayout.addComponent(switchArchivedActiveButton); } // Bulk operation dropdown if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command changeCommand = selectedItem -> { ControllerProvider.getCaseController() .showBulkCaseDataEditComponent(grid.asMultiSelect().getSelectedItems()); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, changeCommand); Command deleteCommand = selectedItem -> { ControllerProvider.getCaseController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); Command archiveCommand = selectedItem -> { ControllerProvider.getCaseController() .archiveAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; archiveItem = bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.actionArchive), VaadinIcons.ARCHIVE, archiveCommand); Command dearchiveCommand = selectedItem -> { ControllerProvider.getCaseController() .dearchiveAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; dearchiveItem = bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.actionDearchive), VaadinIcons.ARCHIVE, dearchiveCommand); dearchiveItem.setVisible(false); actionButtonsLayout.addComponent(bulkOperationsDropdown); } } statusFilterLayout.addComponent(actionButtonsLayout); statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT); statusFilterLayout.setExpandRatio(actionButtonsLayout, 1); return statusFilterLayout; }
From source file:de.symeda.sormas.ui.contact.ContactsView.java
License:Open Source License
public HorizontalLayout createStatusFilterBar() { HorizontalLayout statusFilterLayout = new HorizontalLayout(); statusFilterLayout.setMargin(false); statusFilterLayout.setSpacing(true); statusFilterLayout.setWidth(100, Unit.PERCENTAGE); statusFilterLayout.addStyleName(CssStyles.VSPACE_3); statusButtons = new HashMap<>(); Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> { criteria.contactStatus(null);/*from ww w .jav a 2 s .c om*/ navigateTo(criteria); }); CssStyles.style(statusAll, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER); statusAll.setCaptionAsHtml(true); statusFilterLayout.addComponent(statusAll); statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all)); activeStatusButton = statusAll; for (ContactStatus status : ContactStatus.values()) { Button statusButton = new Button(status.toString(), e -> { criteria.contactStatus(status); navigateTo(criteria); }); statusButton.setData(status); CssStyles.style(statusButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT); statusButton.setCaptionAsHtml(true); statusFilterLayout.addComponent(statusButton); statusButtons.put(statusButton, status.toString()); } HorizontalLayout actionButtonsLayout = new HorizontalLayout(); actionButtonsLayout.setSpacing(true); { // Show archived/active cases button if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW_ARCHIVED)) { switchArchivedActiveButton = new Button(I18nProperties.getCaption(Captions.contactShowArchived)); switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK); switchArchivedActiveButton.addClickListener(e -> { criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE); navigateTo(criteria); }); actionButtonsLayout.addComponent(switchArchivedActiveButton); } // Bulk operation dropdown if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { statusFilterLayout.setWidth(100, Unit.PERCENTAGE); MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command changeCommand = selectedItem -> { ControllerProvider.getContactController() .showBulkContactDataEditComponent(grid.asMultiSelect().getSelectedItems(), null); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, changeCommand); Command cancelFollowUpCommand = selectedItem -> { ControllerProvider.getContactController().cancelFollowUpOfAllSelectedItems( grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkCancelFollowUp), VaadinIcons.CLOSE, cancelFollowUpCommand); Command lostToFollowUpCommand = selectedItem -> { ControllerProvider.getContactController().setAllSelectedItemsToLostToFollowUp( grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkLostToFollowUp), VaadinIcons.UNLINK, lostToFollowUpCommand); Command deleteCommand = selectedItem -> { ControllerProvider.getContactController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); actionButtonsLayout.addComponent(bulkOperationsDropdown); } } statusFilterLayout.addComponent(actionButtonsLayout); statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT); statusFilterLayout.setExpandRatio(actionButtonsLayout, 1); return statusFilterLayout; }