protected JMenu buildToolsMenu() {
    toolsMenu = new JMenu("Tools");
    JMenu menu = toolsMenu;
    JMenuItem item;

    addInternalTools(menu);
    addTools(menu, Base.getToolsFolder());
    File sketchbookTools = new File(Base.getSketchbookFolder(), "tools");
    addTools(menu, sketchbookTools);

    menu.addSeparator();
    
    numTools = menu.getItemCount();
    
    // XXX: DAM: these should probably be implemented using the Tools plugin
    // API, if possible (i.e. if it supports custom actions, etc.)
    
    if (boardsMenu == null) {
      boardsMenu = new JMenu("Board");
      ButtonGroup boardGroup = new ButtonGroup();
      for (Iterator i = Preferences.getSubKeys("boards"); i.hasNext(); ) {
        String board = (String) i.next();
        Action action = new BoardMenuAction(board);
        item = new JRadioButtonMenuItem(action);
        if (board.equals(Preferences.get("board")))
          item.setSelected(true);
        boardGroup.add(item);
        boardsMenu.add(item);
      }
    }
    menu.add(boardsMenu);

    /*
      
    if (serialMenuListener == null)
      serialMenuListener  = new SerialMenuListener();
    if (serialMenu == null)
      serialMenu = new JMenu("Serial Port");
    populateSerialMenu();
    menu.add(serialMenu);
	  
    menu.addSeparator();

    JMenu bootloaderMenu = new JMenu("Burn Bootloader");
    for (Iterator i = Preferences.getSubKeys("programmers"); i.hasNext(); ) {
      String programmer = (String) i.next();
      Action action = new BootloaderMenuAction(programmer);
      item = new JMenuItem(action);
      bootloaderMenu.add(item);
    }
    menu.add(bootloaderMenu);
        
    */

    if (midiInputMenuListener == null)
      midiInputMenuListener = new MidiInputMenuListener();
    if (midiOutputMenuListener == null)
      midiOutputMenuListener = new MidiOutputMenuListener();
    
      if (midiMenu == null) {
          midiMenu = new JMenu("MIDI Ports");
          populateMidiMenu();
          menu.add(midiMenu);
      }
    
    menu.addMenuListener(new MenuListener() {
      public void menuCanceled(MenuEvent e) {}
      public void menuDeselected(MenuEvent e) {}
      public void menuSelected(MenuEvent e) {
        //System.out.println("Tools menu selected.");
        //        populateSerialMenu();
      }
    });

    return menu;
  }