@@ -1228,7 +1228,6 @@ public void rebuildBoardsMenu(JMenu toolsMenu, final Editor editor) {
1228
1228
// For every package cycle through all platform
1229
1229
for (TargetPlatform targetPlatform : targetPackage .platforms ()) {
1230
1230
String platformName = targetPlatform .getName ();
1231
- PreferencesMap customMenus = targetPlatform .getCustomMenus ();
1232
1231
1233
1232
if (targetPlatform .getPreferences ().get ("name" ) == null || targetPlatform .getBoards ().isEmpty ()) {
1234
1233
continue ;
@@ -1265,14 +1264,17 @@ public void actionPerformed(ActionEvent actionevent) {
1265
1264
menuItemsToClickAfterStartup .add (item );
1266
1265
}
1267
1266
1267
+ PreferencesMap customMenus = targetPlatform .getCustomMenus ();
1268
1268
int i = 0 ;
1269
- for (final String customMenuId : customMenus .topLevelKeySet ()) {
1270
- String title = customMenus .get (customMenuId );
1269
+ for (final String menuId : customMenus .keySet ()) {
1270
+ String title = customMenus .get (menuId );
1271
1271
JMenu menu = makeOrGetBoardMenu (toolsMenu , _ (title ));
1272
1272
1273
- Map <String , PreferencesMap > customMenu = customMenus .subTree (customMenuId ).firstLevelMap ();
1274
- if (customMenu .containsKey (boardId )) {
1275
- PreferencesMap boardCustomMenu = customMenu .get (boardId );
1273
+ //Map<String, PreferencesMap> customMenu = customMenus.subTree(menuId).firstLevelMap();
1274
+ if (board .hasMenuOptions (menuId )) {
1275
+ //if (customMenu.containsKey(boardId)) {
1276
+ //PreferencesMap boardCustomMenu = customMenu.get(boardId);
1277
+ PreferencesMap boardCustomMenu = board .getMenuOptions (menuId );
1276
1278
final int currentIndex = i + 1 + 1 ; //plus 1 to skip the first board menu, plus 1 to keep the custom menu next to this one
1277
1279
i ++;
1278
1280
for (String customMenuOption : boardCustomMenu .topLevelKeySet ()) {
@@ -1282,7 +1284,7 @@ public void actionPerformed(ActionEvent e) {
1282
1284
Preferences .set ("target_package" , (String ) getValue ("package" ));
1283
1285
Preferences .set ("target_platform" , (String ) getValue ("platform" ));
1284
1286
Preferences .set ("board" , (String ) getValue ("board" ));
1285
- Preferences .set ("custom_" + customMenuId , (String ) getValue ("board" ) + "_" + (String ) getValue ("custom_menu_option" ));
1287
+ Preferences .set ("custom_" + menuId , (String ) getValue ("board" ) + "_" + (String ) getValue ("custom_menu_option" ));
1286
1288
1287
1289
filterVisibilityOfSubsequentBoardMenus ((String ) getValue ("board" ), currentIndex );
1288
1290
@@ -1297,15 +1299,15 @@ public void actionPerformed(ActionEvent e) {
1297
1299
subAction .putValue ("package" , packageName );
1298
1300
subAction .putValue ("platform" , platformName );
1299
1301
1300
- if (!buttonGroupsMap .containsKey (customMenuId )) {
1301
- buttonGroupsMap .put (customMenuId , new ButtonGroup ());
1302
+ if (!buttonGroupsMap .containsKey (menuId )) {
1303
+ buttonGroupsMap .put (menuId , new ButtonGroup ());
1302
1304
}
1303
1305
1304
1306
item = new JRadioButtonMenuItem (subAction );
1305
1307
menu .add (item );
1306
- buttonGroupsMap .get (customMenuId ).add (item );
1308
+ buttonGroupsMap .get (menuId ).add (item );
1307
1309
1308
- String selectedCustomMenuEntry = Preferences .get ("custom_" + customMenuId );
1310
+ String selectedCustomMenuEntry = Preferences .get ("custom_" + menuId );
1309
1311
if (selBoard .equals (boardId ) && (boardId + "_" + customMenuOption ).equals (selectedCustomMenuEntry )) {
1310
1312
menuItemsToClickAfterStartup .add (item );
1311
1313
}
@@ -1932,16 +1934,21 @@ static public TargetPlatform getCurrentTargetPlatformFromPackage(String pack) {
1932
1934
1933
1935
static public PreferencesMap getBoardPreferences () {
1934
1936
TargetPlatform target = getTargetPlatform ();
1935
- String board = Preferences .get ("board" );
1936
- PreferencesMap boardPreferences = new PreferencesMap (target .getBoard (board ).getPreferences ());
1937
+ String boardId = Preferences .get ("board" );
1938
+ TargetBoard board = target .getBoard (boardId );
1939
+ PreferencesMap boardPreferences = new PreferencesMap (board .getPreferences ());
1937
1940
PreferencesMap customMenus = target .getCustomMenus ();
1938
- for (String customMenuID : customMenus .topLevelKeySet ()) {
1939
- PreferencesMap boardCustomMenu = customMenus .subTree (customMenuID ).subTree (board );
1940
- String selectedCustomMenuEntry = Preferences .get ("custom_" + customMenuID );
1941
- if (boardCustomMenu .size () > 0 && selectedCustomMenuEntry != null && selectedCustomMenuEntry .startsWith (board )) {
1942
- String menuEntryId = selectedCustomMenuEntry .substring (selectedCustomMenuEntry .indexOf ("_" ) + 1 );
1941
+ for (String menuId : customMenus .keySet ()) {
1942
+ PreferencesMap boardCustomMenu = board .getMenuOptions (menuId );
1943
+ String selectedCustomMenuEntry = Preferences .get ("custom_" + menuId );
1944
+ if (boardCustomMenu != null && boardCustomMenu .size () > 0 &&
1945
+ selectedCustomMenuEntry != null &&
1946
+ selectedCustomMenuEntry .startsWith (boardId )) {
1947
+ String menuEntryId = selectedCustomMenuEntry
1948
+ .substring (selectedCustomMenuEntry .indexOf ("_" ) + 1 );
1943
1949
boardPreferences .putAll (boardCustomMenu .subTree (menuEntryId ));
1944
- boardPreferences .put ("name" , boardPreferences .get ("name" ) + ", " + boardCustomMenu .get (menuEntryId ));
1950
+ boardPreferences .put ("name" , boardPreferences .get ("name" ) + ", " +
1951
+ boardCustomMenu .get (menuEntryId ));
1945
1952
}
1946
1953
}
1947
1954
return boardPreferences ;
0 commit comments