(
final List<JMenu> boardsCustomMenus, List<JMenuItem> menuItemsToClickAfterStartup,
Map<String, ButtonGroup> buttonGroupsMap,
TargetBoard board, TargetPlatform targetPlatform, TargetPackage targetPackage)
| 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 |
no test coverage detected