Skip to content

Commit

Permalink
Do not use a boards submenu with just one platform
Browse files Browse the repository at this point in the history
When just one platform is installed, it does not make much sense to use
a submenu, so just add the boards directly under the boards menu as
before.
  • Loading branch information
matthijskooijman committed Sep 19, 2019
1 parent 2a8a47e commit a3da5c1
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -1468,18 +1468,30 @@ public void actionPerformed(ActionEvent actionevent) {
ButtonGroup boardsButtonGroup = new ButtonGroup();
Map<String, ButtonGroup> buttonGroupsMap = new HashMap<>();

int platformCount = 0;
for (TargetPackage targetPackage : BaseNoGui.packages.values()) {
for (TargetPlatform targetPlatform : targetPackage.platforms()) {
++platformCount;
}
}

// Cycle through all packages
for (TargetPackage targetPackage : BaseNoGui.packages.values()) {
// For every package cycle through all platform
for (TargetPlatform targetPlatform : targetPackage.platforms()) {
JMenu platformBoardsMenu;
if (platformCount == 1) {
// With just single platform, just add all platforms directly
platformBoardsMenu = boardMenu;
} else {
// Add a submenu for each platform
String platformLabel = targetPlatform.getPreferences().get("name");
if (platformLabel == null)
platformLabel = targetPackage.getId() + "-" + targetPlatform.getId();

// Add a title for each platform
String platformLabel = targetPlatform.getPreferences().get("name");
if (platformLabel == null)
platformLabel = targetPackage.getId() + "-" + targetPlatform.getId();

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

// Cycle through all boards of this platform
for (TargetBoard board : targetPlatform.getBoards().values()) {
Expand Down

0 comments on commit a3da5c1

Please sign in to comment.