From a3da5c14524873abdc27eaed90d6fa45476569a5 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 19 Sep 2019 17:03:34 +0200 Subject: [PATCH] Do not use a boards submenu with just one platform 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. --- app/src/processing/app/Base.java | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index eb2705abd1d..e783c7003e1 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1468,18 +1468,30 @@ public void actionPerformed(ActionEvent actionevent) { ButtonGroup boardsButtonGroup = new ButtonGroup(); Map 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()) {