Package com.vaadin.ui

Examples of com.vaadin.ui.MenuBar$Command


public class HiddenAndDisabledMenus extends TestBase {

    @Override
    protected void setup() {
        MenuBar mb = new MenuBar();
        mb.addItem("Item 1", null);
        mb.addItem("Item 2 - hidden", null).setVisible(false);
        MenuItem submenu = mb.addItem("Item 3 - sub menu", null);
        mb.addItem("Item 4 - hidden", null).setVisible(false);
        submenu.addItem("Sub item 1 - disabled", null).setEnabled(false);
        submenu.addItem("Sub item 2 - enabled", null);
        submenu.addItem("Sub item 3 - visible", null);
        submenu.addItem("Sub item 4 - hidden", null).setVisible(false);
View Full Code Here


public class MenuBarPrimaryStylenames extends TestBase {

    @Override
    protected void setup() {
        final MenuBar mainMenu = new MenuBar();
        mainMenu.setPrimaryStyleName("my-menu-bar");

        MenuItem submenu1 = mainMenu.addItem("Submenu1", null);
        submenu1.setStyleName("normal icon-white icon-headphones");

        MenuItem item1 = submenu1.addItem("Item1", null);
        item1.setCheckable(true);
        item1.setStyleName("my-menu-item");
        submenu1.addItem("Item2", null);

        MenuItem submenu2 = mainMenu.addItem("Submenu2", null);
        MenuItem menu1 = submenu2.addItem("Menu1", null);
        menu1.addItem("Item11", null);

        addComponent(mainMenu);

        addComponent(new Button("Change primary stylename",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        mainMenu.setPrimaryStyleName("my-other-menu");
                    }
                }));

    }
View Full Code Here

        return MenuBar.class;
    }

    @Override
    protected void initializeComponents() {
        MenuBar m = new MenuBar();
        MenuItem submenu = m.addItem("Item <u>1</u>", getIcon(), null);
        MenuItem subsubmenu = submenu.addItem("<b>Bold</b> item", null);
        subsubmenu.addItem("<i><u>I</u>talic</i> item", getIcon(), null);
        submenu.addItem(
                "<span style='font-size: 30px'>Big</span> <span style='font-size: 8px'>disabled</span> item",
                null).setEnabled(false);

        m.addItem("<span style='font-size: 30px'>Big</span> item", null);

        addTestComponent(m);
    }
View Full Code Here

    /*
     * Returns a menu bar with three levels of nesting but no icons.
     */
    private MenuBar createFirstMenuBar() {
        MenuBar menuBar = new MenuBar();
        MenuItem file = menuBar.addItem("File", null);
        file.addItem("Open", selectionCommand);
        file.addItem("Save", selectionCommand);
        file.addItem("Save As..", selectionCommand);
        file.addSeparator();
        MenuItem export = file.addItem("Export..", null);
        export.addItem("As PDF...", selectionCommand);
        export.addItem("As Doc...", selectionCommand);
        file.addSeparator();
        file.addItem("Exit", selectionCommand);

        MenuItem edit = menuBar.addItem("Edit", null);
        edit.addItem("Copy", selectionCommand);
        edit.addItem("Cut", selectionCommand);
        edit.addItem("Paste", selectionCommand);

        menuBar.addItem("Help", selectionCommand);
        return menuBar;
    }
View Full Code Here

    /*
     * Returns a menu bar containing items with icons. The last menu item is
     * nested and its submenu contains items with and without icons.
     */
    private MenuBar createSecondMenuBar() {
        MenuBar menuBar = new MenuBar();
        int n = itemNames.length;
        for (int i = 0; i < n - 1; i++) {
            menuBar.addItem(itemNames[i], itemIcons[i], selectionCommand);
        }
        MenuItem last = menuBar.addItem(itemNames[n - 1], itemIcons[n - 1],
                null);
        for (int i = 0; i < nestedItemnames.length; i++) {
            last.addItem(nestedItemnames[i], nestedItemIcons[i],
                    selectionCommand);
        }
View Full Code Here

        LegacyWindow main = new LegacyWindow("Test");
        main.setSizeFull();
        setMainWindow(main);
        main.getContent().setSizeFull();

        MenuBar menuBar = new MenuBar();
        menuBar.addItem("Test", new ThemeResource("icons/16/calendar.png"),
                null);
        menuBar.addItem("ABC", new ThemeResource("icons/16/document.png"), null);
        menuBar.addItem("123", new ThemeResource("icons/16/help.png"), null);

        main.addComponent(menuBar);
        ((VerticalLayout) main.getContent()).setComponentAlignment(menuBar,
                Alignment.TOP_RIGHT);
View Full Code Here

*/
public class SpaceMenuBarNavigation extends AbstractTestUI implements Command {

    @Override
    protected void setup(VaadinRequest request) {
        MenuBar menuBar = new MenuBar();
        menuBar.addStyleName("menu-bar");

        MenuItem item = menuBar.addItem("menu", null);

        item.addItem("subitem", this);

        addComponent(menuBar);
    }
View Full Code Here

     * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
     * VaadinRequest)
     */
    @Override
    protected void setup(VaadinRequest request) {
        final MenuBar bar = buildMenu();
        Button focusButton = buildButton(bar);

        addComponent(bar);
        addComponent(focusButton);
        getLayout().setSpacing(true);
View Full Code Here

        addComponent(focusButton);
        getLayout().setSpacing(true);
    }

    private MenuBar buildMenu() {
        final MenuBar bar = new MenuBar();
        bar.setDescription("Root Menu");

        Command command = new Command() {

            @Override
            public void menuSelected(MenuItem selectedItem) {
                addComponent(new Label(selectedItem.getText() + " clicked"));

            }
        };

        // File
        final MenuItem file = bar.addItem("File", null);
        file.addItem("Foo", command);
        file.addItem("Bar", command);

        // Edit
        MenuItem edit = bar.addItem("Edit", null);
        edit.addItem("Baz", command);
        edit.addItem("Bay", command);

        bar.setTabIndex(2);
        return bar;
    }
View Full Code Here

        return l;
    }

    MenuBar getTopMenu() {
        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...", new ThemeResource(
                "../runo/icons/16/folder.png"), null);
        file.addSeparator();

        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);

        find.addItem("Google Search", new Command() {
            @Override
            public void menuSelected(MenuItem selectedItem) {
                getMainWindow().open(
                        new ExternalResource("http://www.google.com"));
            }
        });
        find.addSeparator();
        find.addItem("Find/Replace...", null);
        find.addItem("Find Next", null);
        find.addItem("Find Previous", null);

        final MenuBar.MenuItem view = menubar.addItem("View",
                new ThemeResource("../runo/icons/16/user.png"), null);
        MenuItem statusBarItem = view.addItem("Show/Hide Status Bar", null);
        statusBarItem.setCheckable(true);
        statusBarItem.setChecked(true);
        view.addItem("Customize Toolbar...", null);
        view.addSeparator();

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

        menubar.addItem("Help", null).setEnabled(false);

        return menubar;
    }
View Full Code Here

TOP

Related Classes of com.vaadin.ui.MenuBar$Command

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.