Example usage for com.vaadin.ui MenuBar MenuBar

List of usage examples for com.vaadin.ui MenuBar MenuBar

Introduction

In this page you can find the example usage for com.vaadin.ui MenuBar MenuBar.

Prototype

public MenuBar() 

Source Link

Document

Constructs an empty, horizontal menu.

Usage

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   w w  w.  j  a  va 2s . c o  m*/
        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  w  w. j av  a2  s .c om
    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.metl.ui.views.ManageNavigator.java

License:Open Source License

public ManageNavigator(FolderType folderType, ApplicationContext context) {
    this.context = context;

    setSizeFull();/*from   w  w  w . jav  a2s . c  o m*/

    addStyleName(ValoTheme.MENU_ROOT);

    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();
    setContent(content);

    MenuBar leftMenuBar = new MenuBar();
    leftMenuBar.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    leftMenuBar.setWidth(100, Unit.PERCENTAGE);
    content.addComponent(leftMenuBar);

    treeTable = buildTreeTable();
    content.addComponent(treeTable);
    content.setExpandRatio(treeTable, 1);

    agentsFolder = new Folder();
    agentsFolder.setName("Agents");

    flowsFolder = new Folder();
    flowsFolder.setName("Flows");
}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.SqlExplorer.java

License:Open Source License

public SqlExplorer(String configDir, IDbProvider databaseProvider, ISettingsProvider settingsProvider,
        String user, float leftSplitSize, IDbMenuItem... additionalMenuItems) {
    this.databaseProvider = databaseProvider;
    this.settingsProvider = settingsProvider;
    this.savedSplitPosition = leftSplitSize;
    this.additionalMenuItems = additionalMenuItems;

    setSizeFull();/*ww w. j av a 2 s.c  o  m*/
    addStyleName("sqlexplorer");

    VerticalLayout leftLayout = new VerticalLayout();
    leftLayout.setSizeFull();
    leftLayout.addStyleName(ValoTheme.MENU_ROOT);

    leftLayout.addComponent(buildLeftMenu());

    Panel scrollable = new Panel();
    scrollable.setSizeFull();

    dbTree = buildDbTree();
    scrollable.setContent(dbTree);

    leftLayout.addComponent(scrollable);
    leftLayout.setExpandRatio(scrollable, 1);

    VerticalLayout rightLayout = new VerticalLayout();
    rightLayout.setSizeFull();

    VerticalLayout rightMenuWrapper = new VerticalLayout();
    rightMenuWrapper.setWidth(100, Unit.PERCENTAGE);
    rightMenuWrapper.addStyleName(ValoTheme.MENU_ROOT);
    contentMenuBar = new MenuBar();
    contentMenuBar.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    contentMenuBar.setWidth(100, Unit.PERCENTAGE);
    addShowButton(contentMenuBar);

    rightMenuWrapper.addComponent(contentMenuBar);
    rightLayout.addComponent(rightMenuWrapper);

    contentTabs = new SqlExplorerTabPanel();
    contentTabs.addSelectedTabChangeListener(new SelectedTabChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            selectContentTab((IContentTab) contentTabs.getSelectedTab());
        }
    });
    rightLayout.addComponent(contentTabs);
    rightLayout.setExpandRatio(contentTabs, 1);

    addComponents(leftLayout, rightLayout);

    setSplitPosition(savedSplitPosition, Unit.PIXELS);
}

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/*from w w  w  .j av a 2 s  . com*/
        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.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);//w w w  .  ja v  a2  s . c om
    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!");
        }//  www  . ja  va 2s. c o  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// w w  w .ja v  a2  s . co  m
 * @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.vaadin.main.internal.MainApplication.java

License:Apache License

private MenuBar getMenu() {
    menubar = new MenuBar();
    menubar.setWidth("100%");
    //      actionMenu = menubar.addItem("Action", null);
    ////from  w w  w.  ja v a 2 s  .  com
    //      actionMenu.addItem("Built-in Action...", new Command() {
    //         @Override
    //         public void menuSelected(MenuItem selectedItem) {
    //            main.showNotification("Built-in Action executed!");
    //         }
    //      });
    //      actionMenu.addSeparator();

    return menubar;
}

From source file:org.opennms.features.topology.app.internal.menu.MenuBuilder.java

License:Open Source License

/**
 * Converts the current menu configuration to Vaadin's {@link MenuBar} representation.
 *
 * @param targets The current targets (e.g. the selection)
 * @param operationContext The current {@link OperationContext}.
 * @param hooks Optional hooks to be executed after a menu item's command has been executed.
 * @return The converted {@link MenuBar}
 *//*  w w  w .j a  v a2s  . co  m*/
public MenuBar build(List<VertexRef> targets, OperationContext operationContext, Runnable... hooks) {
    MenuBar menuBar = new MenuBar();
    apply(menuBar, targets, operationContext, hooks);
    return menuBar;
}