Skip to content

Commit a3da5c1

Browse files
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.
1 parent 2a8a47e commit a3da5c1

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

app/src/processing/app/Base.java

+19-7
Original file line numberDiff line numberDiff line change
@@ -1468,18 +1468,30 @@ public void actionPerformed(ActionEvent actionevent) {
14681468
ButtonGroup boardsButtonGroup = new ButtonGroup();
14691469
Map<String, ButtonGroup> buttonGroupsMap = new HashMap<>();
14701470

1471+
int platformCount = 0;
1472+
for (TargetPackage targetPackage : BaseNoGui.packages.values()) {
1473+
for (TargetPlatform targetPlatform : targetPackage.platforms()) {
1474+
++platformCount;
1475+
}
1476+
}
1477+
14711478
// Cycle through all packages
14721479
for (TargetPackage targetPackage : BaseNoGui.packages.values()) {
14731480
// For every package cycle through all platform
14741481
for (TargetPlatform targetPlatform : targetPackage.platforms()) {
1482+
JMenu platformBoardsMenu;
1483+
if (platformCount == 1) {
1484+
// With just single platform, just add all platforms directly
1485+
platformBoardsMenu = boardMenu;
1486+
} else {
1487+
// Add a submenu for each platform
1488+
String platformLabel = targetPlatform.getPreferences().get("name");
1489+
if (platformLabel == null)
1490+
platformLabel = targetPackage.getId() + "-" + targetPlatform.getId();
14751491

1476-
// Add a title for each platform
1477-
String platformLabel = targetPlatform.getPreferences().get("name");
1478-
if (platformLabel == null)
1479-
platformLabel = targetPackage.getId() + "-" + targetPlatform.getId();
1480-
1481-
JMenu platformBoardsMenu = new JMenu(tr(platformLabel));
1482-
boardMenu.add(platformBoardsMenu);
1492+
platformBoardsMenu = new JMenu(tr(platformLabel));
1493+
boardMenu.add(platformBoardsMenu);
1494+
}
14831495

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

0 commit comments

Comments
 (0)