This method is used to build the menu tree.
329569
def get_nodes(self, request):
        
        nodes = []
        for term in Term.objects.only('pk', 'name', 'url'):
            try:
                url = term.get_absolute_url()
            except NoReverseMatch:
                continue

            nodes.append(NavigationNode(
                smart_text(term),
                url,
                term.pk,
            ))
        return nodes
76323
def build(self):
        
        self.children = BasicFactory.build(self.root, self)
        collated = BasicFactory.collate(self.children)
        self.children = collated[0]
        self.attributes = collated[2]
        self.imports = collated[1]
        self.elements = collated[3]
        self.types = collated[4]
        self.groups = collated[5]
        self.agrps = collated[6]
1257628
public function menuMyPages(?Tree $tree): ?Menu
    {
        if ($tree instanceof Tree && Auth::id()) {
            return new Menu(I18N::translate('My pages'), '#', 'menu-mymenu', [], array_filter([
                $this->menuMyPage($tree),
                $this->menuMyIndividualRecord($tree),
                $this->menuMyPedigree($tree),
                $this->menuMyAccount(),
                $this->menuControlPanel($tree),
                $this->menuChangeBlocks($tree),
            ]));
        }

        return null;
    }
927593
protected function buildMap(): void
    {
        $roots = $this->findRootPages();

        $this->buildPageMap($roots['main'], $roots['source'], $this->sourceMap, $this->sourceMapInverse);
        $this->buildPageMap($roots['main'], $roots['target'], $this->targetMap, $this->targetMapInverse);
        $this->combineSourceAndTargetMaps();
    }
248979
private void createMenus(Collection<ActionRef> parents, Collection<ActionRef> actions)
    {
        for (final ActionRef action : actions)
        {
            final Featurable menu = createMenu(action);
            if (!action.getRefs().isEmpty())
            {
                generateSubMenu(actions, action, menu);
            }
            else if (action.hasCancel())
            {
                previous.put(action, parents);
                generateCancel(action, menu);
            }
        }
        for (final Featurable current : menus)
        {
            handler.add(current);
        }
    }
1174809
private void generateSubMenu(final Collection<ActionRef> parents, final ActionRef action, Featurable menu)
    {
        menu.getFeature(Actionable.class).setAction(() ->
        {
            clearMenus();
            createMenus(parents, action.getRefs());
        });
    }
219857
private StringTreeNode buildOrgHierarchyTree(final Object[] data) {
		StringTreeNode childNode = new StringTreeNode((String) data[0]);

		if (data.length > 1) {
			for (int i = 1; i < data.length; i++) {
				childNode.add(buildOrgHierarchyTree((Object[]) data[i]));
			}
		}

		return childNode;
	}
1361144
public function Build() {
        $left_menu_output = "<ul class=\"content_left nav-sidebar\">";
        $main_menus = $this->_LoadXml();
        $left_menu_output .= $this->ProcessMainMenus($main_menus);
        $left_menu_output .= "</ul>";
        return $left_menu_output;
    }
760133
private CmsTreeItem buildTreeItem(CmsCategoryTreeEntry category, List<String> selectedCategories) {

        m_categories.put(category.getPath(), category);
        // set the list item widget
        CmsDataValue dataValue = new CmsDataValue(
            600,
            3,
            CmsCategoryBean.SMALL_ICON_CLASSES,
            category.getTitle(),
            CmsStringUtil.isNotEmptyOrWhitespaceOnly(category.getDescription())
            ? category.getDescription()
            : category.getPath());

        // the checkbox
        CmsCheckBox checkBox = new CmsCheckBox();
        if ((selectedCategories != null) && selectedCategories.contains(category.getPath())) {
            checkBox.setChecked(true);
        }
        SelectionHandler selectionHandler = new SelectionHandler(category.getPath(), checkBox);
        checkBox.addClickHandler(selectionHandler);
        dataValue.addClickHandler(selectionHandler);
        dataValue.addButton(createSelectButton(selectionHandler));
        dataValue.setUnselectable();
        // set the category tree item and add to list
        CmsTreeItem treeItem = new CmsTreeItem(true, checkBox, dataValue);
        treeItem.setSmallView(true);
        treeItem.setId(category.getPath());
        return treeItem;
    }
1351090
private void initContextMenu() {

        m_contextMenu.removeItems();
        MenuItem main = m_contextMenu.addItem("", null);
        main.setIcon(FontOpenCms.CONTEXT_MENU);
        main.setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_MENU_TITLE_0));
        CmsContextMenuTreeBuilder treeBuilder = new CmsContextMenuTreeBuilder(getDialogContext());
        CmsTreeNode<I_CmsContextMenuItem> tree = treeBuilder.buildAll(
            OpenCms.getWorkplaceAppManager().getMenuItemProvider().getMenuItems());
        for (CmsTreeNode<I_CmsContextMenuItem> node : tree.getChildren()) {
            createMenuEntry(main, node, treeBuilder);
        }
    }
860429
public function build()
    {
        if ($this->updateRequired) {
            $this->updateRequired = false;
            foreach ($this->nodes as $node) {
                if ($node->parent()) {
                    $node->unlock()->detach();
                }
            }
            $this->root->addChildren($this->builder->build($this->hierarchy, $this->nodes->toArray()));
            foreach ($this->nodes as $node) {
                if ($node->parent() === $this->root || $this->nodes->contains($node->parent())) {
                    $node->lock();
                }
            }
        }
    }
700399
def create_menubar(MAIN):
    """"""
    actions = MAIN.action
    menubar = MAIN.menuBar()
    menubar.clear()

    """ ------ FILE ------ """
    menu_file = menubar.addMenu('File')
    menu_file.addAction(MAIN.info.action['open_dataset'])
    submenu_recent = menu_file.addMenu('Recent Datasets')
    submenu_recent.addActions(MAIN.info.action['open_recent'])
    menu_file.addAction(MAIN.info.action['export'])

    menu_file.addSeparator()
    menu_file.addAction(actions['open_settings'])
    menu_file.addSeparator()
    menu_file.addAction(actions['close_wndw'])

    """ ------ CHANNELS ------ """
    actions = MAIN.channels.action
    menu_time = menubar.addMenu('Channels')
    menu_time.addAction(actions['load_channels'])
    menu_time.addAction(actions['save_channels'])

    """ ------ NAVIGATION ------ """
    actions = MAIN.traces.action

    menu_time = menubar.addMenu('Navigation')
    menu_time.addAction(actions['step_prev'])
    menu_time.addAction(actions['step_next'])
    menu_time.addAction(actions['page_prev'])
    menu_time.addAction(actions['page_next'])
    menu_time.addSeparator()
    menu_time.addAction(actions['addtime_-6h'])
    menu_time.addAction(actions['addtime_-1h'])
    menu_time.addAction(actions['addtime_-10min'])
    menu_time.addAction(actions['addtime_10min'])
    menu_time.addAction(actions['addtime_1h'])
    menu_time.addAction(actions['addtime_6h'])
    menu_time.addSeparator()
    menu_time.addAction(actions['next_event'])
    menu_time.addAction(actions['del_and_next_event'])
    menu_time.addAction(actions['next_of_same_type'])
    menu_time.addAction(actions['centre_event'])
    menu_time.addSeparator()
    menu_time.addAction(actions['go_to_epoch'])
    menu_time.addAction(actions['line_up_with_epoch'])

    """ ------ VIEW ------ """
    actions = MAIN.traces.action

    menu_view = menubar.addMenu('View')
    submenu_ampl = menu_view.addMenu('Global Scaling')
    submenu_ampl.addAction(actions['Y_less'])
    submenu_ampl.addAction(actions['Y_more'])
    submenu_ampl.addSeparator()
    for x in sorted(MAIN.value('y_scale_presets'), reverse=True):
        act = submenu_ampl.addAction('Set to ' + str(x))
        act.triggered.connect(partial(MAIN.traces.Y_ampl, x))

    submenu_dist = menu_view.addMenu('Distance Between Traces')
    submenu_dist.addAction(actions['Y_wider'])
    submenu_dist.addAction(actions['Y_tighter'])
    submenu_dist.addSeparator()
    for x in sorted(MAIN.value('y_distance_presets'),
                    reverse=True):
        act = submenu_dist.addAction('Set to ' + str(x))
        act.triggered.connect(partial(MAIN.traces.Y_dist, x))

    submenu_length = menu_view.addMenu('Window Length')
    submenu_length.addAction(actions['X_more'])
    submenu_length.addAction(actions['X_less'])
    submenu_length.addSeparator()
    for x in sorted(MAIN.value('window_length_presets'),
                    reverse=True):
        act = submenu_length.addAction('Set to ' + str(x))
        act.triggered.connect(partial(MAIN.traces.X_length, x))

    menu_view.addAction(actions['cross_chan_mrk'])

    menu_view.addSeparator()
    menu_view.addAction(actions['export_svg'])

    """ ------ ANNOTATIONS ------ """
    actions = MAIN.notes.action

    menu_annot = menubar.addMenu('Annotations')
    menu_annot.addAction(actions['new_annot'])
    menu_annot.addAction(actions['load_annot'])
    menu_annot.addAction(actions['clear_annot'])
    menu_annot.addSeparator()

    submenu_rater = menu_annot.addMenu('Rater')
    submenu_rater.addAction(actions['new_rater'])
    submenu_rater.addAction(actions['rename_rater'])
    submenu_rater.addAction(actions['del_rater'])
    submenu_rater.addSeparator()
    if MAIN.notes.annot is not None:
        for rater in sorted(MAIN.notes.annot.raters):
            act = submenu_rater.addAction(rater)
            act.triggered.connect(partial(MAIN.notes.select_rater, rater))
    menu_annot.addSeparator()

    submenu_marker = menu_annot.addMenu('Bookmark')
    submenu_marker.addAction(actions['new_bookmark'])

    submenu_event = menu_annot.addMenu('Event')
    submenu_event.addAction(actions['new_eventtype'])
    submenu_event.addAction(actions['del_eventtype'])
    submenu_event.addAction(actions['rename_eventtype'])
    submenu_mrk2evt = submenu_event.addMenu('Markers into Events')
    submenu_mrk2evt.addAction(actions['m2e_newname'])
    submenu_mrk2evt.addAction(actions['m2e_keepname'])
    submenu_event.addAction(actions['merge_events'])
    submenu_event.addAction(MAIN.traces.action['change_event_type'])

    # these are the real QActions attached to notes
    submenu_stage = menu_annot.addMenu('Stage')
    submenu_stage.addActions(MAIN.notes.actions())

    submenu_mrkr = menu_annot.addMenu('Cycle')
    submenu_mrkr.addAction(actions['cyc_start'])
    submenu_mrkr.addAction(actions['cyc_end'])
    submenu_mrkr.addAction(actions['remove_cyc'])
    submenu_mrkr.addAction(actions['clear_cyc'])
    menu_annot.addSeparator()

    submenu_import = menu_annot.addMenu('Import Staging')
    submenu_import.addAction(actions['import_alice'])
    submenu_import.addAction(actions['import_compumedics'])
    submenu_import.addAction(actions['import_deltamed'])
    submenu_import.addAction(actions['import_domino'])
    submenu_import.addAction(actions['import_prana'])
    submenu_import.addAction(actions['import_remlogic'])
    submenu_import.addAction(actions['import_sandman'])
    submenu_import.addAction(actions['import_fasst'])

    submenu_import_qual = menu_annot.addMenu('Import Signal Quality')
    submenu_import_qual.addAction(actions['import_alice_qual'])
    submenu_import_qual.addAction(actions['import_compumedics_qual'])
    submenu_import_qual.addAction(actions['import_deltamed_qual'])
    submenu_import_qual.addAction(actions['import_domino_qual'])
    submenu_import_qual.addAction(actions['import_prana_qual'])
    submenu_import_qual.addAction(actions['import_remlogic_qual'])
    submenu_import_qual.addAction(actions['import_sandman_qual'])
    
    submenu_import_event = menu_annot.addMenu('Import Events')
    submenu_import_event.addAction(actions['import_events_wonambi'])
    submenu_import_event.addAction(actions['import_events_remlogic'])
    menu_annot.addSeparator()
    
    submenu_export_staging = menu_annot.addMenu('Export Staging')
    submenu_export_staging.addAction(actions['export_to_csv'])
    submenu_export_staging.addAction(actions['export_to_remlogic'])
    submenu_export_staging.addAction(actions['export_to_remlogic_fr'])

    menu_annot.addAction(actions['export_events'])    
    menu_annot.addSeparator()
    
    menu_annot.addAction(actions['export_sleepstats'])

    """ ------ ANALYSIS ------ """
    actions = MAIN.notes.action

    menu_analysis = menubar.addMenu('Analysis')

    submenu_detect = menu_analysis.addMenu('Detection')
    submenu_detect.addAction(actions['spindle'])
    submenu_detect.addAction(actions['slow_wave'])

    menu_analysis.addAction(actions['analyze'])


    """ ------ WINDOWS ------ """
    actions = MAIN.action

    menu_window = menubar.addMenu('Windows')
    for dockwidget_act in actions['dockwidgets']:
        menu_window.addAction(dockwidget_act)
    MAIN.menu_window = menu_window

    menu_about = menubar.addMenu('About')
    menu_about.addAction(actions['about'])
    menu_about.addAction(actions['aboutqt'])
1343847
private function buildDemoMenuBar()
	{
		$this->layout_ui->getWidget('menu')->setEntries($this->available_demos);
		$this->layout_ui->getWidget('menu')->setSelectedEntry($this->demo);
	}
1300442
public function buildMenu()
    {
        $sessionClass = ReporticoSession();

        if (!$this->static_menu && !is_array($this->static_menu)) {
            $this->static_menu = ReporticoApp::get("static_menu");
        }

        // In admin mode static_menu shows all reports
        if ($sessionClass::issetReporticoSessionParam('admin_password')) {
            // .. unless an admin menu has been specified
            if (ReporticoApp::get("admin_menu")) {
                $this->static_menu = ReporticoApp::get("admin_menu");
            } else {
                $this->static_menu = array(array("report" => ".*\.xml", "title" => "<AUTO>"));
            }

        }

        $p = new DesignPanel($this, "MENU");
        $this->initializePanels("MENU");
        $this->setAttribute("ReportTitle", ReporticoApp::getConfig("project_title", "Report Suite"));

        if ($this->static_menu && is_array($this->static_menu)) {
            $ct = 0;
            foreach ($this->static_menu as $menuitem) {
                if ($menuitem["title"] == "<AUTO>") {
                    // Generate Menu from XML files
                    if (is_dir(ReporticoApp::get("projpath"))) {
                        if ($dh = opendir(ReporticoApp::get("projpath"))) {
                            while (($file = readdir($dh)) !== false) {
                                $mtch = "/^" . $menuitem["report"] . "/";
                                if (preg_match($mtch, $file)) {
                                    $repxml = new XmlReader($this, $file, false, "ReportTitle");
                                    $this->panels["MENU"]->setMenuItem($file, ReporticoLang::translate($repxml->search_response));
                                }
                            }
                            closedir($dh);
                        }
                    }
                } else {
                    $this->panels["MENU"]->setMenuItem($menuitem["report"], ReporticoLang::translate($menuitem["title"]));
                }

                $ct++;
            }

            if ($ct == 0) {
                ReporticoApp::handleError("No Menu Items Available - Check Language - " . ReporticoApp::get("language"));
            }

        }
    }
672507
private void buildUI() {
		add(new WSkipLinks());

		// the application header
		add(headerPanel);
		headerPanel.add(new UtilityBar());
		headerPanel.add(new WHeading(HeadingLevel.H1, "WComponents"));

		// mainPanel holds the menu and the actual example.
		add(mainPanel);
		mainPanel.add(menuPanel);
		mainPanel.add(exampleSection);

		// An application footer?
		WPanel footer = new WPanel(WPanel.Type.FOOTER);
		footer.add(lastLoaded);
		add(footer);
		add(new WAjaxControl(menuPanel.getTree(), new AjaxTarget[]{menuPanel.getMenu(), exampleSection}));
	}
1305752
private WMenu buildTreeMenuWithDecoratedLabel() {
		WMenu menu = new WMenu(WMenu.MenuType.TREE);

		WDecoratedLabel dLabel = new WDecoratedLabel(null, new WText("Settings Menu"), new WImage(
				"/image/settings.png", "settings"));
		WSubMenu settings = new WSubMenu(dLabel);
		settings.setMode(WSubMenu.MenuMode.LAZY);
		settings.setAccessKey('S');
		menu.add(settings);
		settings.add(new WMenuItem(new WDecoratedLabel(null, new WText("Account Settings"),
				new WImage("/image/user-properties.png", "user properties"))));
		settings.add(new WMenuItem(new WDecoratedLabel(null, new WText("Personal Details"),
				new WImage("/image/user.png", "user"))));
		WSubMenu addressSub = new WSubMenu(new WDecoratedLabel(null, new WText("Address Details"),
				new WImage("/image/address-book-open.png", "address book")));
		addressSub.setMode(WSubMenu.MenuMode.LAZY);
		settings.add(addressSub);
		addressSub.add(new WMenuItem(new WDecoratedLabel(null, new WText("Home Address"),
				new WImage("/image/home.png", "home"))));
		addressSub.add(new WMenuItem(new WDecoratedLabel(null, new WText("Work Address"),
				new WImage("/image/wrench.png", "work"))));
		addressSub.add(new WMenuItem(new WDecoratedLabel(null, new WText("Postal Address"),
				new WImage("/image/mail-post.png", "postal"))));


		WMenuItem itemWithIcon = new WMenuItem("Help");
		itemWithIcon.setAction(new Action() {
			@Override
			public void execute(final ActionEvent event) {
				// do something
			}
		});
		itemWithIcon.setHtmlClass(HtmlClassProperties.ICON_HELP_BEFORE);
		menu.add(itemWithIcon);
		return menu;
	}
1302962
private void buildChildMenus() {
        int i;
        JInternalFrame[] array = desktop.getAllFrames();

        add(cascade);
        add(tile);
        add(minAll);
        add(restoreAll);
        if (array.length > 0) {
            addSeparator();
        }
        cascade.setEnabled(array.length > 0);
        tile.setEnabled(array.length > 0);
        minAll.setEnabled(desktop.deIconifiedFrames() > 0);
        restoreAll.setEnabled(desktop.iconifiedFrames() > 0);

        ChildMenuItem menu;
        for (i = 0; i < array.length; i++) {
            menu = new ChildMenuItem(array[i]);
            menu.setState(i == 0);
            menu.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent ae) {
                    JInternalFrame frame =
                            ((ChildMenuItem) ae.getSource()).getFrame();
                    frame.moveToFront();
                    try {
                        frame.setSelected(true);
                    } catch (PropertyVetoException e) {
                        e.printStackTrace();
                    }
                }
            });
            menu.setIcon(array[i].getFrameIcon());
            add(menu);
        }
    }