Print Menu & Submenu Tree
495732
private function printMenuTree() {
		/*
		* The elements in the array are :
		*   0: Menu item name
		*   1: Minimum level or capability required.
		*   2: The URL of the item's file
		*   3: Class
		*   4: ID
		*   5: Icon for top level menu
		*/
		global $menu, $submenu;
		if ( ! is_iterable( $menu ) ) {
			return;
		}

		echo '<ul class="ul-disc">';
		foreach ( $menu as $arr1 ) {
			if ( empty( $arr1[0] ) ) {
				continue;
			}
			$menu_hook = get_plugin_page_hook( $arr1[2], null );
			if ( $menu_hook ) {
				$href = 'admin.php?page=' . $arr1[2];
			} else {
				$href = $arr1[2];
			}
			echo "<li><a href='{$href}'>{$arr1[0]}</a>";
			foreach ( $submenu as $k => $arr2 ) {
				if ( $k === $arr1[2] ) {
					echo '<ul class="ul-disc">';
					foreach ( $arr2 as $arr3 ) {
						$menu_hook = get_plugin_page_hook( $arr3[2], $k );
						if ( $menu_hook ) {
							if ( str_ends_with( $k, '.php' ) ) {
								$href = "{$k}?page={$arr3[2]}";
							} else {
								$href = "admin.php?page={$arr3[2]}";
							}
						} else {
							$href = $arr3[2];
						}
						echo "<li><a href='{$href}'>{$arr3[0]}</a>";
					}
					echo '</ul>';
					continue;
				}
			}
		}
		echo '</ul>';
	}
1193416
public void printXmlHeader(PrintWriter out, ResourceBundle reg)
    {
        String strTopMenu = reg.getString("xmlHeader");
        if ((strTopMenu == null) || (strTopMenu.length() == 0))
            strTopMenu =
                " <top-menu>" +
                "   <menu-item>" +
                "       <description>Site home page</description>" +
                "       <link>?menu=Main</link>" +
                "       <image>Home</image>" +
                "       <name>Home</name>" +
                "   </menu-item>" +
                "   <menu-item>" +
                "       <description>My home</description>" +
                "       <link>?menu=</link>" +
                "       <image>MyHome</image>" +
                "   </menu-item>" +
                "   <menu-item>" +
                "       <description>View or change preferences</description>" +
                "       <link>" + HtmlConstants.SERVLET_LINK+ "?screen=org.jbundle.main.screen.UserPreferenceScreen&amp;java=no</link>" +
                "       <image>Lookup</image>" +
                "       <name>Preferences</name>" +
                "   </menu-item>" +
                "   <menu-item>" +
                "       <description>About us</description>" +
                "       <link>" + '?' + DBParams.HELP + '=' + "&amp;xml=docs/com/aboutus.xml</link>" +
                "       <image>About</image>" +
                "   </menu-item>" +
                "   <help-item>" +
                "       <menu-item>" +
                "           <description>Help for the current screen</description>" +
                "           <link>" + '?' + DBParams.HELP + '=' + "&amp;{url}&amp;class={helpclass}</link>" +
                "           <image>Help</image>" +
                "       </menu-item>" +
                "   </help-item>" +
                " </top-menu>";
        
        String strTitle = this.getProperty(XMLTags.TITLE);                // Menu page
        if ((strTitle == null) || (strTitle.length() == 0))
            strTitle = ((BasePanel)this.getScreenField()).getTitle();
        String strURL = this.getThisURL();
        if (strURL == null)
            strURL = DBConstants.BLANK;
        if (strURL.length() > 0)
            if (strURL.charAt(0) == '?')
                strURL = strURL.substring(1); // Always
        strURL = Utility.encodeXML(strURL);   // Convert < to &lt; , etc.

        Hashtable<String,Object> ht = new Hashtable<String,Object>();
        ht.put("helpclass", HelpScreen.class.getName());
        ht.put(XMLTags.URL, strURL);
        ht.put(XMLTags.TITLE, strTitle);
        String strUserName = this.getProperty(DBParams.USER_NAME);
        if (strUserName == null)
            strUserName = DBConstants.BLANK;
//x        ht.put(XMLTags.USER_NAME, strUserName);  // This is available in /full-screen/params/user
        String strLogin = "Login";
        if (strUserName.length() > 0)
            strLogin = "Logout";
        ht.put("loginIcon", strLogin);
        ht.put("loginDesc", reg.getString(strLogin));
        String strLoginLink = "?screen=" + UserInfoModel.USER_LOGIN_SCREEN_CLASS + "&amp;java=no";
        if (strUserName.length() > 0)
            strLoginLink = "?user=&amp;menu=";
        ht.put("loginLink", strLoginLink);
        
        strTopMenu = Utility.replaceResources(strTopMenu, reg, ht, null);

        out.println(strTopMenu);
    }
1286290
def repaint # menu.repaint
      # OMG will not print anything if no items !
      # When we do item generation this list will be empty
      #return if @items.nil? or @items.empty? # commented 2011-09-24 NEWMENU
      #$log.debug "menu repaint: #{text} row #{@row} col #{@col}  " 
      @color_pair  = get_color($reversecolor, @color, @bgcolor)
      if !@parent.is_a? Canis::MenuBar 
        @parent.window.printstring( @row, 0, "|%-*s>|" % [@width-1, text], @color_pair)
        @parent.window.refresh
      end
      if @window.nil?
        #create_window
      else
        @window.show
        select_item 0
        @window.refresh
      end
    end
385575
function _createMenu () {
  // Set up the application menu1
  const template = [
    {
      label: 'File',
      submenu: [
        {
          label: 'New',
          submenu: [
            {
              label: 'Article',
              accelerator: 'CommandOrControl+N',
              click () {
                _openNew('article')
              }
            },
            {
              label: 'Figure Package',
              click () {
                _openNew('figure-package')
              }
            }
          ]
        },
        {
          label: 'Open',
          accelerator: 'CommandOrControl+O',
          click () {
            _promptOpen()
          }
        },
        {
          label: 'Save',
          accelerator: 'CommandOrControl+S',
          click () {
            _save()
          }
        },
        {
          label: 'Save As...',
          accelerator: 'CommandOrControl+Shift+S',
          click () {
            _saveAs()
          }
        }
      ]
    },
    {
      label: 'Edit',
      submenu: [
        { role: 'undo' },
        { role: 'redo' },
        { type: 'separator' },
        { role: 'cut' },
        { role: 'copy' },
        { role: 'paste' },
        { role: 'pasteandmatchstyle' },
        { role: 'delete' },
        { role: 'selectall' }
      ]
    },
    {
      label: 'View',
      submenu: [
        { role: 'toggledevtools' },
        { type: 'separator' },
        { role: 'resetzoom' },
        { role: 'zoomin' },
        { role: 'zoomout' },
        { type: 'separator' },
        { role: 'togglefullscreen' }
      ]
    },
    {
      role: 'window',
      submenu: [
        { role: 'minimize' },
        { role: 'close' }
      ]
    },
    {
      role: 'help',
      submenu: [
        {
          label: 'Learn More',
          click () {
            // TODO: why not use the globally required electron?
            shell.openExternal('http://substance.io/texture')
          }
        }
      ]
    }
  ]

  if (process.platform === 'darwin') {
    template.unshift({
      label: app.getName(),
      submenu: [
        { role: 'about' },
        { type: 'separator' },
        { role: 'services', submenu: [] },
        { type: 'separator' },
        { role: 'hide' },
        { role: 'hideothers' },
        { role: 'unhide' },
        { type: 'separator' },
        { role: 'quit' }
      ]
    })
  }

  const menu = Menu.buildFromTemplate(template)
  Menu.setApplicationMenu(menu)
}
89322
def print_tree(sent, token_attr):
    
    def __print_sent__(token, attr):
        print("{", end=" ")
        [__print_sent__(t, attr) for t in token.lefts]
        print(u"%s->%s(%s)" % (token,token.dep_,token.tag_ if not attr else getattr(token, attr)), end="")
        [__print_sent__(t, attr) for t in token.rights]
        print("}", end=" ")
    return __print_sent__(sent.root, token_attr)
442371
function Menu() {
  ui.Emitter.call(this);
  this.items = {};
  this.el = $(html).hide().appendTo('body');
  this.el.hover(this.deselect.bind(this));
  $('html').click(this.hide.bind(this));
  this.on('show', this.bindKeyboardEvents.bind(this));
  this.on('hide', this.unbindKeyboardEvents.bind(this));
}
239961
def debug_print_tree( self, spacing='' ):
        '''  '''
        print (spacing+" "+str(self.word_id)+" "+str(self.text))
        if (self.children):
            spacing=spacing+"  "
            for child in self.children:
                child.debug_print_tree(spacing)
117322
public void printHtmlNavMenu(PrintWriter out)
        throws DBException
    {
        if (HHelpScreen.getFirstToUpper(this.getProperty(DBParams.NAVMENUS)) != UserInfoModel.NO_ICONS.charAt(0))
            super.printHtmlNavMenu(out);
        else
        { // Applets frequently turn off menu bars temporarly
            String strHTML = "\t<tr valign=top>\n\t<td>"; // Default menu = no table items
            out.println(strHTML);
        }
    }
1166748
def print_meta(ds, ds_path=None):
    ""

    print('\n#' + ds_path)
    for sub, cls in ds.classes.items():
        print('{},{}'.format(sub, cls))

    return
88770
def print_item_with_children(ac, classes, level):
    
    print_row(ac.id, ac.name, f"{ac.allocation:,.2f}", level)
    print_children_recursively(classes, ac, level + 1)
979291
def menu_tree mt, pm = self
      mt.each_pair { |ch, code| 
        if code.is_a? Canis::MenuTree
          item = pm.add(ch, code.value, "") 
          current = PromptMenu.new @caller, code.value
          item.action = current
          menu_tree code, current
        else
          item = pm.add(ch, code.to_s, "", code) 
        end
      }
    end
62497
def print_tree(graph, tails, node_id_map):
    """"""
    # Example:
    # |
    # | 5
    # *  a {0, 1, 2, 3, 4}
    # |
    # | 6
    # |\
    # * |  b {0, 1, 2, 3}
    # | *  n {4}
    # | |
    # | | 7
    # * |  c {0, 1, 2, 3}
    # | *  o {4}
    # | |
    # | | 8
    # |\ \
    # * | |  i {2, 3}
    # | * |  d {0, 1}
    # | | *  p {4}
    # | | |
    # | | | 9
    # * | |  j {2, 3}
    # | * |  e {0, 1}
    # | | *  q {4}
    # | | |
    # | | | 10
    # * | |  k {2, 3}
    # | * |  f {0, 1}
    # | | *  r {4}
    # | | |
    # | | | 11
    # |\ \ \
    # | | |\ \
    # * | | | |    g {0}
    # | * | | |    h {1}
    # |   * | |    l {2}
    # |   | * |    m {3}
    # |   |   *    s {4}
    # |  /   /
    # | |  /
    # | | | 12
    # * | |   t {0}
    # | * |   u {2}
    # | | *   v {4}
    # | |
    # | | 13
    # * |   w {0}
    # | *   x {2}
    # |
    # | 14
    # *   y {0}
    # | 15
    # *   z {0}

    walker = graph.walk()
    next_block_num, next_parent, next_siblings = next(walker)
    prev_cliques = []

    done = False
    while not done:
        cliques = {}
        block_num = next_block_num

        # Read all the cliques for this block number
        try:
            while block_num == next_block_num:
                cliques[next_parent] = next_siblings
                next_block_num, next_parent, next_siblings = next(walker)
        except StopIteration:
            # Do one last iteration after we've consumed the entire graph
            done = True

        print_cliques(prev_cliques, cliques, node_id_map)

        print_block_num_row(block_num, prev_cliques, cliques)

        print_splits(prev_cliques, cliques)

        print_folds(prev_cliques, cliques)

        prev_cliques = build_ordered_cliques(prev_cliques, cliques)

    print_cliques(prev_cliques, [], node_id_map)
567309
def _build_menu(docs):
    

    paths = []
    current = docs.filename
    while current != docs.root:
        current = current.parent
        paths.append(current)

    for path in reversed(paths):
        docs.add_menu(path.stem.title(), link=path / 'index.html')

    if docs.filename.stem != 'index':
        docs.add_menu(docs.title, link=docs.filename)

    docs.end_menu()
1224698
public void printHtmlNavMenu(PrintWriter out)
        throws DBException
    {
        String strHTML = null, strStart = null, strEnd = null;
        ResourceBundle reg = ((BaseApplication)this.getTask().getApplication()).getResources(HtmlConstants.HTML_RESOURCE, false);

        char ch = HBasePanel.getFirstToUpper(this.getProperty(DBParams.NAVMENUS), ' ');
        if (ch != UserInfoModel.NO_ICONS.charAt(0))
        {
            String strMenu = this.getProperty(DBParams.MENU); // This user's nav menu
            if ((strMenu == null) || (strMenu.length() == 0))
                strMenu = "NavMenu";
            if (ch == UserInfoModel.ICONS_ONLY.charAt(0))  /** Icons only */
            {
                strStart = reg.getString("htmlNavIconsOnlyStart");
                strHTML = reg.getString(strMenu + "IconsOnly");
                if ((strHTML == null) || (strHTML.length() == 0))
                    strHTML = reg.getString("htmlNavMenuIconsOnly");
                strEnd = reg.getString("htmlNavIconsOnlyEnd");
            }
            if ((strHTML == null) || (strHTML.length() == 0))
                strHTML = reg.getString(strMenu);
            if ((strHTML == null) || (strHTML.length() == 0))
                strHTML = reg.getString("htmlNavMenu");
                
            if ((strStart == null) || (strStart.length() == 0))
                strStart = reg.getString("htmlNavStart");
            if ((strEnd == null) || (strEnd.length() == 0))
                strEnd = reg.getString("htmlNavEnd");
        }
        if ((strHTML == null) || (strHTML.length() == 0) || 
            (strStart == null) || (strStart.length() == 0) || 
                (strEnd == null) || (strEnd.length() == 0))
        {
            strStart = Constants.BLANK;
            strHTML = Constants.BLANK;  // "\t<tr valign=top>\n\t<td>";  // Default menu = no table items
            strEnd = Constants.BLANK;
        }
        out.println(strStart);
        out.println(strHTML);
        out.println(strEnd);
    }
1098550
private void mapTreeHierarchy(final WComponent currentComponent,
			final StringTreeNode currentNode, final WText selectedMenuText) {
		if (currentNode.isLeaf()) {
			WMenuItem menuItem = new WMenuItem(currentNode.getData(), new ExampleMenuAction(
					selectedMenuText));
			menuItem.setActionObject(currentNode.getData());
			if (currentComponent instanceof WMenu) {
				((WMenu) currentComponent).add(menuItem);
			} else {
				((WSubMenu) currentComponent).add(menuItem);
			}
		} else {
			WSubMenu subMenu = new WSubMenu(currentNode.getData());
			subMenu.setSelectMode(SelectMode.SINGLE);

			if (currentComponent instanceof WMenu) {
				((WMenu) currentComponent).add(subMenu);
			} else {
				((WSubMenu) currentComponent).add(subMenu);
			}

			// Expand the first couple of levels in the tree by default.
			if (currentNode.getLevel() < 2) {
				subMenu.setOpen(true);
			}

			for (Iterator<TreeNode> i = currentNode.children(); i.hasNext();) {
				mapTreeHierarchy(subMenu, (StringTreeNode) i.next(), selectedMenuText);
			}
		}
	}
1177541
def _add_submenu(self, parent, data):
        """"""

        for item in data:
            obj = item[0]
            if obj == wx.Menu:
                try:
                    __, menuname, submenu, menu_id = item
                except ValueError:
                    __, menuname, submenu = item
                    menu_id = -1

                menu = obj()
                self._add_submenu(menu, submenu)

                if parent == self:
                    self.menubar.Append(menu, menuname)
                else:
                    parent.AppendMenu(menu_id, menuname, menu)

            elif obj == wx.MenuItem:
                try:
                    msgtype, shortcut, helptext, item_id = item[1]
                except ValueError:
                    msgtype, shortcut, helptext = item[1]
                    item_id = wx.NewId()

                try:
                    style = item[2]
                except IndexError:
                    style = wx.ITEM_NORMAL

                menuitem = obj(parent, item_id, shortcut, helptext, style)
                self.shortcut2menuitem[shortcut] = menuitem
                self.id2menuitem[item_id] = menuitem

                parent.AppendItem(menuitem)

                self.ids_msgs[item_id] = msgtype

                self.parent.Bind(wx.EVT_MENU, self.OnMenu, id=item_id)

            elif obj == "Separator":
                parent.AppendSeparator()

            else:
                raise TypeError(_("Menu item unknown"))
989945
public void printScreen(PrintWriter out, ResourceBundle reg)
        throws DBException
    {
        String strHTML = "";

        ClassInfoModel classInfo = (ClassInfoModel)Record.makeRecordFromClassName(ClassInfoModel.THICK_CLASS, ((HelpScreen)this.getScreenField()));
        if (classInfo != null)
            classInfo = classInfo.readClassInfo(((HelpScreen)this.getScreenField()), null);

        String strClassName = classInfo.getClassName();
        if ((strClassName != null) && (strClassName.equalsIgnoreCase("MenuScreen")))
        {
            strHTML = reg.getString("htmlHelpMenu");
            if ((strHTML == null) || (strHTML.length() == 0))
                strHTML =
                    "<CENTER><h2>" + HtmlConstants.TITLE_TAG + "</h2></CENTER>" +
                    "<h3>Description:</h3>" +
                    "<p>" + HtmlConstants.MENU_DESC_TAG + "</p>" + 
                    "<h3>Menu items:</h3>";
            Record menu = Record.makeRecordFromClassName(MenusModel.THICK_CLASS, null);
            menu.setKeyArea(MenusModel.TYPE_KEY);
            menu.getField(MenusModel.TYPE).setString(DBParams.MENU);
            String strParamMenu = this.getProperty(DBParams.MENU);      // Display record
            menu.getField(MenusModel.PROGRAM).setString(strParamMenu);
            boolean bSuccess = menu.seek("=");
            if (!bSuccess)
                ;   // Do something?
            XMLParser parser = new MenuParser((HelpScreen)this.getScreenField(), menu);
            parser.parseHtmlData(out, strHTML);
            parser.free();
            parser = null;

            menu.free();
            menu = null;
        }
        else
        {
            if (strHTML.length() == 0)
            {
                if ((strClassName != null) && (strClassName.length() > 0))
                    strHTML = reg.getString("htmlHelp");
                else
                {
                    strHTML = reg.getString("htmlHelpDefault");
                    out.println(strHTML);
                    classInfo.free();
                    classInfo = null;
                    return;
                }
            }
            if ((strHTML == null) || (strHTML.length() == 0))
                strHTML =
                "<h2>" + HtmlConstants.TITLE_TAG + "</h2>" +
                "<h3>Description:</h3>" +
                "<p>" + HtmlConstants.MENU_DESC_TAG + "</p>" +
                "<h3>Operation:</h3>" +
                "<p>" + HtmlConstants.HELP_TAG + "</p>";
    
            XMLParser parser = new HelpParser((HelpScreen)this.getScreenField(), classInfo);
            parser.parseHtmlData(out, strHTML);
            parser.free();
            parser = null;
        }
        classInfo.free();
        classInfo = null;
    }