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 e35a772 commit c33a3e9
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -1468,19 +1468,31 @@ 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()) {

// 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));
MenuScroller.setScrollerFor(platformBoardsMenu);
boardMenu.add(platformBoardsMenu);
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();

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 Down

0 comments on commit c33a3e9

Please sign in to comment.