@@ -117,6 +117,8 @@ public class Base {
117
117
List <Editor > editors = Collections .synchronizedList (new ArrayList <Editor >());
118
118
Editor activeEditor ;
119
119
120
+ private static JMenu boardMenu ;
121
+
120
122
// these menus are shared so that the board and serial port selections
121
123
// are the same for all windows (since the board and serial port that are
122
124
// actually used are determined by the preferences, which are shared)
@@ -1313,6 +1315,28 @@ public void rebuildExamplesMenu(JMenu menu) {
1313
1315
private static String priorPlatformFolder ;
1314
1316
private static boolean newLibraryImported ;
1315
1317
1318
+ public void selectTargetBoard (TargetBoard targetBoard ) {
1319
+ for (int i = 0 ; i < boardMenu .getItemCount (); i ++) {
1320
+ JMenuItem menuItem = boardMenu .getItem (i );
1321
+ if (!(menuItem instanceof JRadioButtonMenuItem )) {
1322
+ continue ;
1323
+ }
1324
+
1325
+ JRadioButtonMenuItem radioButtonMenuItem = ((JRadioButtonMenuItem ) menuItem );
1326
+ if (targetBoard .getName ().equals (radioButtonMenuItem .getText ())) {
1327
+ radioButtonMenuItem .setSelected (true );
1328
+ break ;
1329
+ }
1330
+ }
1331
+
1332
+ BaseNoGui .selectBoard (targetBoard );
1333
+ filterVisibilityOfSubsequentBoardMenus (boardsCustomMenus , targetBoard , 1 );
1334
+
1335
+ onBoardOrPortChange ();
1336
+ rebuildImportMenu (Editor .importMenu );
1337
+ rebuildExamplesMenu (Editor .examplesMenu );
1338
+ }
1339
+
1316
1340
public void onBoardOrPortChange () {
1317
1341
BaseNoGui .onBoardOrPortChange ();
1318
1342
@@ -1406,7 +1430,7 @@ public void rebuildBoardsMenu() throws Exception {
1406
1430
boardsCustomMenus = new LinkedList <>();
1407
1431
1408
1432
// The first custom menu is the "Board" selection submenu
1409
- JMenu boardMenu = new JMenu (tr ("Board" ));
1433
+ boardMenu = new JMenu (tr ("Board" ));
1410
1434
boardMenu .putClientProperty ("removeOnWindowDeactivation" , true );
1411
1435
MenuScroller .setScrollerFor (boardMenu ).setTopFixedCount (1 );
1412
1436
@@ -1512,12 +1536,7 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
1512
1536
@ SuppressWarnings ("serial" )
1513
1537
Action action = new AbstractAction (board .getName ()) {
1514
1538
public void actionPerformed (ActionEvent actionevent ) {
1515
- BaseNoGui .selectBoard ((TargetBoard ) getValue ("b" ));
1516
- filterVisibilityOfSubsequentBoardMenus (boardsCustomMenus , (TargetBoard ) getValue ("b" ), 1 );
1517
-
1518
- onBoardOrPortChange ();
1519
- rebuildImportMenu (Editor .importMenu );
1520
- rebuildExamplesMenu (Editor .examplesMenu );
1539
+ selectTargetBoard ((TargetBoard ) getValue ("b" ));
1521
1540
}
1522
1541
};
1523
1542
action .putValue ("b" , board );
0 commit comments