Package org.gwtoolbox.widget.client.menu

Examples of org.gwtoolbox.widget.client.menu.Menu$InternalContextListener


    public SimpleMenuButtonSample() {

        HorizontalPanel buttons = new HorizontalPanel();

        SimpleMenuButton button = new SimpleMenuButton("Vertical Menu", true);
        Menu menu = button.getMenu();
        menu.addItem("Item 1", new Command() {
            public void execute() {
                showMessage("Item 1 was clicked");
            }
        });
        menu.addItem("Item 2", new Command() {
            public void execute() {
                showMessage("Item 2 was clicked");
            }
        });

        Menu subMenu = new Menu(true);
        subMenu.addItem("Item 3", new Command() {
            public void execute() {
                showMessage("Item 3 was clicked");
            }
        });
        menu.addItem("Sub Menu", subMenu);
        buttons.add(button);

        addGap(buttons, "20px");

        button = new SimpleMenuButton("Horizontal Menu", false);
        menu = button.getMenu();
        menu.addItem("Item 1", new Command() {
            public void execute() {
                showMessage("Item 1 was clicked");
            }
        });
        menu.addItem("Item 2", new Command() {
            public void execute() {
                showMessage("Item 2 was clicked");
            }
        });

        subMenu = new Menu(true);
        subMenu.addItem("Item 3", new Command() {
            public void execute() {
                showMessage("Item 3 was clicked");
            }
        });
        menu.addItem("Sub Menu", subMenu);
View Full Code Here


                });
                menu.addItem("Item 3", new Command() {
                    public void execute() {
                    }
                });
                Menu subMenu = new Menu(true);
                subMenu.addItem("Item 4", new Command() {
                    public void execute() {
                    }
                });
                subMenu.setAutoOpen(true);
                menu.addItem("Sub Menu", subMenu);
            }
        });

        contentPanel.addToggleTool(ContentPanel.ToggleTools.PIN, new ToggleHandler() {
View Full Code Here

public class MenuSample extends Composite implements SamplePanel {

    public MenuSample() {
        FlowPanel main = new FlowPanel();

        Menu menubar = new Menu();
        menubar.setWidth("100%");
        main.add(menubar);

        Menu fileMenu = new Menu(true);
        fileMenu.addItem("New", new AlertCommand("'New' was clicked")).setIconStyleName("menu-item-file-new");
        fileMenu.addItem("Open...", new AlertCommand("'Open...' was clicked")).setIconStyleName("menu-item-file-open");
        fileMenu.addSeparator();
        fileMenu.addItem("Save...", new AlertCommand("'Save...' was clicked")).setIconStyleName("menu-item-file-save");
        fileMenu.addItem("Save As...", new AlertCommand("'Save As...' was clicked")).setIconStyleName("menu-item-file-save");
        fileMenu.addSeparator();
        fileMenu.addItem("Exit", new AlertCommand("'Exit' was clicked")).setIconStyleName("menu-item-file-exit");
        menubar.addItem("File", fileMenu);

        Menu editMenu = new Menu(true);
        editMenu.addItem("Undo", new AlertCommand("'Undo' was clicked")).setIconStyleName("menu-item-edit-undo");
        editMenu.addItem("Redo", new AlertCommand("'Redo' was clicked")).setIconStyleName("menu-item-edit-redo");
        editMenu.addSeparator();
        editMenu.addItem("Cut", new AlertCommand("'Cut' was clicked")).setIconStyleName("menu-item-edit-cut");
        editMenu.addItem("Copy", new AlertCommand("'Copy' was clicked")).setIconStyleName("menu-item-edit-copy");
        editMenu.addItem("Paste", new AlertCommand("'Paste' was clicked")).setIconStyleName("menu-item-edit-paste");
        menubar.addItem("Edit", editMenu);

        Menu miscMenu = new Menu(true);
        menubar.addItem("Misc", miscMenu);

        final CheckMenuItem check2 = new CheckMenuItem("Option 2", true);
        final CheckMenuItem check1 = new CheckMenuItem("Enable Option 2", true);
        check1.setCommand(new Command() {
            public void execute() {
                check2.setEnabled(check1.isSelected());
            }
        });
        miscMenu.addItem(check1);
        check2.setCommand(new Command() {
            public void execute() {
                Window.alert("'Option 2' is " + (check2.isSelected() ? "checked" : "unchecked"));
            }
        });
        miscMenu.addItem(check2);

        miscMenu.addSeparator();

        Menu secondary = new Menu(true);
        secondary.addItem("Item 1", new AlertCommand("'Item 1' was clicked"));
        secondary.addItem("Item 2", new AlertCommand("'Item 2' was clicked")).setEnabled(false);
        secondary.addItem("Item 3", new AlertCommand("'Item 3' was clicked"));
        miscMenu.addItem("Items", secondary);

        miscMenu.addSeparator();

        Menu radiosMenu = new Menu(true);

        MenuItemSelectionListener listener = new MenuItemSelectionListener() {
            public void selectionChanged(SelectionMenuItem item) {
                Window.alert("'" + item.getKey() + "' was selected");
            }
        };

        RadioMenuItem radio = new RadioMenuItem("1", "Option 1", false);
        radio.addListener(listener);
        radio.setGroup("options");
        radiosMenu.addItem(radio);

        radio = new RadioMenuItem("2", "Option 2", false);
        radio.addListener(listener);
        radio.setGroup("options");
        radiosMenu.addItem(radio);

        radio = new RadioMenuItem("3", "Option 3", false);
        radio.addListener(listener);
        radio.setGroup("options");
        radiosMenu.addItem(radio);

        miscMenu.addItem("Radios", radiosMenu);


        // context menues

        final MenuPopup contextMenu = new MenuPopup(true);
        contextMenu.addItem("Item 1", new AlertCommand("'Item 1' was clicked"));
        contextMenu.addItem("Item 2", new AlertCommand("'Item 2' was clicked"));
        contextMenu.addItem("Item 3", new AlertCommand("'Item 3' was clicked"));

        Menu subMenu = new Menu(true);
        subMenu.addItem("Option 1", new AlertCommand("'Option 1' was clicked"));
        subMenu.addItem("option2", "Option 2", new AlertCommand("'Option 2' was clicked"));
        subMenu.addItem("Option 3", new AlertCommand("'Option 3' was clicked"));
        contextMenu.addSubMenu("Options", subMenu);

        BasicLabel label = new BasicLabel("Right-click Here");
        label.addContextMenuHandler(new com.google.gwt.event.dom.client.ContextMenuHandler() {
            public void onContextMenu(final ContextMenuEvent event) {
View Full Code Here

            }
        });
    }

    private void initMenuPopup() {
        Menu columnsMenu = new Menu(true);
        for (int i = 0; i < columns.length; i++) {
            final int index = i;
            Column column = columns[i];
            if (column.supports(Column.Feature.HIDABLE)) {
                final CheckMenuItem item = new CheckMenuItem(column.getName(), column.isShownByDefault());
                item.setCommand(new Command() {
                    public void execute() {
                        setColumnVisible(index, item.isSelected());
                        popup.hide();
                    }
                });
                columnsMenu.addItem(item);
            }
        }

        popup = new MenuPopup(true);
        popup.getMenu().addItem("sortAsc", "Sort Asc", new Command() {
View Full Code Here

TOP

Related Classes of org.gwtoolbox.widget.client.menu.Menu$InternalContextListener

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.