Package org.gwtoolbox.widget.client.menu

Examples of org.gwtoolbox.widget.client.menu.MenuPopup


        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) {
                contextMenu.setPopupPositionAndShow(new Popup.PositionCallback() {
                    public void setPosition(int offsetWidth, int offsetHeight) {
                        int x = event.getNativeEvent().getClientX();
                        int y = event.getNativeEvent().getClientY();
                        contextMenu.setPopupPosition(x, y);
                    }
                });
            }
        });
        main.add(label);
        label.setWidth("150px");
        label.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
        DOM.setStyleAttribute(label.getElement(), "cursor", "default");
        DOM.setStyleAttribute(label.getElement(), "border", "1px solid gray");
        DOM.setStyleAttribute(label.getElement(), "marginTop", "150px");

        final CheckBox checkBox = new CheckBox("Disable Option 2");
        checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
            public void onValueChange(ValueChangeEvent<Boolean> event) {
                MenuItemBase item = contextMenu.getMenu().getItem("Options.option2");
                item.setEnabled(!event.getValue());
            }
        });
        main.add(checkBox);
View Full Code Here


                });
                columnsMenu.addItem(item);
            }
        }

        popup = new MenuPopup(true);
        popup.getMenu().addItem("sortAsc", "Sort Asc", new Command() {
            public void execute() {
                int columnIndex = menuPopupContext.getColumnIndex();
                sortByColumn(columnIndex, true);
            }
View Full Code Here

            final MenuBuilder menuBuilder = tabSpec.getMenuBuilder();
            if (menuBuilder != null || showDefaultContextMenu) {

                ContextMenuHandler handler = new ContextMenuHandler() {
                    public void onContextMenu(final com.google.gwt.dom.client.Element element, final int x, final int y) {
                        final MenuPopup menu = new MenuPopup(true);

                        if (showDefaultContextMenu) {
                            if (!isSelected()) {
                                menu.addItem("Select", new Command() {
                                    public void execute() {
                                        select();
                                    }
                                }).setEnabled(enabled);
                            }
                            if (closeButtonElement != null) {
                                menu.addItem("Close", new Command() {
                                    public void execute() {
                                        handleOnClose();
                                    }
                                }).setEnabled(enabled);
                            }
                            menu.addItem("Close Others", new Command() {
                                public void execute() {
                                    handleCloseOthers();
                                }
                            }).setEnabled(enabled);
                        }

                        if (menuBuilder != null) {
                            if (showDefaultContextMenu) {
                                menu.addSeparator();
                            }
                            menuBuilder.build(menu.getMenu());
                        }
                        menu.setPopupPositionAndShow(new Popup.PositionCallback() {
                            public void setPosition(int offsetWidth, int offsetHeight) {
                                menu.setPopupPosition(element.getAbsoluteLeft() + x, element.getAbsoluteTop() + y);
                            }
                        });
                    }
                };
                addContextMenuListener(tabElement, handler);
View Full Code Here

        this(new SimpleButton(caption), verticalMenu);
    }

    public SimpleMenuButton(final ButtonBase button, boolean verticalMenu) {
        button.setEnabled(false);
        popup = new MenuPopup(verticalMenu);
        popup.getMenu().addAddHandler(new AddHandler<MenuItemBase>() {
            public void onAdd(AddEvent<MenuItemBase> menuItemBaseAddEvent) {
                button.setEnabled(true);
            }
        });
View Full Code Here

            }
            final MenuBuilder menuBuilder = tabSpec.getMenuBuilder();
            if (menuBuilder != null) {
                addContextMenuListener(tabElement, new ContextMenuHandler() {
                    public void onContextMenu(final com.google.gwt.dom.client.Element element, final int x, final int y) {
                        final MenuPopup menu = new MenuPopup(true);
                        menuBuilder.build(menu.getMenu());
                        menu.setPopupPositionAndShow(new Popup.PositionCallback() {
                        public void setPosition(int offsetWidth, int offsetHeight) {
                            menu.setPopupPosition(element.getAbsoluteLeft() + x, element.getAbsoluteTop() + y);
                        }
                    });
                    }
                });
            }
View Full Code Here

TOP

Related Classes of org.gwtoolbox.widget.client.menu.MenuPopup

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.