Example usage for com.vaadin.ui MenuBar addItem

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

Introduction

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

Prototype

public MenuBar.MenuItem addItem(String caption, MenuBar.Command command) 

Source Link

Document

Add a new item to the menu bar.

Usage

From source file:annis.gui.components.NavigateableSinglePage.java

License:Apache License

private MenuBar createMenubarFromHTML(File localFile, URI externalURI, Map<String, MenuItem> idToMenuItem) {

    MenuBar mbNavigation = new MenuBar();
    mbNavigation.setStyleName("huge");
    MenuItem navRoot = mbNavigation.addItem("Choose topic", null);
    navRoot.setStyleName("huge");

    try (FileInputStream input = new FileInputStream(localFile)) {
        Document doc = Jsoup.parse(input, "UTF-8", externalURI.toASCIIString());

        ArrayList<MenuItem> itemPath = new ArrayList<>();
        // find all headers that have an ID
        for (Element e : doc.getElementsByAttribute("id")) {
            Matcher m = regexHeader.matcher(e.tagName());
            if (m.matches()) {
                int level = Integer.parseInt(m.group(1)) - 1;

                // decide wether to expand the path (one level deeper) or to truncate
                if (level == 0) {
                    itemPath.clear();//from   w ww .  ja v  a 2 s . co  m
                } else if (itemPath.size() >= level) {
                    // truncate
                    itemPath = new ArrayList<>(itemPath.subList(0, level));
                }

                if (itemPath.isEmpty() && level > 0) {
                    // fill the path with empty elements
                    for (int i = 0; i < level; i++) {
                        itemPath.add(createItem(navRoot, itemPath, "<empty>", null));
                    }
                }
                MenuItem item = createItem(navRoot, itemPath, e.text(), e.id());
                itemPath.add(item);
                idToMenuItem.put(e.id(), item);
            }
        }
    } catch (IOException ex) {
        log.error("Could not parse iframe source", ex);
    }
    return mbNavigation;
}

From source file:annis.gui.resultview.ResultViewPanel.java

License:Apache License

public ResultViewPanel(AnnisUI ui, PluginSystem ps, InstanceConfig instanceConfig,
        DisplayedResultQuery initialQuery) {
    this.sui = ui;
    this.tokenAnnoVisible = new TreeMap<>();
    this.ps = ps;
    this.controller = ui.getQueryController();
    this.initialQuery = initialQuery;

    cacheResolver = Collections//from www . j a  v  a2 s .  c o  m
            .synchronizedMap(new HashMap<HashSet<SingleResolverRequest>, List<ResolverEntry>>());

    resultPanelList = Collections.synchronizedList(new LinkedList<SingleResultPanel>());

    resultLayout = new CssLayout();
    resultLayout.addStyleName("result-view-css");
    Panel resultPanel = new Panel(resultLayout);
    resultPanel.setSizeFull();
    resultPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    resultPanel.addStyleName("result-view-panel");

    this.instanceConfig = instanceConfig;

    setSizeFull();
    setMargin(false);

    MenuBar mbResult = new MenuBar();
    mbResult.setWidth("100%");
    mbResult.addStyleName("menu-hover");
    addComponent(mbResult);

    miSegmentation = mbResult.addItem("Base text", null);
    miTokAnnos = mbResult.addItem("Token Annotations", null);

    addComponent(resultPanel);

    setExpandRatio(mbResult, 0.0f);
    setExpandRatio(resultPanel, 1.0f);

    paging = new PagingComponent();

    addComponent(paging, 1);

    setComponentAlignment(paging, Alignment.TOP_CENTER);
    setExpandRatio(paging, 0.0f);
}

From source file:at.peppol.webgui.app.MainWindow.java

License:Mozilla Public License

private void createMenuBar() {

    topBarLayout.setMargin(false, false, false, false);
    topBarLayout.setSizeFull();/*from   www. ja v  a 2s. c  o m*/
    // topBarLayout.setStyleName("v-menubar");
    topBarLayoutLeft = new HorizontalLayout();
    topBarLayoutRight = new HorizontalLayout();

    // Label pawgLabel = new Label("PAWG",Label.CONTENT_XHTML);
    // pawgLabel.setStyleName("v-menubar");
    // pawgLabel.addStyleName("v-label-big");
    // pawgLabel.setSizeFull();
    // topBarLayoutLeft.addComponent(pawgLabel);

    final MenuBar lMenuBar = new MenuBar();
    lMenuBar.setHtmlContentAllowed(true);
    lMenuBar.addItem("<b>PAWG<b>", new MenuBar.Command() {

        @Override
        public void menuSelected(final MenuItem selectedItem) {

            removeComponent(mainContentComponent);
            showInitialMainContent(um.getDrafts());
        }
    });
    final MenuBar.MenuItem docItem = lMenuBar.addItem("Document", null);
    lMenuBar.addItem("Preferences", null);
    lMenuBar.addItem("Logout", new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            PawgApp.getInstance().logout();
            PawgApp.getInstance().showLoginWindow();
        }
    });
    lMenuBar.addItem("About", null);
    lMenuBar.setSizeFull();

    final MenuBar.MenuItem invItem = docItem.addItem("Invoice", null);
    final MenuBar.MenuItem orderItem = docItem.addItem("Order", null);
    invItem.addItem("New ...", new MenuBar.Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            showInvoiceForm();
            //showInvoiceForm (null);
        }
    });
    invItem.addItem("View ... ", new MenuBar.Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            showTestForm();
        }
    });
    invItem.addItem("Upload ...", new MenuBar.Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            showInvUploadWindow();
        }
    });

    orderItem.addItem("New", null);
    orderItem.addItem("View", null);
    orderItem.addItem("Upload ...", new MenuBar.Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            showOrdUploadWindow();
        }
    });

    topBarLayoutLeft.addComponent(lMenuBar);

    final IUser user = (IUser) PawgApp.getInstance().getUser();

    topBarLayoutLeft.setComponentAlignment(lMenuBar, Alignment.MIDDLE_CENTER);
    topBarLayoutLeft.setSpacing(false);
    topBarLayoutLeft.setSizeFull();
    topBarLayoutRight.setSizeUndefined();

    final MenuBar rMenuBar = new MenuBar();
    rMenuBar.setHtmlContentAllowed(true);
    final MenuBar.MenuItem userLabel = rMenuBar.addItem("<b>" + user.getEmailAddress() + "<b>", null);
    userLabel.addItem("Logout", new MenuBar.Command() {
        @Override
        public void menuSelected(final MenuItem selectedItem) {
            PawgApp.getInstance().logout();
        }
    });
    topBarLayoutRight.addComponent(rMenuBar);
    topBarLayout.addComponent(topBarLayoutLeft);
    topBarLayout.addComponent(topBarLayoutRight);
    topBarLayout.setComponentAlignment(topBarLayoutRight, Alignment.MIDDLE_RIGHT);
    topBarLayout.setExpandRatio(topBarLayoutLeft, 1);
    // topBarLayout.setExpandRatio(topBarLayoutRight, 1);
    addComponent(topBarLayout);

}

From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java

License:Apache License

Panel windows() {
    Panel p = new Panel("Dialogs");
    VerticalLayout content = new VerticalLayout() {
        final Window win = new Window("Window Caption");
        String prevHeight = "300px";
        boolean footerVisible = true;
        boolean autoHeight = false;
        boolean tabsVisible = false;
        boolean toolbarVisible = false;
        boolean footerToolbar = false;
        boolean toolbarLayout = false;
        String toolbarStyle = null;

        VerticalLayout windowContent() {
            VerticalLayout root = new VerticalLayout();

            if (toolbarVisible) {
                MenuBar menuBar = MenuBars.getToolBar();
                menuBar.setSizeUndefined();
                menuBar.setStyleName(toolbarStyle);
                Component toolbar = menuBar;
                if (toolbarLayout) {
                    menuBar.setWidth(null);
                    HorizontalLayout toolbarLayout = new HorizontalLayout();
                    toolbarLayout.setWidth("100%");
                    toolbarLayout.setSpacing(true);
                    Label label = new Label("Tools");
                    label.setSizeUndefined();
                    toolbarLayout.addComponents(label, menuBar);
                    toolbarLayout.setExpandRatio(menuBar, 1);
                    toolbarLayout.setComponentAlignment(menuBar, Alignment.TOP_RIGHT);
                    toolbar = toolbarLayout;
                }/*from  w  w w  .  j  a  va2  s  .  c om*/
                toolbar.addStyleName("v-window-top-toolbar");
                root.addComponent(toolbar);
            }

            Component content = null;

            if (tabsVisible) {
                TabSheet tabs = new TabSheet();
                tabs.setSizeFull();
                VerticalLayout l = new VerticalLayout();
                l.addComponent(new Label(
                        "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>",
                        ContentMode.HTML));
                l.setMargin(true);
                tabs.addTab(l, "Selected");
                tabs.addTab(new Label("&nbsp;", ContentMode.HTML), "Another");
                tabs.addTab(new Label("&nbsp;", ContentMode.HTML), "One more");
                tabs.addStyleName("padded-tabbar");
                tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() {
                    @Override
                    public void selectedTabChange(final SelectedTabChangeEvent event) {
                        try {
                            Thread.sleep(600);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                });
                content = tabs;
            } else if (!autoHeight) {
                Panel p = new Panel();
                p.setSizeFull();
                p.addStyleName("borderless");
                if (!toolbarVisible || !toolbarLayout) {
                    p.addStyleName("scroll-divider");
                }
                VerticalLayout l = new VerticalLayout();
                l.addComponent(new Label(
                        "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>",
                        ContentMode.HTML));
                l.setMargin(true);
                p.setContent(l);
                content = p;
            } else {
                content = new Label(
                        "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>",
                        ContentMode.HTML);
                root.setMargin(true);
            }

            root.addComponent(content);

            if (footerVisible) {
                HorizontalLayout footer = new HorizontalLayout();
                footer.setWidth("100%");
                footer.setSpacing(true);
                footer.addStyleName("v-window-bottom-toolbar");

                Label footerText = new Label("Footer text");
                footerText.setSizeUndefined();

                Button ok = new Button("OK");
                ok.addStyleName("primary");

                Button cancel = new Button("Cancel");

                footer.addComponents(footerText, ok, cancel);
                footer.setExpandRatio(footerText, 1);

                if (footerToolbar) {
                    MenuBar menuBar = MenuBars.getToolBar();
                    menuBar.setStyleName(toolbarStyle);
                    menuBar.setWidth(null);
                    footer.removeAllComponents();
                    footer.addComponent(menuBar);
                }

                root.addComponent(footer);
            }

            if (!autoHeight) {
                root.setSizeFull();
                root.setExpandRatio(content, 1);
            }

            return root;
        }

        {
            setSpacing(true);
            setMargin(true);
            win.setWidth("380px");
            win.setHeight(prevHeight);
            win.setClosable(false);
            win.setResizable(false);
            win.setContent(windowContent());
            win.setCloseShortcut(KeyCode.ESCAPE, null);

            Command optionsCommand = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    if (selectedItem.getText().equals("Footer")) {
                        footerVisible = selectedItem.isChecked();
                    }
                    if (selectedItem.getText().equals("Auto Height")) {
                        autoHeight = selectedItem.isChecked();
                        if (!autoHeight) {
                            win.setHeight(prevHeight);
                        } else {
                            prevHeight = win.getHeight() + win.getHeightUnits().toString();
                            win.setHeight(null);
                        }
                    }
                    if (selectedItem.getText().equals("Tabs")) {
                        tabsVisible = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Top")) {
                        toolbarVisible = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Footer")) {
                        footerToolbar = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Top layout")) {
                        toolbarLayout = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Borderless")) {
                        toolbarStyle = selectedItem.isChecked() ? "borderless" : null;
                    }

                    win.setContent(windowContent());
                }
            };

            MenuBar options = new MenuBar();
            options.setCaption("Content");
            options.addItem("Auto Height", optionsCommand).setCheckable(true);
            options.addItem("Tabs", optionsCommand).setCheckable(true);
            MenuItem option = options.addItem("Footer", optionsCommand);
            option.setCheckable(true);
            option.setChecked(true);
            options.addStyleName("small");
            addComponent(options);

            options = new MenuBar();
            options.setCaption("Toolbars");
            options.addItem("Footer", optionsCommand).setCheckable(true);
            options.addItem("Top", optionsCommand).setCheckable(true);
            options.addItem("Top layout", optionsCommand).setCheckable(true);
            options.addItem("Borderless", optionsCommand).setCheckable(true);
            options.addStyleName("small");
            addComponent(options);

            Command optionsCommand2 = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    if (selectedItem.getText().equals("Caption")) {
                        win.setCaption(selectedItem.isChecked() ? "Window Caption" : null);
                    } else if (selectedItem.getText().equals("Closable")) {
                        win.setClosable(selectedItem.isChecked());
                    } else if (selectedItem.getText().equals("Resizable")) {
                        win.setResizable(selectedItem.isChecked());
                    } else if (selectedItem.getText().equals("Modal")) {
                        win.setModal(selectedItem.isChecked());
                    }
                }
            };

            options = new MenuBar();
            options.setCaption("Options");
            MenuItem caption = options.addItem("Caption", optionsCommand2);
            caption.setCheckable(true);
            caption.setChecked(true);
            options.addItem("Closable", optionsCommand2).setCheckable(true);
            options.addItem("Resizable", optionsCommand2).setCheckable(true);
            options.addItem("Modal", optionsCommand2).setCheckable(true);
            options.addStyleName("small");
            addComponent(options);

            final Button show = new Button("Open Window", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    getUI().addWindow(win);
                    win.center();
                    win.focus();
                    event.getButton().setEnabled(false);
                }
            });
            show.addStyleName("primary");
            addComponent(show);

            final CheckBox hidden = new CheckBox("Hidden");
            hidden.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    win.setVisible(!hidden.getValue());
                }
            });
            addComponent(hidden);

            win.addCloseListener(new CloseListener() {
                @Override
                public void windowClose(final CloseEvent e) {
                    show.setEnabled(true);
                }
            });
        }
    };
    p.setContent(content);
    return p;

}

From source file:com.cavisson.gui.dashboard.components.controls.Dragging.java

License:Apache License

public Dragging() {
    setMargin(true);/*w w  w .  ja v  a2 s.c o m*/
    setSpacing(true);

    Label h1 = new Label("Dragging Components");
    h1.addStyleName("h1");
    addComponent(h1);

    MenuBar options = new MenuBar();
    options.setCaption("Drop Hints");
    addComponent(options);

    // Use these styles to hide irrelevant drag hints
    // Can be used either on a parent or directly on the DnDWrapper
    MenuItem opt = options.addItem("Vertical", new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            if (selectedItem.isChecked()) {
                sample.removeStyleName("no-vertical-drag-hints");
            } else {
                sample.addStyleName("no-vertical-drag-hints");
            }
        }
    });
    opt.setCheckable(true);
    opt.setChecked(true);

    opt = options.addItem("Horizontal", new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            if (selectedItem.isChecked()) {
                sample.removeStyleName("no-horizontal-drag-hints");
            } else {
                sample.addStyleName("no-horizontal-drag-hints");
            }
        }
    });
    opt.setCheckable(true);
    opt.setChecked(true);

    opt = options.addItem("Box", new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            if (selectedItem.isChecked()) {
                sample.removeStyleName("no-box-drag-hints");
            } else {
                sample.addStyleName("no-box-drag-hints");
            }
        }
    });
    opt.setCheckable(true);
    opt.setChecked(true);

    sample = new SortableLayout();
    sample.setSizeUndefined();
    sample.setHeight("100px");

    for (final Component component : createComponents()) {
        sample.addComponent(component);
    }

    addComponent(sample);

}

From source file:com.cavisson.gui.dashboard.components.controls.MenuBars.java

License:Apache License

static MenuBar getMenuBar() {
    Command click = new Command() {
        @Override// w  w  w .  j  ava 2 s  . co m
        public void menuSelected(MenuItem selectedItem) {
            Notification.show("Clicked " + selectedItem.getText());
        }
    };

    MenuBar menubar = new MenuBar();
    menubar.setWidth("100%");
    final MenuBar.MenuItem file = menubar.addItem("File", null);
    final MenuBar.MenuItem newItem = file.addItem("New", null);
    file.addItem("Open file...", click);
    file.addSeparator();

    newItem.addItem("File", click);
    newItem.addItem("Folder", click);
    newItem.addItem("Project...", click);

    file.addItem("Close", click);
    file.addItem("Close All", click);
    file.addSeparator();

    file.addItem("Save", click);
    file.addItem("Save As...", click);
    file.addItem("Save All", click);

    final MenuBar.MenuItem edit = menubar.addItem("Edit", null);
    edit.addItem("Undo", click);
    edit.addItem("Redo", click).setEnabled(false);
    edit.addSeparator();

    edit.addItem("Cut", click);
    edit.addItem("Copy", click);
    edit.addItem("Paste", click);
    edit.addSeparator();

    final MenuBar.MenuItem find = edit.addItem("Find/Replace", null);

    find.addItem("Google Search", click);
    find.addSeparator();
    find.addItem("Find/Replace...", click);
    find.addItem("Find Next", click);
    find.addItem("Find Previous", click);

    Command check = new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            Notification.show(selectedItem.isChecked() ? "Checked" : "Unchecked");
        }
    };

    final MenuBar.MenuItem view = menubar.addItem("View", null);
    view.addItem("Show Status Bar", check).setCheckable(true);
    MenuItem title = view.addItem("Show Title Bar", check);
    title.setCheckable(true);
    title.setChecked(true);
    view.addItem("Customize Toolbar...", click);
    view.addSeparator();

    view.addItem("Actual Size", click);
    view.addItem("Zoom In", click);
    view.addItem("Zoom Out", click);

    TestIcon testIcon = new TestIcon(50);

    MenuItem fav = menubar.addItem("", check);
    fav.setIcon(testIcon.get());
    fav.setStyleName("icon-only");
    fav.setCheckable(true);
    fav.setChecked(true);

    fav = menubar.addItem("", check);
    fav.setIcon(testIcon.get());
    fav.setStyleName("icon-only");
    fav.setCheckable(true);
    fav.setCheckable(true);

    menubar.addItem("Attach", click).setIcon(FontAwesome.PAPERCLIP);
    menubar.addItem("Undo", click).setIcon(FontAwesome.UNDO);
    MenuItem redo = menubar.addItem("Redo", click);
    redo.setIcon(FontAwesome.REPEAT);
    redo.setEnabled(false);
    menubar.addItem("Upload", click).setIcon(FontAwesome.UPLOAD);

    return menubar;
}

From source file:com.cavisson.gui.dashboard.components.controls.MenuBars.java

License:Apache License

static MenuBar getToolBar() {
    MenuBar menubar = new MenuBar();
    menubar.setWidth("100%");

    MenuItem fav = menubar.addItem("", null);
    fav.setIcon(FontAwesome.ALIGN_LEFT);
    fav.setStyleName("icon-only");
    fav.setCheckable(true);/*from   www. ja v a 2 s.co  m*/
    // fav.setChecked(true);

    fav = menubar.addItem("", null);
    fav.setIcon(FontAwesome.ALIGN_CENTER);
    fav.setStyleName("icon-only");
    fav.setCheckable(true);

    fav = menubar.addItem("", null);
    fav.setIcon(FontAwesome.ALIGN_RIGHT);
    fav.setStyleName("icon-only");
    fav.setCheckable(true);

    MenuItem clip = menubar.addItem("", null);
    clip.setIcon(FontAwesome.PAPERCLIP);
    clip.setStyleName("icon-only");

    MenuItem undo = menubar.addItem("", null);
    undo.setIcon(FontAwesome.UNDO);
    undo.setStyleName("icon-only");

    MenuItem redo = menubar.addItem("", null);
    redo.setIcon(FontAwesome.REPEAT);
    redo.setEnabled(false);
    redo.setStyleName("icon-only");

    return menubar;
}

From source file:com.cavisson.gui.dashboard.components.controls.MenuBars.java

License:Apache License

static MenuBar getMenuButton(String caption, boolean splitButton) {
    MenuBar split = new MenuBar();
    MenuBar.MenuItem dropdown = split.addItem(caption, null);
    if (splitButton) {
        dropdown = split.addItem("", null);
    }//from  w w w .  j  av  a 2s. c  o  m
    dropdown.addItem("Another Action", null);
    dropdown.addItem("Secondary Action", null);
    dropdown.addSeparator();
    dropdown.addItem("Last Action", null);

    return split;
}

From source file:com.example.themes.valo.MenuBars.java

License:Apache License

static MenuBar getMenuBar() {
    Command click = new Command() {
        @Override//w w  w . j  av  a  2s . c o m
        public void menuSelected(MenuItem selectedItem) {
            Notification.show("Clicked " + selectedItem.getText());
        }
    };

    MenuBar menubar = new MenuBar();
    menubar.setWidth("100%");
    final MenuBar.MenuItem file = menubar.addItem("Draft", null);
    final MenuBar.MenuItem newItem = file.addItem("New", null);
    file.addItem("Open file...", click);
    file.addSeparator();

    newItem.addItem("File", click);
    newItem.addItem("Folder", click);
    newItem.addItem("Project...", click);

    file.addItem("Close", click);
    file.addItem("Close All", click);
    file.addSeparator();

    file.addItem("Save", click);
    file.addItem("Save As...", click);
    file.addItem("Save All", click);

    final MenuBar.MenuItem edit = menubar.addItem("Edit", null);
    edit.addItem("Undo", click);
    edit.addItem("Redo", click).setEnabled(false);
    edit.addSeparator();

    edit.addItem("Cut", click);
    edit.addItem("Copy", click);
    edit.addItem("Paste", click);
    edit.addSeparator();

    final MenuBar.MenuItem find = edit.addItem("Find/Replace", null);

    find.addItem("Google Search", click);
    find.addSeparator();
    find.addItem("Find/Replace...", click);
    find.addItem("Find Next", click);
    find.addItem("Find Previous", click);

    Command check = new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            Notification.show(selectedItem.isChecked() ? "Checked" : "Unchecked");
        }
    };

    final MenuBar.MenuItem view = menubar.addItem("View", null);
    view.addItem("Show Status Bar", check).setCheckable(true);
    MenuItem title = view.addItem("Show Title Bar", check);
    title.setCheckable(true);
    title.setChecked(true);
    view.addItem("Customize Toolbar...", click);
    view.addSeparator();

    view.addItem("Actual Size", click);
    view.addItem("Zoom In", click);
    view.addItem("Zoom Out", click);

    TestIcon testIcon = new TestIcon(50);

    MenuItem fav = menubar.addItem("", check);
    fav.setIcon(testIcon.get());
    fav.setStyleName("icon-only");
    fav.setCheckable(true);
    fav.setChecked(true);

    fav = menubar.addItem("", check);
    fav.setIcon(testIcon.get());
    fav.setStyleName("icon-only");
    fav.setCheckable(true);
    fav.setCheckable(true);

    menubar.addItem("Attach", click).setIcon(FontAwesome.PAPERCLIP);
    menubar.addItem("Undo", click).setIcon(FontAwesome.UNDO);
    MenuItem redo = menubar.addItem("Redo", click);
    redo.setIcon(FontAwesome.REPEAT);
    redo.setEnabled(false);
    menubar.addItem("Upload", click).setIcon(FontAwesome.UPLOAD);

    return menubar;
}

From source file:com.expressui.core.view.menu.MenuBarNode.java

License:Open Source License

MenuBar createMenuBar() {
    MenuBar menuBar = new MenuBar();
    menuBar.setSizeUndefined();//  ww  w.j a va  2 s .  c  om
    menuBar.setAutoOpen(true);
    menuBar.setHtmlContentAllowed(true);

    for (MenuBarNode child : children.values()) {
        if (child.isViewAllowed() && child.isVisible()) {
            MenuBar.MenuItem childMenuItem = menuBar.addItem(child.caption, child.command);
            child.populate(childMenuItem);
        }
    }

    return menuBar;
}