Example usage for com.google.gwt.user.client.ui MenuItem setSubMenu

List of usage examples for com.google.gwt.user.client.ui MenuItem setSubMenu

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui MenuItem setSubMenu.

Prototype

public void setSubMenu(MenuBar subMenu) 

Source Link

Document

Sets the sub-menu associated with this item.

Usage

From source file:org.jbpm.formbuilder.client.command.LanguageCommand.java

License:Apache License

@Override
public void setItem(final MenuItem item) {
    MenuBar subMenu = new MenuBar(true);
    String[] availableLocaleNames = LocaleInfo.getAvailableLocaleNames();
    for (final String localeName : availableLocaleNames) {
        String html = LocaleInfo.getLocaleNativeDisplayName(localeName);
        if (html == null || "".equals(html)) {
            html = i18n.LocaleDefault();
        }//  ww w  .  j  a  v a 2 s  .  c om
        subMenu.addItem(html, new Command() {
            @Override
            public void execute() {
                reloadLocale(localeName, item);
            }
        });
    }
    item.setSubMenu(subMenu);
    item.setCommand(null);
}

From source file:org.xwiki.gwt.wysiwyg.client.MenuBarController.java

License:Open Source License

/**
 * Fills the given menu bar with items matching the given list of descriptors.
 * //from   w ww . ja  va  2 s. c  o m
 * @param menuBar the menu bar to be filled
 * @param descriptors the list of menu item descriptors
 * @param pluginManager the object used to access the menu bar {@link UIExtension}s
 */
private void fillMenuBar(MenuBar menuBar, List<MenuItemDescriptor> descriptors, PluginManager pluginManager) {
    for (MenuItemDescriptor descriptor : descriptors) {
        UIExtension uie = pluginManager.getUIExtension(MENU_ROLE, descriptor.getFeature());
        if (uie != null) {
            // We have to handle menu items and menu item separators differently because MenuItemSeparator doesn't
            // extends MenuItem.
            UIObject uiObject = uie.getUIObject(descriptor.getFeature());
            if (uiObject instanceof MenuItemSeparator) {
                menuBar.addSeparator((MenuItemSeparator) uiObject);
            } else if (uiObject instanceof MenuItem) {
                MenuItem menuItem = (MenuItem) uiObject;
                if (!descriptor.getSubMenu().isEmpty()) {
                    menuItem.setSubMenu(new MenuBar(true));
                    fillMenuBar((MenuBar) menuItem.getSubMenu(), descriptor.getSubMenu(), pluginManager);
                }
                menuBar.addItem(menuItem);
            }
        }
    }
}