@@ -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)
@@ -1342,6 +1344,29 @@ public void rebuildExamplesMenu(JMenu menu) {
1342
1344
private static String priorPlatformFolder ;
1343
1345
private static boolean newLibraryImported ;
1344
1346
1347
+ public void selectTargetBoard (TargetBoard targetBoard ) {
1348
+ for (int i = 0 ; i < boardMenu .getItemCount (); i ++) {
1349
+ JMenuItem menuItem = boardMenu .getItem (i );
1350
+ if (!(menuItem instanceof JRadioButtonMenuItem )) {
1351
+ continue ;
1352
+ }
1353
+
1354
+ JRadioButtonMenuItem radioButtonMenuItem = ((JRadioButtonMenuItem ) menuItem );
1355
+ if (targetBoard .getName ().equals (radioButtonMenuItem .getText ())) {
1356
+ radioButtonMenuItem .setSelected (true );
1357
+ break ;
1358
+ }
1359
+ }
1360
+
1361
+ BaseNoGui .selectBoard (targetBoard );
1362
+ filterVisibilityOfSubsequentBoardMenus (boardsCustomMenus , targetBoard , 1 );
1363
+
1364
+ onBoardOrPortChange ();
1365
+ rebuildImportMenu (Editor .importMenu );
1366
+ rebuildExamplesMenu (Editor .examplesMenu );
1367
+ rebuildProgrammerMenu ();
1368
+ }
1369
+
1345
1370
public void onBoardOrPortChange () {
1346
1371
BaseNoGui .onBoardOrPortChange ();
1347
1372
@@ -1435,7 +1460,7 @@ public void rebuildBoardsMenu() throws Exception {
1435
1460
boardsCustomMenus = new LinkedList <>();
1436
1461
1437
1462
// The first custom menu is the "Board" selection submenu
1438
- JMenu boardMenu = new JMenu (tr ("Board" ));
1463
+ boardMenu = new JMenu (tr ("Board" ));
1439
1464
boardMenu .putClientProperty ("removeOnWindowDeactivation" , true );
1440
1465
MenuScroller .setScrollerFor (boardMenu ).setTopFixedCount (1 );
1441
1466
@@ -1568,13 +1593,7 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
1568
1593
@ SuppressWarnings ("serial" )
1569
1594
Action action = new AbstractAction (board .getName ()) {
1570
1595
public void actionPerformed (ActionEvent actionevent ) {
1571
- BaseNoGui .selectBoard ((TargetBoard ) getValue ("b" ));
1572
- filterVisibilityOfSubsequentBoardMenus (boardsCustomMenus , (TargetBoard ) getValue ("b" ), 1 );
1573
-
1574
- onBoardOrPortChange ();
1575
- rebuildImportMenu (Editor .importMenu );
1576
- rebuildExamplesMenu (Editor .examplesMenu );
1577
- rebuildProgrammerMenu ();
1596
+ selectTargetBoard ((TargetBoard ) getValue ("b" ));
1578
1597
}
1579
1598
};
1580
1599
action .putValue ("b" , board );
0 commit comments