Skip to content

Commit

Permalink
Separate the boards menu per platform
Browse files Browse the repository at this point in the history
Previously, the Tools->Boards menu was one long list, divided into
different platforms by (unselectable) headers. When more than one or two
platforms were installed, this quickly results in a very long list of
boards that is hard to navigate.

This commit changes the board menu to have a submenu for each platform,
where each submenu contains just the boards for that platform.

This fixes part of arduino#8858.
  • Loading branch information
matthijskooijman committed Jan 26, 2020
1 parent e94d676 commit 7d43914
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -1472,23 +1472,18 @@ public void actionPerformed(ActionEvent actionevent) {
JMenuItem firstBoardItem = null;

// Cycle through all packages
boolean first = true;
for (TargetPackage targetPackage : BaseNoGui.packages.values()) {
// For every package cycle through all platform
for (TargetPlatform targetPlatform : targetPackage.platforms()) {

// Add a separator from the previous platform
if (!first)
boardMenu.add(new JSeparator());
first = false;

// Add a title for each platform
String platformLabel = targetPlatform.getPreferences().get("name");
if (platformLabel != null && !targetPlatform.getBoards().isEmpty()) {
JMenuItem menuLabel = new JMenuItem(tr(platformLabel));
menuLabel.setEnabled(false);
boardMenu.add(menuLabel);
}
if (platformLabel == null)
platformLabel = targetPackage.getId() + "-" + targetPlatform.getId();

JMenu platformBoardsMenu = new JMenu(tr(platformLabel));
MenuScroller.setScrollerFor(platformBoardsMenu);
boardMenu.add(platformBoardsMenu);

// Cycle through all boards of this platform
for (TargetBoard board : targetPlatform.getBoards().values()) {
Expand All @@ -1497,7 +1492,7 @@ public void actionPerformed(ActionEvent actionevent) {
JMenuItem item = createBoardMenusAndCustomMenus(boardsCustomMenus, menuItemsToClickAfterStartup,
buttonGroupsMap,
board, targetPlatform, targetPackage);
boardMenu.add(item);
platformBoardsMenu.add(item);
boardsButtonGroup.add(item);

if (firstBoardItem == null)
Expand Down

0 comments on commit 7d43914

Please sign in to comment.