Package com.vaadin.ui.MenuBar

Examples of com.vaadin.ui.MenuBar.Command


    }

    private MenuBar createMenuBar(final BeanContainer<String, Task> beans, final Table table) {
        MenuBar menu = new MenuBar();
        menu.setImmediate(true);
        menu.addItem("Reload", new Command() {
            public void menuSelected(MenuItem selectedItem) {
                update(beans);
            }
        });
        menu.addItem("Add", new Command() {
            public void menuSelected(MenuItem selectedItem) {
                Task task = new Task();
                task.setId(UUID.randomUUID().toString());
                task.setTitle("New Task");
                task.setDescription("None");
                taskService.addTask(task);
                beans.addBean(task);
            }
        });
        menu.addItem("Delete", new Command() {
            public void menuSelected(MenuItem selectedItem) {
                String id = (String) table.getValue();
                taskService.deleteTask(id);
                table.removeItem(id);
            }
View Full Code Here


        split.addStyleName("small");
        wrap.addComponent(split);
    }

    static MenuBar getMenuBar() {
        Command click = new Command() {
            @Override
            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");
            }
View Full Code Here

        }

        MenuItem first = itemList.get(0);

        for (int i = 0; i < 5; i++) {
            first.addItem(new String("Submenu item" + i), null, new Command() {

                @Override
                public void menuSelected(MenuItem selected) {
                    main.showNotification("Action " + selected.getText());
                }
            });
        }

        MenuItem firstSubItem1 = first.getChildren().get(1);

        for (int i = 0; i < 3; i++) {
            firstSubItem1.addItem(new String("Subsubmenu item" + i), null,
                    new Command() {

                        @Override
                        public void menuSelected(MenuItem selected) {
                            main.showNotification("Action "
                                    + selected.getText());
                        }
                    });
        }
        MenuItem firstSubItem2 = first.getChildren().get(3);

        for (int i = 0; i < 3; i++) {
            firstSubItem2.addItem(new String("Subsubmenu item" + i), null,
                    new Command() {

                        @Override
                        public void menuSelected(MenuItem selected) {
                            main.showNotification("Action "
                                    + selected.getText());
                        }
                    });
        }

        MenuItem second = menuBar.getItems().get(1);

        for (int i = 0; i < 5; i++) {
            second.addItem(new String("Second submenu item" + i), null,
                    new Command() {

                        @Override
                        public void menuSelected(MenuItem selected) {
                            main.showNotification("Action "
                                    + selected.getText());
                        }
                    });
        }

        MenuItem third = menuBar.getItems().get(2);
        third.setIcon(new ThemeResource("icons/16/document.png"));

        for (int i = 2; i <= 3; i++) {
            (menuBar.getItems().get(i)).setCommand(new Command() {

                @Override
                public void menuSelected(MenuItem selectedItem) {
                    main.showNotification("Action " + selectedItem.getText());
                }
            });
        }

        final MenuItem fourth = menuBar.getItems().get(3);
        fourth.setText("Add new item");

        fourth.setCommand(new Command() {
            @Override
            public void menuSelected(MenuItem selected) {
                menuBar.addItem("Newborn", null, null);
            }
        });

        final MenuItem fifth = menuBar.getItems().get(4);
        for (int i = 0; i < 5; i++) {
            fifth.addItem("Another subitem " + i, null);
        }

        final MenuItem last = menuBar.getItems().get(menuBar.getSize() - 1);
        last.setText("Remove me!");

        // A command for removing the selected menuitem
        Command removeCommand = new Command() {

            @Override
            public void menuSelected(MenuItem selected) {
                MenuItem parent = selected.getParent();
                if (parent != null) {
View Full Code Here

        return menu;
    }

    private Command buildCommand() {
        Command command = new Command() {

            @Override
            public void menuSelected(MenuItem selectedItem) {

            }
View Full Code Here

public class MenuBarRootItemSelectWithKeyboard extends TestBase {

    @Override
    protected void setup() {
        Command c = new Command() {
            @Override
            public void menuSelected(MenuItem selectedItem) {
                getMainWindow().showNotification(selectedItem.getText());

            }
View Full Code Here

    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"));
View Full Code Here

        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"));
            }
View Full Code Here

        return menu;
    }

    private Command buildCommand() {
        Command command = new Command() {

            @Override
            public void menuSelected(MenuItem selectedItem) {

            }
View Full Code Here

                description
                        .setValue("A more informative message about what has happened. Nihil hic munitissimus habendi senatus locus, nihil horum? Inmensae subtilitatis, obscuris et malesuada fames. Hi omnes lingua, institutis, legibus inter se differunt.");
                description.setWidth("100%");
                addComponent(description);

                Command typeCommand = new Command() {
                    @Override
                    public void menuSelected(MenuItem selectedItem) {
                        if (selectedItem.getText().equals("Humanized")) {
                            typeString = "";
                            notification.setStyleName(styleString.trim());
                        } else {
                            typeString = selectedItem.getText().toLowerCase();
                            notification
                                    .setStyleName((typeString + " " + styleString
                                            .trim()).trim());
                        }
                        for (MenuItem item : type.getItems()) {
                            item.setChecked(false);
                        }
                        selectedItem.setChecked(true);
                    }
                };

                type.setCaption("Type");
                MenuItem humanized = type.addItem("Humanized", typeCommand);
                humanized.setCheckable(true);
                humanized.setChecked(true);
                type.addItem("Tray", typeCommand).setCheckable(true);
                type.addItem("Warning", typeCommand).setCheckable(true);
                type.addItem("Error", typeCommand).setCheckable(true);
                type.addItem("System", typeCommand).setCheckable(true);
                addComponent(type);
                type.addStyleName("small");

                Command styleCommand = new Command() {
                    @Override
                    public void menuSelected(MenuItem selectedItem) {
                        styleString = "";
                        for (MenuItem item : style.getItems()) {
                            if (item.isChecked()) {
View Full Code Here

                win.setClosable(false);
                win.setResizable(false);
                win.setContent(windowContent());
                win.setCloseShortcut(KeyCode.ESCAPE, null);

                Command optionsCommand = new Command() {
                    @Override
                    public void menuSelected(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 Toolbar")) {
                            toolbarVisible = selectedItem.isChecked();
                        }

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

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

                        if (selectedItem.getText()
                                .equals("Borderless Toolbars")) {
                            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 Toolbar", optionsCommand).setCheckable(
                        true);
                options.addItem("Top Toolbar", optionsCommand).setCheckable(
                        true);
                options.addItem("Top Toolbar layout", optionsCommand)
                        .setCheckable(true);
                options.addItem("Borderless Toolbars", optionsCommand)
                        .setCheckable(true);
                options.addStyleName("small");
                addComponent(options);

                Command optionsCommand2 = new Command() {
                    @Override
                    public void menuSelected(MenuItem selectedItem) {
                        if (selectedItem.getText().equals("Caption")) {
                            win.setCaption(selectedItem.isChecked() ? "Window Caption"
                                    : null);
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.