/*
(non-Javadoc)

@see
org.eclipse.ui.IWorkbenchWindowPulldownDelegate#getMenu(org.eclipse.swt
.widgets.Control)
197667
@Override
    public Menu getMenu(Control parent) {
        if (menu == null) {
            menu = new Menu(parent);
            fillMenu();
        }
        return menu;
    }
1074494
private Element getTabElement(int tabIndex) {

        Element tabRootEl = m_tabPanel.getElement();
        // set an additional css class for the parent element of the .gwt-TabLayoutPanelTabs element
        List<Element> tabDivs = CmsDomUtil.getElementsByClass(
            I_CmsLayoutBundle.INSTANCE.tabbedPanelCss().cmsTabLayoutPanelTab(),
            CmsDomUtil.Tag.div,
            tabRootEl);
        if ((tabDivs != null) && (tabDivs.size() > tabIndex)) {
            return tabDivs.get(tabIndex);
        }
        return null;
    }
42985
public Optional<MenuItem> getMenuById(SubMenuItem root, int id) {
        return getMenuItems(root).stream().filter(item -> item.getId() == id).findFirst();
    }
863761
@Override
    public Widget get(final int dataIndex) {
        return dataIndex >= size() ? null : getChildren().get(dataIndex);
    }
1294005
public String getSubMenuXML()
    {
        StringBuffer sbMenuArea = new StringBuffer();
        
        if (this.getEditMode() == Constants.EDIT_CURRENT)
        {
            if (this.getField(Menus.ICON_RESOURCE).isNull())
            {
                String strIcon = this.getField(Menus.TYPE).toString();
                if (strIcon.length() > 0)
                    strIcon = strIcon.substring(0, 1).toUpperCase() + strIcon.substring(1);
                this.getField(Menus.ICON_RESOURCE).setString(strIcon);
            }
            sbMenuArea.append(XmlUtilities.createXMLStringRecord(this));
            sbMenuArea = this.addLinkTag(sbMenuArea);
        }
        
        if (sbMenuArea.length() == 0)
            sbMenuArea.append(
                    Utility.startTag(this.getTableNames(false)) +
                    " <Name>Name</Name>" +
                    " <Description>Description</Description>" +
                    " <Program>Program</Program>" +
                    " <Params>Params</Params>" +
                    " <IconResource>IconResource</IconResource>" +
                    " <Keywords>Keywords</Keywords>" +
                    " <Html>Html</Html>" +
                    Utility.endTag(this.getTableNames(false)));
        
        StringBuffer sbContentArea = new StringBuffer();
        sbContentArea.append(Utility.startTag(XMLTags.MENU_LIST));
        try   {
            String strMenu = this.getField(Menus.ID).toString();
            this.setKeyArea(Menus.PARENT_FOLDER_ID_KEY);
            FileListener behavior = new StringSubFileFilter(strMenu, this.getField(Menus.PARENT_FOLDER_ID), null, null, null, null);
            this.addListener(behavior);
            this.close();
            while (this.hasNext())
            {
                this.next();
                if (this.getField(Menus.ICON_RESOURCE).isNull())
                {
                    String strIcon = this.getField(Menus.TYPE).toString();
                    if (strIcon.length() > 0)
                        strIcon = strIcon.substring(0, 1).toUpperCase() + strIcon.substring(1);
                    this.getField(Menus.ICON_RESOURCE).setString(strIcon);
                }
                StringBuffer sbMenuItem = new StringBuffer();
                sbMenuItem.append(XmlUtilities.createXMLStringRecord(this));
                sbMenuItem = this.addLinkTag(sbMenuItem);
                sbContentArea.append(sbMenuItem);
            }
            this.removeListener(behavior, true);
        } catch (DBException ex)    {
            ex.printStackTrace();
        }
        sbContentArea.append(Utility.endTag(XMLTags.MENU_LIST));
        sbMenuArea.insert(sbMenuArea.lastIndexOf(Utility.endTag(this.getTableNames(false))), sbContentArea);
        return sbMenuArea.toString();
    }
418245
@Override public boolean onCreateOptionsMenu(Menu menu) {
    if (actionBarMenuAction != null) {
      menu.add(actionBarMenuAction.title)
          .setShowAsActionFlags(SHOW_AS_ACTION_ALWAYS)
          .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override public boolean onMenuItemClick(MenuItem menuItem) {
              actionBarMenuAction.action.call();
              return true;
            }
          });
    }
    menu.add("Log Scope Hierarchy")
        .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
          @Override public boolean onMenuItemClick(MenuItem item) {
            Log.d("DemoActivity", MortarScopeDevHelper.scopeHierarchyToString(activityScope));
            return true;
          }
        });
    return true;
  }
912606
public JComponent getEditorMenuBar(){
		CommandGroup commandGroup = getCommandGroup(getMenuBarCommandGroupName());
		if(commandGroup == null){
			return null;
		}
		return commandGroup.createMenuBar();
	}
715553
private Class<? extends WComponent> getRowRendererClass() {
		UIContext uic = UIContextHolder.getCurrent();

		if (table.getDataModel() instanceof TreeTableDataModel && uic instanceof SubUIContext) {
			int row = getRowIndex((SubUIContext) uic);
			TreeTableDataModel dataModel = (TreeTableDataModel) table.getDataModel();

			TableTreeNode node = dataModel.getNodeAtLine(row);
			return node.getRendererClass();
		}

		return null;
	}
700544
public View getMenuButton(MenuButton button) {
        switch (button) {
            case MID:
                return mMidContainer;
            case LEFT:
                return mLeftContainer;
            case RIGHT:
                return mRightContainer;
        }
        return null;
    }
1030910
public WebMenuItem getMenuItem(String menuName, String path){
		try{
			return menuItemPaths.get(menuName).get(path);
		}catch(Exception e){
			log.error("Error when getting menu item for: menuName='" + menuName + "', path='" + path + "'", e);
			return null;
		}
	}
718043
private JPanel getPaneSelect() {
		if (paneSelect == null) {
			paneSelect = new JPanel();
			paneSelect.setLayout(new BorderLayout(0,0));
			paneSelect.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
			paneSelect.add(getTabbedSelect());
		}
		return paneSelect;
	}
563881
public static I_CmsContextMenuCommand getContextMenuCommand() {

        return new I_CmsContextMenuCommand() {

            public void execute(CmsUUID structureId, I_CmsContextMenuHandler handler, CmsContextMenuEntryBean bean) {

                openWorkplace(structureId, false);
            }

            public A_CmsContextMenuItem getItemWidget(
                CmsUUID structureId,
                I_CmsContextMenuHandler handler,
                CmsContextMenuEntryBean bean) {

                return null;
            }

            public boolean hasItemWidget() {

                return false;
            }
        };
    }
592967
private WMenu buildMenu(final WText selectedMenuText) {
		WMenu menu = new WMenu(WMenu.MenuType.FLYOUT);

		// The Colours menu just shows simple text
		WSubMenu colourMenu = new WSubMenu("Colours");
		addMenuItem(colourMenu, "Red", selectedMenuText);
		addMenuItem(colourMenu, "Green", selectedMenuText);
		addMenuItem(colourMenu, "Blue", selectedMenuText);
		colourMenu.addSeparator();
		colourMenu.add(new WMenuItem("Disable colour menu", new ToggleDisabledAction(colourMenu)));
		menu.add(colourMenu);

		// The Shapes menu shows grouping of items
		WSubMenu shapeMenu = new WSubMenu("Shapes");
		addMenuItem(shapeMenu, "Circle", selectedMenuText);

		WMenuItemGroup triangleGroup = new WMenuItemGroup("Triangles");
		shapeMenu.add(triangleGroup);
		addMenuItem(triangleGroup, "Equilateral", selectedMenuText);
		addMenuItem(triangleGroup, "Isosceles", selectedMenuText);
		addMenuItem(triangleGroup, "Scalene", selectedMenuText);
		addMenuItem(triangleGroup, "Right-angled", selectedMenuText);
		addMenuItem(triangleGroup, "Obtuse", selectedMenuText);

		WMenuItemGroup quadGroup = new WMenuItemGroup("Quadrilaterals");
		shapeMenu.add(quadGroup);
		addMenuItem(quadGroup, "Square", selectedMenuText);
		addMenuItem(quadGroup, "Rectangle", selectedMenuText);
		addMenuItem(quadGroup, "Rhombus", selectedMenuText);
		addMenuItem(quadGroup, "Trapezoid", selectedMenuText);
		addMenuItem(quadGroup, "Parallelogram", selectedMenuText);

		shapeMenu.addSeparator();
		shapeMenu.add(new WMenuItem("Disable shape menu", new ToggleDisabledAction(shapeMenu)));
		menu.add(shapeMenu);

		// The Image menu shows use of decorated labels and images
		WSubMenu imageMenu = new WSubMenu("Images");
		imageMenu.add(createImageMenuItem("/image/flag.png", "Flag", "eg-menu-image-1",
				selectedMenuText));
		imageMenu.add(createImageMenuItem("/image/attachment.png", "Attachment", "eg-menu-image-2",
				selectedMenuText));
		imageMenu.add(createImageMenuItem("/image/settings.png", "Settings", "eg-menu-image-3",
				selectedMenuText));

		imageMenu.addSeparator();
		imageMenu.add(new WMenuItem("Disable image menu", new ToggleDisabledAction(imageMenu)));
		menu.add(imageMenu);

		WSubMenu sitesMenu = new WSubMenu("External apps");
		sitesMenu.add(new WMenuItem("Example website", "http://www.example.com/"));
		WMenuItem google = new WMenuItem("Example (new window)", "http://www.example.com/");
		google.setTargetWindow("exampleWindow");
		sitesMenu.add(google);
		menu.add(sitesMenu);

		// Add an item to toggle the states of all the menus
		menu.add(new WMenuItem("Toggle top-level menus", new ToggleDisabledAction(colourMenu,
				shapeMenu, imageMenu,
				sitesMenu)));

		menu.add(new WMenuItem("Link", "http://www.example.com"));
		menu.add(new WMenuItem("No Action"));

		return menu;
	}
991909
@Override
    public Object getValue() throws WidgetException {
        List<String> selectedOptions = null;
        try {
            selectedOptions = getSelectedItems_internal();

        } catch (Exception e) {
            throw new WidgetException("Error while fetching selected value on select",
                    getByLocator(), e);
        }

        if (selectedOptions.size() == 0) {
            return null;
        } else if (selectedOptions.size() == 1) {
            return selectedOptions.get(0);
        } else {
            return selectedOptions;
        }
    }
221261
private String getRole(final WMenuItem item) {
		if (!item.isSelectAllowed()) {
			return null;
		}
		MenuSelectContainer selectContainer = WebUtilities.getAncestorOfClass(MenuSelectContainer.class, item);
		if (selectContainer == null) {
			return CHECKBOX_ROLE;
		}
		return MenuSelectContainer.SelectionMode.MULTIPLE.equals(selectContainer.getSelectionMode()) ? CHECKBOX_ROLE : RADIO_ROLE;
	}
250032
public static I_CmsContextMenuCommand getContextMenuCommand() {

        return new I_CmsContextMenuCommand() {

            public void execute(CmsUUID structureId, I_CmsContextMenuHandler handler, CmsContextMenuEntryBean bean) {

                editProperties(structureId, handler, false, null, true, new PropertyEditingContext());
            }

            public A_CmsContextMenuItem getItemWidget(
                CmsUUID structureId,
                I_CmsContextMenuHandler handler,
                CmsContextMenuEntryBean bean) {

                return null;
            }

            public boolean hasItemWidget() {

                return false;
            }
        };
    }
928469
private JPopupMenu getJPopupMenu()
    {
        Container parent = this.getParent();
        while (parent != null)
        {
            if (parent instanceof JPopupMenu)
                return (JPopupMenu)parent;
            parent = parent.getParent();
        }
        return null;
    }