MCPcopy Index your code
hub / github.com/arduino/Arduino / createBoardMenusAndCustomMenus

Method createBoardMenusAndCustomMenus

app/src/processing/app/Base.java:1552–1627  ·  view source on GitHub ↗
(
          final List<JMenu> boardsCustomMenus, List<JMenuItem> menuItemsToClickAfterStartup,
          Map<String, ButtonGroup> buttonGroupsMap,
          TargetBoard board, TargetPlatform targetPlatform, TargetPackage targetPackage)

Source from the content-addressed store, hash-verified

1550 }
1551
1552 private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
1553 final List<JMenu> boardsCustomMenus, List<JMenuItem> menuItemsToClickAfterStartup,
1554 Map<String, ButtonGroup> buttonGroupsMap,
1555 TargetBoard board, TargetPlatform targetPlatform, TargetPackage targetPackage)
1556 throws Exception {
1557 String selPackage = PreferencesData.get("target_package");
1558 String selPlatform = PreferencesData.get("target_platform");
1559 String selBoard = PreferencesData.get("board");
1560
1561 String boardId = board.getId();
1562 String packageName = targetPackage.getId();
1563 String platformName = targetPlatform.getId();
1564
1565 // Setup a menu item for the current board
1566 @SuppressWarnings("serial")
1567 Action action = new AbstractAction(board.getName()) {
1568 public void actionPerformed(ActionEvent actionevent) {
1569 BaseNoGui.selectBoard((TargetBoard) getValue("b"));
1570 filterVisibilityOfSubsequentBoardMenus(boardsCustomMenus, (TargetBoard) getValue("b"), 1);
1571
1572 onBoardOrPortChange();
1573 rebuildImportMenu(Editor.importMenu);
1574 rebuildExamplesMenu(Editor.examplesMenu);
1575 rebuildProgrammerMenu();
1576 }
1577 };
1578 action.putValue("b", board);
1579
1580 JRadioButtonMenuItem item = new JRadioButtonMenuItem(action);
1581
1582 if (selBoard.equals(boardId) && selPackage.equals(packageName)
1583 && selPlatform.equals(platformName)) {
1584 menuItemsToClickAfterStartup.add(item);
1585 }
1586
1587 PreferencesMap customMenus = targetPlatform.getCustomMenus();
1588 for (final String menuId : customMenus.keySet()) {
1589 String title = customMenus.get(menuId);
1590 JMenu menu = getBoardCustomMenu(tr(title), getPlatformUniqueId(targetPlatform));
1591
1592 if (board.hasMenu(menuId)) {
1593 PreferencesMap boardCustomMenu = board.getMenuLabels(menuId);
1594 for (String customMenuOption : boardCustomMenu.keySet()) {
1595 @SuppressWarnings("serial")
1596 Action subAction = new AbstractAction(tr(boardCustomMenu.get(customMenuOption))) {
1597 public void actionPerformed(ActionEvent e) {
1598 PreferencesData.set("custom_" + menuId, ((List<TargetBoard>) getValue("board")).get(0).getId() + "_" + getValue("custom_menu_option"));
1599 onBoardOrPortChange();
1600 }
1601 };
1602 List<TargetBoard> boards = (List<TargetBoard>) subAction.getValue("board");
1603 if (boards == null) {
1604 boards = new ArrayList<>();
1605 }
1606 boards.add(board);
1607 subAction.putValue("board", boards);
1608 subAction.putValue("custom_menu_option", customMenuOption);
1609

Callers 1

rebuildBoardsMenuMethod · 0.95

Calls 15

getMethod · 0.95
getMethod · 0.95
getBoardCustomMenuMethod · 0.95
getPlatformUniqueIdMethod · 0.95
trMethod · 0.80
putMethod · 0.80
getIdMethod · 0.65
getNameMethod · 0.65
getCustomMenusMethod · 0.65
hasMenuMethod · 0.65
getMenuLabelsMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected