@@ -118,6 +118,7 @@ public boolean apply(UserLibrary library) {
118
118
// actually used are determined by the preferences, which are shared)
119
119
private List <JMenu > boardsCustomMenus ;
120
120
private volatile Action openBoardsManager ;
121
+ private List <JMenuItem > programmerMenus ;
121
122
122
123
private final PdeKeywords pdeKeywords ;
123
124
private final List <JMenuItem > recentSketchesMenuItems ;
@@ -299,6 +300,7 @@ public Base(String[] args) throws Exception {
299
300
BaseNoGui .initPackages ();
300
301
splashScreenHelper .splashText (_ ("Preparing boards..." ));
301
302
rebuildBoardsMenu ();
303
+ rebuildProgrammerMenu ();
302
304
303
305
// Setup board-dependent variables.
304
306
onBoardOrPortChange ();
@@ -1275,6 +1277,7 @@ private void openManageLibrariesDialog() {
1275
1277
protected void onIndexesUpdated () throws Exception {
1276
1278
BaseNoGui .initPackages ();
1277
1279
rebuildBoardsMenu ();
1280
+ rebuildProgrammerMenu ();
1278
1281
onBoardOrPortChange ();
1279
1282
setIndexer (BaseNoGui .librariesIndexer );
1280
1283
}
@@ -1298,6 +1301,7 @@ private void openInstallBoardDialog(final String filterText) throws Exception {
1298
1301
protected void onIndexesUpdated () throws Exception {
1299
1302
BaseNoGui .initPackages ();
1300
1303
rebuildBoardsMenu ();
1304
+ rebuildProgrammerMenu ();
1301
1305
setIndexer (BaseNoGui .indexer );
1302
1306
if (StringUtils .isNotEmpty (filterText )) {
1303
1307
setFilterText (filterText );
@@ -1313,6 +1317,7 @@ protected void onIndexesUpdated() throws Exception {
1313
1317
// Reload all boards (that may have been installed/updated/removed)
1314
1318
BaseNoGui .initPackages ();
1315
1319
rebuildBoardsMenu ();
1320
+ rebuildProgrammerMenu ();
1316
1321
onBoardOrPortChange ();
1317
1322
}
1318
1323
@@ -1515,6 +1520,10 @@ private JMenu getBoardCustomMenu(String label) throws Exception {
1515
1520
throw new Exception ("Custom menu not found!" );
1516
1521
}
1517
1522
1523
+ public List <JMenuItem > getProgrammerMenus () {
1524
+ return programmerMenus ;
1525
+ }
1526
+
1518
1527
private static JMenuItem selectVisibleSelectedOrFirstMenuItem (JMenu menu ) {
1519
1528
JMenuItem firstVisible = null ;
1520
1529
for (int i = 0 ; i < menu .getItemCount (); i ++) {
@@ -1546,27 +1555,28 @@ private static JMenuItem selectFirstEnabledMenuItem(JMenu menu) {
1546
1555
throw new IllegalStateException ("Menu has no enabled items" );
1547
1556
}
1548
1557
1549
- public void rebuildProgrammerMenu (JMenu menu ) {
1550
- menu .removeAll ();
1558
+ public void rebuildProgrammerMenu () {
1559
+ programmerMenus = new LinkedList <>();
1560
+
1551
1561
ButtonGroup group = new ButtonGroup ();
1552
1562
for (TargetPackage targetPackage : BaseNoGui .packages .values ()) {
1553
1563
for (TargetPlatform targetPlatform : targetPackage .platforms ()) {
1554
1564
for (String programmer : targetPlatform .getProgrammers ().keySet ()) {
1555
1565
String id = targetPackage .getId () + ":" + programmer ;
1556
1566
1557
1567
@ SuppressWarnings ("serial" )
1558
- AbstractAction action = new AbstractAction (targetPlatform
1559
- .getProgrammer (programmer ).get ("name" )) {
1568
+ AbstractAction action = new AbstractAction (targetPlatform .getProgrammer (programmer ).get ("name" )) {
1560
1569
public void actionPerformed (ActionEvent actionevent ) {
1561
1570
PreferencesData .set ("programmer" , "" + getValue ("id" ));
1562
1571
}
1563
1572
};
1564
1573
action .putValue ("id" , id );
1565
1574
JMenuItem item = new JRadioButtonMenuItem (action );
1566
- if (PreferencesData .get ("programmer" ).equals (id ))
1575
+ if (PreferencesData .get ("programmer" ).equals (id )) {
1567
1576
item .setSelected (true );
1577
+ }
1568
1578
group .add (item );
1569
- menu .add (item );
1579
+ programmerMenus .add (item );
1570
1580
}
1571
1581
}
1572
1582
}
0 commit comments