@@ -395,8 +395,20 @@ public Base(String[] args) throws Exception {
395
395
Thread .sleep (10 );
396
396
397
397
// Do board selection if requested
398
- if (selectBoard != null )
399
- selectBoard (selectBoard );
398
+ if (selectBoard != null ) {
399
+ String [] split = selectBoard .split (":" );
400
+
401
+ TargetBoard targetBoard = getTargetPlatform (split [0 ], split [1 ]).getBoard (split [2 ]);
402
+ selectBoard (targetBoard );
403
+
404
+ if (split .length > 3 ) {
405
+ String [] customsParts = split [3 ].split ("," );
406
+ for (String customParts : customsParts ) {
407
+ String [] keyValue = customParts .split ("=" );
408
+ Preferences .set ("custom_" + keyValue [0 ].trim (), targetBoard .getId () + "_" + keyValue [1 ].trim ());
409
+ }
410
+ }
411
+ }
400
412
401
413
if (doUpload ) {
402
414
// Build and upload
@@ -1347,10 +1359,10 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
1347
1359
@ SuppressWarnings ("serial" )
1348
1360
Action action = new AbstractAction (board .getName ()) {
1349
1361
public void actionPerformed (ActionEvent actionevent ) {
1350
- selectBoard ((String ) getValue ("b" ));
1362
+ selectBoard ((TargetBoard ) getValue ("b" ));
1351
1363
}
1352
1364
};
1353
- action .putValue ("b" , packageName + ":" + platformName + ":" + boardId );
1365
+ action .putValue ("b" , board );
1354
1366
1355
1367
JRadioButtonMenuItem item = new JRadioButtonMenuItem (action );
1356
1368
@@ -1373,11 +1385,11 @@ public void actionPerformed(ActionEvent actionevent) {
1373
1385
@ SuppressWarnings ("serial" )
1374
1386
Action subAction = new AbstractAction (_ (boardCustomMenu .get (customMenuOption ))) {
1375
1387
public void actionPerformed (ActionEvent e ) {
1376
- Preferences .set ("custom_" + menuId , getValue ("board" ) + "_" + getValue ("custom_menu_option" ));
1388
+ Preferences .set ("custom_" + menuId , (( TargetBoard ) getValue ("board" )). getId ( ) + "_" + getValue ("custom_menu_option" ));
1377
1389
Sketch .buildSettingChanged ();
1378
1390
}
1379
1391
};
1380
- subAction .putValue ("board" , boardId );
1392
+ subAction .putValue ("board" , board );
1381
1393
subAction .putValue ("custom_menu_option" , customMenuOption );
1382
1394
1383
1395
if (!buttonGroupsMap .containsKey (menuId )) {
@@ -1399,12 +1411,12 @@ public void actionPerformed(ActionEvent e) {
1399
1411
return item ;
1400
1412
}
1401
1413
1402
- private static void filterVisibilityOfSubsequentBoardMenus (String boardID , int fromIndex ) {
1414
+ private static void filterVisibilityOfSubsequentBoardMenus (TargetBoard board , int fromIndex ) {
1403
1415
for (int i = fromIndex ; i < Editor .boardsMenus .size (); i ++) {
1404
1416
JMenu menu = Editor .boardsMenus .get (i );
1405
1417
for (int m = 0 ; m < menu .getItemCount (); m ++) {
1406
1418
JMenuItem menuItem = menu .getItem (m );
1407
- menuItem .setVisible (menuItem .getAction ().getValue ("board" ).equals (boardID ));
1419
+ menuItem .setVisible (menuItem .getAction ().getValue ("board" ).equals (board ));
1408
1420
}
1409
1421
menu .setVisible (ifThereAreVisibleItemsOn (menu ));
1410
1422
@@ -1477,22 +1489,15 @@ private static JMenuItem selectFirstEnabledMenuItem(JMenu menu) {
1477
1489
}
1478
1490
1479
1491
1480
- private void selectBoard (String selectBoard ) {
1481
- String [] split = selectBoard .split (":" );
1482
- Preferences .set ("target_package" , split [0 ]);
1483
- Preferences .set ("target_platform" , split [1 ]);
1484
- String boardId = split [2 ];
1485
- Preferences .set ("board" , boardId );
1492
+ private void selectBoard (TargetBoard targetBoard ) {
1493
+ TargetPlatform targetPlatform = targetBoard .getContainerPlatform ();
1494
+ TargetPackage targetPackage = targetPlatform .getContainerPackage ();
1486
1495
1487
- if (split .length > 3 ) {
1488
- String [] customsParts = split [3 ].split ("," );
1489
- for (String customParts : customsParts ) {
1490
- String [] keyValue = customParts .split ("=" );
1491
- Preferences .set ("custom_" + keyValue [0 ].trim (), boardId + "_" + keyValue [1 ].trim ());
1492
- }
1493
- }
1496
+ Preferences .set ("target_package" , targetPackage .getId ());
1497
+ Preferences .set ("target_platform" , targetPlatform .getId ());
1498
+ Preferences .set ("board" , targetBoard .getId ());
1494
1499
1495
- filterVisibilityOfSubsequentBoardMenus (boardId , 1 );
1500
+ filterVisibilityOfSubsequentBoardMenus (targetBoard , 1 );
1496
1501
1497
1502
onBoardOrPortChange ();
1498
1503
Sketch .buildSettingChanged ();
0 commit comments