@@ -116,6 +116,8 @@ public class Base {
116
116
List <Editor > editors = Collections .synchronizedList (new ArrayList <Editor >());
117
117
Editor activeEditor ;
118
118
119
+ private static JMenu boardMenu ;
120
+
119
121
// these menus are shared so that the board and serial port selections
120
122
// are the same for all windows (since the board and serial port that are
121
123
// actually used are determined by the preferences, which are shared)
@@ -1337,6 +1339,29 @@ public void rebuildExamplesMenu(JMenu menu) {
1337
1339
private static String priorPlatformFolder ;
1338
1340
private static boolean newLibraryImported ;
1339
1341
1342
+ public void selectTargetBoard (TargetBoard targetBoard ) {
1343
+ for (int i = 0 ; i < boardMenu .getItemCount (); i ++) {
1344
+ JMenuItem menuItem = boardMenu .getItem (i );
1345
+ if (!(menuItem instanceof JRadioButtonMenuItem )) {
1346
+ continue ;
1347
+ }
1348
+
1349
+ JRadioButtonMenuItem radioButtonMenuItem = ((JRadioButtonMenuItem ) menuItem );
1350
+ if (targetBoard .getName ().equals (radioButtonMenuItem .getText ())) {
1351
+ radioButtonMenuItem .setSelected (true );
1352
+ break ;
1353
+ }
1354
+ }
1355
+
1356
+ BaseNoGui .selectBoard (targetBoard );
1357
+ filterVisibilityOfSubsequentBoardMenus (boardsCustomMenus , targetBoard , 1 );
1358
+
1359
+ onBoardOrPortChange ();
1360
+ rebuildImportMenu (Editor .importMenu );
1361
+ rebuildExamplesMenu (Editor .examplesMenu );
1362
+ rebuildProgrammerMenu ();
1363
+ }
1364
+
1340
1365
public void onBoardOrPortChange () {
1341
1366
BaseNoGui .onBoardOrPortChange ();
1342
1367
@@ -1430,7 +1455,7 @@ public void rebuildBoardsMenu() throws Exception {
1430
1455
boardsCustomMenus = new LinkedList <>();
1431
1456
1432
1457
// The first custom menu is the "Board" selection submenu
1433
- JMenu boardMenu = new JMenu (tr ("Board" ));
1458
+ boardMenu = new JMenu (tr ("Board" ));
1434
1459
boardMenu .putClientProperty ("removeOnWindowDeactivation" , true );
1435
1460
MenuScroller .setScrollerFor (boardMenu ).setTopFixedCount (1 );
1436
1461
@@ -1539,13 +1564,7 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
1539
1564
@ SuppressWarnings ("serial" )
1540
1565
Action action = new AbstractAction (board .getName ()) {
1541
1566
public void actionPerformed (ActionEvent actionevent ) {
1542
- BaseNoGui .selectBoard ((TargetBoard ) getValue ("b" ));
1543
- filterVisibilityOfSubsequentBoardMenus (boardsCustomMenus , (TargetBoard ) getValue ("b" ), 1 );
1544
-
1545
- onBoardOrPortChange ();
1546
- rebuildImportMenu (Editor .importMenu );
1547
- rebuildExamplesMenu (Editor .examplesMenu );
1548
- rebuildProgrammerMenu ();
1567
+ selectTargetBoard ((TargetBoard ) getValue ("b" ));
1549
1568
}
1550
1569
};
1551
1570
action .putValue ("b" , board );
0 commit comments