List of usage examples for com.vaadin.ui MenuBar addItem
public MenuBar.MenuItem addItem(String caption, MenuBar.Command command)
From source file:org.jpos.qi.Header.java
License:Open Source License
@SuppressWarnings("unchecked") private MenuBar createMenu() { menuOptions = new LinkedHashMap<>(); MenuBar mb = new MenuBar(); mb.addStyleName(ValoTheme.MENUBAR_SMALL); mb.addStyleName(ValoTheme.MENUBAR_BORDERLESS); mb.setHtmlContentAllowed(true);/*from w w w .j ava 2s .c om*/ Element cfg = app.getXmlConfiguration(); if (cfg != null) { Element menubar = cfg.getChild("menubar"); if (menubar != null) { for (Element e : menubar.getChildren()) { addMenubarItem(mb, e); } } } userMenuItem = mb.addItem(app.getUser().getNick(), null); userMenuItem.setIcon(VaadinIcons.USER); userMenuItem.addItem("Profile", selectedItem -> { removeSelected(); app.navigateTo("/profile"); }); userMenuItem.addItem("Log Out", selectedItem -> app.logout()); return mb; }
From source file:org.jpos.qi.Header.java
License:Open Source License
private void addMenubarItem(MenuBar mb, Element e) { if ("menu".equals(e.getName())) { String perm = e.getAttributeValue("perm"); boolean allowed = perm == null || QI.getQI().getUser().hasPermission(perm); if (allowed) { MenuBar.MenuItem mi = mb.addItem(e.getAttributeValue("name"), selectedItem -> menuItemSelected(selectedItem, e)); decorate(mi, e);/*from ww w . j av a2s . c om*/ menuOptions.put(e.getAttributeValue("name"), mi); for (Element child : e.getChildren()) { addMenuItem(mi, child); } } } }
From source file:org.jumpmind.metl.ui.views.DeployNavigator.java
License:Open Source License
protected HorizontalLayout buildMenuBar() { HorizontalLayout layout = new HorizontalLayout(); layout.setWidth(100, Unit.PERCENTAGE); MenuBar leftMenuBar = new MenuBar(); leftMenuBar.addStyleName(ValoTheme.MENUBAR_BORDERLESS); leftMenuBar.setWidth(100, Unit.PERCENTAGE); MenuItem newMenu = leftMenuBar.addItem("New", null); newFolder = newMenu.addItem("Folder", new Command() { @Override/*from ww w .jav a 2s. c om*/ public void menuSelected(MenuItem selectedItem) { addFolder(); } }); newAgent = newMenu.addItem("Agent", new Command() { @Override public void menuSelected(MenuItem selectedItem) { addAgent(); } }); MenuItem editMenu = leftMenuBar.addItem("Edit", null); editMenu.addItem("Open", new Command() { @Override public void menuSelected(MenuItem selectedItem) { openItem(treeTable.getValue()); } }); editMenu.addItem("Rename", new Command() { @Override public void menuSelected(MenuItem selectedItem) { startEditingItem((AbstractObject) treeTable.getValue()); } }); delete = editMenu.addItem("Remove", new Command() { @Override public void menuSelected(MenuItem selectedItem) { handleDelete(); } }); MenuBar rightMenuBar = new MenuBar(); rightMenuBar.addStyleName(ValoTheme.MENUBAR_BORDERLESS); search = rightMenuBar.addItem("", Icons.SEARCH, new Command() { @Override public void menuSelected(MenuItem selectedItem) { search.setChecked(!search.isChecked()); searchBarLayout.setVisible(search.isChecked()); } }); search.setVisible(false); layout.addComponent(leftMenuBar); layout.addComponent(rightMenuBar); layout.setExpandRatio(leftMenuBar, 1); return layout; }
From source file:org.jumpmind.metl.ui.views.DesignNavigator.java
License:Open Source License
protected HorizontalLayout buildMenuBar() { HorizontalLayout layout = new HorizontalLayout(); layout.setWidth(100, Unit.PERCENTAGE); // left menu bar MenuBar leftMenuBar = new MenuBar(); leftMenuBar.addStyleName(ValoTheme.MENUBAR_BORDERLESS); leftMenuBar.setWidth(100, Unit.PERCENTAGE); // file menu/*from w ww. j a va2 s . co m*/ fileMenu = leftMenuBar.addItem("File", null); // file - new newMenu = fileMenu.addItem("New", null); newFlow = newMenu.addItem("Flow", selectedItem -> addNewFlow()); newModel = newMenu.addItem("Model", selectedItem -> addNewModel()); // file - new - resource resourceMenu = newMenu.addItem("Resource", null); newDataSource = resourceMenu.addItem("Database", selectedItem -> addNewDatabase()); newFtpResource = resourceMenu.addItem("FTP", selectedItem -> addNewFtpResource()); newFileResource = resourceMenu.addItem("Local File System", selectedItem -> addNewLocalFileSystem()); newSSHResource = resourceMenu.addItem("Sftp", selectedItem -> addNewSSHFileSystem()); newWebResource = resourceMenu.addItem("Web Resource", selectedItem -> addNewHttpResource()); newJMSResource = resourceMenu.addItem("JMS", selectedItem -> addNewJMSFileSystem()); // file - export exportMenu = fileMenu.addItem("Export...", selectedItem -> export()); // file - import importConfig = fileMenu.addItem("Import...", selecteItem -> importConfig()); // edit menu editMenu = leftMenuBar.addItem("Edit", null); editMenu.addItem("Open", selectedItem -> open(treeTable.getValue())); editMenu.addItem("Rename", selectedItem -> startEditingItem((AbstractObject) treeTable.getValue())); editMenu.addItem("Copy", selectedItem -> copySelected()); delete = editMenu.addItem("Remove", selectedItem -> handleDelete()); // project menu MenuItem projectMenu = leftMenuBar.addItem("Project", null); projectMenu.addItem("Manage", selectedItem -> viewProjects()); closeProject = projectMenu.addItem("Close", selectedItem -> closeProject()); // right menu MenuBar rightMenuBar = new MenuBar(); rightMenuBar.addStyleName(ValoTheme.MENUBAR_BORDERLESS); search = rightMenuBar.addItem("", Icons.SEARCH, new Command() { @Override public void menuSelected(MenuItem selectedItem) { search.setChecked(!search.isChecked()); searchBarLayout.setVisible(search.isChecked()); } }); search.setVisible(false); layout.addComponent(leftMenuBar); layout.addComponent(rightMenuBar); layout.setExpandRatio(leftMenuBar, 1); return layout; }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.SqlExplorer.java
License:Open Source License
protected MenuBar buildLeftMenu() { MenuBar leftMenu = new MenuBar(); leftMenu.addStyleName(ValoTheme.MENUBAR_BORDERLESS); leftMenu.setWidth(100, Unit.PERCENTAGE); MenuItem hideButton = leftMenu.addItem("", new Command() { private static final long serialVersionUID = 1L; @Override/* w ww. j av a 2s. co m*/ public void menuSelected(MenuItem selectedItem) { savedSplitPosition = getSplitPosition() > 10 ? getSplitPosition() : DEFAULT_SPLIT_POS; setSplitPosition(0); setLocked(true); showButton.setVisible(true); } }); hideButton.setDescription("Hide the database explorer"); hideButton.setIcon(FontAwesome.BARS); MenuItem refreshButton = leftMenu.addItem("", new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(MenuItem selectedItem) { dbTree.refresh(); Component tab = contentTabs.getSelectedTab(); if (tab instanceof QueryPanel) { findQueryPanelForDb(((QueryPanel) tab).db).suggester.clearCaches(); } } }); refreshButton.setIcon(FontAwesome.REFRESH); refreshButton.setDescription("Refresh the database explorer"); MenuItem openQueryTab = leftMenu.addItem("", new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(MenuItem selectedItem) { openQueryWindow(dbTree.getSelected()); } }); openQueryTab.setIcon(QUERY_ICON); openQueryTab.setDescription("Open a query tab"); MenuItem settings = leftMenu.addItem("", new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(MenuItem selectedItem) { SettingsDialog dialog = new SettingsDialog(SqlExplorer.this); dialog.showAtSize(.5); } }); settings.setIcon(FontAwesome.GEAR); settings.setDescription("Modify sql explorer settings"); return leftMenu; }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.SqlExplorer.java
License:Open Source License
protected void addShowButton(MenuBar contentMenuBar) { boolean visible = showButton != null ? showButton.isVisible() : false; showButton = contentMenuBar.addItem("", new Command() { private static final long serialVersionUID = 1L; @Override/*from w w w .j a v a 2s.c o m*/ public void menuSelected(MenuItem selectedItem) { setSplitPosition(savedSplitPosition, Unit.PIXELS); setLocked(false); showButton.setVisible(false); } }); showButton.setIcon(FontAwesome.BARS); showButton.setDescription("Show the database explorer"); showButton.setVisible(visible); }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.TabularResultLayout.java
License:Open Source License
private void createMenuBar() { HorizontalLayout resultBar = new HorizontalLayout(); resultBar.setWidth(100, Unit.PERCENTAGE); resultBar.setMargin(new MarginInfo(false, true, false, true)); HorizontalLayout leftBar = new HorizontalLayout(); leftBar.setSpacing(true);/*from w w w .j a va2 s. c o m*/ resultLabel = new Label("", ContentMode.HTML); leftBar.addComponent(resultLabel); final Label sqlLabel = new Label("", ContentMode.TEXT); sqlLabel.setWidth(800, Unit.PIXELS); leftBar.addComponent(sqlLabel); resultBar.addComponent(leftBar); resultBar.setComponentAlignment(leftBar, Alignment.MIDDLE_LEFT); resultBar.setExpandRatio(leftBar, 1); MenuBar rightBar = new MenuBar(); rightBar.addStyleName(ValoTheme.MENUBAR_BORDERLESS); rightBar.addStyleName(ValoTheme.MENUBAR_SMALL); MenuBar.MenuItem refreshButton = rightBar.addItem("", new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(MenuBar.MenuItem selectedItem) { listener.reExecute(sql); } }); refreshButton.setIcon(FontAwesome.REFRESH); MenuBar.MenuItem exportButton = rightBar.addItem("", new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(MenuBar.MenuItem selectedItem) { new ExportDialog(grid, db.getName(), sql).show(); } }); exportButton.setIcon(FontAwesome.UPLOAD); if (isInQueryGeneralResults) { MenuBar.MenuItem keepResultsButton = rightBar.addItem("", new Command() { private static final long serialVersionUID = 1L; @Override public void menuSelected(com.vaadin.ui.MenuBar.MenuItem selectedItem) { queryPanel.addResultsTab(refreshWithoutSaveButton(), StringUtils.abbreviate(sql, 20), queryPanel.getGeneralResultsTab().getIcon()); queryPanel.resetGeneralResultsTab(); } }); keepResultsButton.setIcon(FontAwesome.CLONE); keepResultsButton.setDescription("Save these results to a new tab"); } if (showSql) { sqlLabel.setValue(StringUtils.abbreviate(sql, 200)); } resultBar.addComponent(rightBar); resultBar.setComponentAlignment(rightBar, Alignment.MIDDLE_RIGHT); this.addComponent(resultBar, 0); }
From source file:org.kani.Application.java
License:Apache License
private MenuBar getMenu() { MenuBar menubar = new MenuBar(); menubar.setWidth("100%"); actionMenu = menubar.addItem("Action", null); actionMenu.addItem("Built-in Action...", new Command() { public void menuSelected(MenuItem selectedItem) { main.showNotification("Built-in Action executed!"); }/*w w w . j av a2 s . co m*/ }); final MenuBar.MenuItem viewMenu = menubar.addItem("Help", null); viewMenu.addItem("About...", new Command() { public void menuSelected(MenuItem selectedItem) { main.addWindow(getAboutDialog()); } }); return menubar; }
From source file:org.opencms.ui.sitemap.CmsSitemapTreeController.java
License:Open Source License
/** * Creates a sitemap tree node widget from a tree node bean.<p> * * @param entry the tree node bean/*from w ww . ja va2s . c om*/ * @return the tree node widget */ public CmsSitemapTreeNode createNode(final CmsSitemapTreeNodeData entry) { final CmsSitemapTreeNode node = new CmsSitemapTreeNode(); node.addLayoutClickListener(new LayoutClickListener() { private static final long serialVersionUID = 1L; @SuppressWarnings("synthetic-access") public void layoutClick(LayoutClickEvent event) { Component currentComponent = event.getClickedComponent(); if (currentComponent != null) { boolean linked = false; do { currentComponent = currentComponent.getParent(); if ((currentComponent != null) && "linked".equals(((AbstractComponent) currentComponent).getData())) { linked = true; } if (event.getClickedComponent() instanceof CmsResourceIcon) { if (currentComponent == node) { openTargetPage((CmsSitemapTreeNodeData) (node.getData()), linked); } else if (currentComponent instanceof CmsSitemapTreeNode) { break; } } } while (currentComponent != null); } } }); String icon = CmsResourceIcon.getSitemapResourceIcon(A_CmsUI.getCmsObject(), entry.getResource(), IconMode.localeCompare); CmsResourceInfo info = new CmsResourceInfo(entry.getClientEntry().getTitle(), entry.getClientEntry().getSitePath(), icon); info = CmsResourceInfo.createSitemapResourceInfo(entry.getResource(), OpenCms.getSiteManager().getSiteForRootPath(m_localeContext.getRoot().getRootPath())); info.getResourceIcon().addStyleName(OpenCmsTheme.POINTER); info.getResourceIcon() .setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_OPEN_PAGE_0)); if (entry.getClientEntry().isHiddenNavigationEntry()) { info.addStyleName(OpenCmsTheme.RESOURCE_INFO_WEAK); } final MenuBar menu = new MenuBar(); boolean noTranslation = false; noTranslation = entry.isMarkedNoTranslation(m_localeContext.getComparisonLocale()); final MenuItem main = menu.addItem("", null); main.setIcon(FontOpenCms.CONTEXT_MENU); CssLayout rightSide = new CssLayout(); info.setButtonWidget(rightSide); rightSide.addComponent(menu); main.setCommand(new Command() { /** Serial version id. */ private static final long serialVersionUID = 1L; public void menuSelected(MenuItem selectedItem) { List<I_CmsSimpleContextMenuEntry<MenuContext>> entries = Arrays.asList( new EntryOpen(), new EntryExplorer(), new EntryProperties(), new EntryLink(), new EntryUnlink(), new EntryMark(), new EntryRemoveMark(), new EntryCopy(), new EntryInfo()); MenuContext context = new MenuContext(entry, node); m_menu.setEntries(entries, context); m_menu.open(menu); } }); menu.addStyleName("borderless o-toolbar-button o-resourceinfo-toolbar"); if (entry.isLinked()) { CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(m_localeContext.getRoot().getRootPath()); CmsResourceInfo linkedInfo = CmsResourceInfo .createSitemapResourceInfo(readSitemapEntryFolderIfPossible(entry.getLinkedResource()), site); linkedInfo.addStyleName(OpenCmsTheme.RESOURCE_INFO_DIRECTLINK); rightSide.addComponent(linkedInfo, 0); linkedInfo.setWidth(RHS_WIDTH + "px"); node.setContent(info); linkedInfo.setData("linked"); // Data used by click handler to distinguish clicked resource icons linkedInfo.getResourceIcon() .setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_OPEN_PAGE_0)); linkedInfo.getResourceIcon().addStyleName(OpenCmsTheme.POINTER); } else { if (noTranslation) { CmsResourceInfo noTranslationInfo = new CmsResourceInfo(); String topMessage = CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_NO_TRANSLATION_TOP_0); String bottomMessage = CmsVaadinUtils .getMessageText(Messages.GUI_LOCALECOMPARE_NO_TRANSLATION_BOTTOM_0); noTranslationInfo.getTopLine().setValue(topMessage); noTranslationInfo.getBottomLine().setValue(bottomMessage); noTranslationInfo.getResourceIcon().setValue("<span class=\"" + OpenCmsTheme.RESOURCE_ICON + " " + OpenCmsTheme.NO_TRANSLATION_ICON + "\">" + FontAwesome.BAN.getHtml() + "</span>"); noTranslationInfo.addStyleName(OpenCmsTheme.RESOURCE_INFO_DIRECTLINK); noTranslationInfo.setWidth(RHS_WIDTH + "px"); rightSide.addComponent(noTranslationInfo, 0); } node.setContent(info); } if (entry.hasNoChildren()) { node.setOpen(true); node.setOpenerVisible(false); } node.setData(entry); return node; }
From source file:org.openeos.services.ui.vaadin.internal.VaadinMenuContributor.java
License:Apache License
@Override public void contribute(MenuBar menuBar, IUnoVaadinApplication application) { Collections.sort(menuList, new Comparator<MenuContributor>() { @Override//from w w w .j a v a 2s . c om public int compare(MenuContributor o1, MenuContributor o2) { return new Integer(o1.getOrder()).compareTo(o2.getOrder()); } }); for (MenuContributor contributor : menuList) { for (IMenuDefinition menu : contributor.getRootMenuDefinitionList()) { MenuItem menuItem = menuBar.addItem(menu.getName(), createAction(menu, application)); addRecursiveMenus(contributor, contributor.getChildMenuDefinitionList(menu), menuItem, application); } } }