@@ -66,7 +66,8 @@ public class BoardDescription {
66
66
private String myProgrammer = EMPTY ;
67
67
private String myBoardID = EMPTY ;
68
68
private Map <String , String > myOptions = new TreeMap <>(String .CASE_INSENSITIVE_ORDER );
69
- private BoardTxtFile myBoardTxtFile ;
69
+ private File myUserSelectedBoardsTxtFile ; //this is the boards.txt file selected in the gui
70
+ private BoardTxtFile mySloeberBoardTxtFile ; // this is the actual used and loaded sloeber.boards.txt file
70
71
71
72
private String myBoardsCore = null ;
72
73
private String myBoardsVariant = null ;
@@ -149,7 +150,7 @@ private void calculateDerivedFields() {
149
150
}
150
151
151
152
private void ParseSection () {
152
- KeyValueTree rootData = myBoardTxtFile .getData ();
153
+ KeyValueTree rootData = mySloeberBoardTxtFile .getData ();
153
154
String boardID = getBoardID ();
154
155
KeyValueTree boardData = rootData .getChild (boardID );
155
156
@@ -301,23 +302,25 @@ public static List<BoardDescription> makeBoardDescriptors(File boardFile) {
301
302
*/
302
303
BoardDescription (File boardsFile , String boardID , Map <String , String > options ) {
303
304
myBoardID = boardID ;
304
- myBoardTxtFile = new BoardTxtFile (resolvePathEnvironmentString (boardsFile ));
305
+ myUserSelectedBoardsTxtFile = boardsFile ;
306
+ mySloeberBoardTxtFile = new BoardTxtFile (resolvePathEnvironmentString (myUserSelectedBoardsTxtFile ));
305
307
setDefaultOptions ();
306
308
if (options != null ) {
307
309
myOptions .putAll (options );
308
310
}
309
311
}
310
312
311
313
public BoardDescription () {
312
- File boardsFile = new File (myStorageNode .get (KEY_LAST_USED_BOARDS_FILE , EMPTY ));
313
- if (!boardsFile .exists ()) {
314
+ myUserSelectedBoardsTxtFile = new File (myStorageNode .get (KEY_LAST_USED_BOARDS_FILE , EMPTY ));
315
+ if (!myUserSelectedBoardsTxtFile .exists ()) {
314
316
List <ArduinoPlatformVersion > platforms = BoardsManager .getInstalledPlatforms ();
315
317
//If you crash on the next line no platform have been installed
316
318
ArduinoPlatformVersion platform = platforms .get (0 );
317
- myBoardTxtFile = new BoardTxtFile (platform .getBoardsFile ());
318
- myBoardID = myBoardTxtFile .getAllBoardIDs ().get (0 );
319
+ myUserSelectedBoardsTxtFile = platform .getBoardsFile ();
320
+ mySloeberBoardTxtFile = new BoardTxtFile (myUserSelectedBoardsTxtFile );
321
+ myBoardID = mySloeberBoardTxtFile .getAllBoardIDs ().get (0 );
319
322
} else {
320
- myBoardTxtFile = new BoardTxtFile (boardsFile );
323
+ mySloeberBoardTxtFile = new BoardTxtFile (myUserSelectedBoardsTxtFile );
321
324
myBoardID = myStorageNode .get (KEY_LAST_USED_BOARD , EMPTY );
322
325
myUploadPort = myStorageNode .get (KEY_LAST_USED_UPLOAD_PORT , EMPTY );
323
326
myProgrammer = myStorageNode .get (KEY_LAST_USED_UPLOAD_PROTOCOL , EMPTY );
@@ -326,7 +329,8 @@ public BoardDescription() {
326
329
}
327
330
328
331
public BoardDescription (BoardDescription srcObject ) {
329
- myBoardTxtFile = srcObject .myBoardTxtFile ;
332
+ myUserSelectedBoardsTxtFile = srcObject .myUserSelectedBoardsTxtFile ;
333
+ mySloeberBoardTxtFile = srcObject .mySloeberBoardTxtFile ;
330
334
myBoardID = srcObject .myBoardID ;
331
335
myUploadPort = srcObject .myUploadPort ;
332
336
myProgrammer = srcObject .myProgrammer ;
@@ -345,10 +349,10 @@ public String getuploadTool() {
345
349
* incomplete or invalid this method still returns a complete and valid set.
346
350
*/
347
351
private void setDefaultOptions () {
348
- Map <String , String > allMenuIDs = this .myBoardTxtFile .getMenus ();
352
+ Map <String , String > allMenuIDs = this .mySloeberBoardTxtFile .getMenus ();
349
353
for (Map .Entry <String , String > curMenuID : allMenuIDs .entrySet ()) {
350
354
String providedMenuValue = this .myOptions .get (curMenuID .getKey ());
351
- ArrayList <String > menuOptions = this .myBoardTxtFile .getMenuItemIDsFromMenuID (curMenuID .getKey (),
355
+ ArrayList <String > menuOptions = this .mySloeberBoardTxtFile .getMenuItemIDsFromMenuID (curMenuID .getKey (),
352
356
getBoardID ());
353
357
if (menuOptions .size () > 0 ) {
354
358
if (providedMenuValue == null ) {
@@ -374,15 +378,15 @@ public void saveUserSelection() {
374
378
}
375
379
376
380
public String getArchitecture () {
377
- return myBoardTxtFile .getArchitecture ();
381
+ return mySloeberBoardTxtFile .getArchitecture ();
378
382
}
379
383
380
384
public File getReferencingBoardsFile () {
381
- return myBoardTxtFile . getLoadedFile () ;
385
+ return myUserSelectedBoardsTxtFile ;
382
386
}
383
387
384
388
public String getBoardName () {
385
- return this .myBoardTxtFile .getNiceNameFromID (this .myBoardID );
389
+ return this .mySloeberBoardTxtFile .getNiceNameFromID (this .myBoardID );
386
390
}
387
391
388
392
public String getUploadPort () {
@@ -431,7 +435,7 @@ private void setDirty() {
431
435
}
432
436
433
437
public void setBoardName (String boardName ) {
434
- String newBoardID = this .myBoardTxtFile .getIDFromNiceName (boardName );
438
+ String newBoardID = this .mySloeberBoardTxtFile .getIDFromNiceName (boardName );
435
439
if ((newBoardID == null || this .myBoardID .equals (newBoardID ))) {
436
440
return ;
437
441
}
@@ -444,14 +448,15 @@ public void setreferencingBoardsFile(File boardsFile) {
444
448
if (boardsFile == null ) {
445
449
return ;// ignore
446
450
}
447
- /*
448
- * do not do this optimization as workaround changes will not be captured if
449
- * (this.myreferencingBoardsFile.equals(resolvePathEnvironmentString(boardsFile)
450
- * )) { return; }
451
- */
452
451
453
- myBoardTxtFile = new BoardTxtFile (resolvePathEnvironmentString (boardsFile ));
454
- setDirty ();
452
+ if (!myUserSelectedBoardsTxtFile .equals (boardsFile )) {
453
+ myUserSelectedBoardsTxtFile = boardsFile ;
454
+ setDirty ();
455
+ }
456
+
457
+ /* do not remove this for optimization as workaround changes will not be captured */
458
+ mySloeberBoardTxtFile = new BoardTxtFile (resolvePathEnvironmentString (myUserSelectedBoardsTxtFile ));
459
+
455
460
}
456
461
457
462
public void setOptions (Map <String , String > options ) {
@@ -486,7 +491,7 @@ public String getBoardID() {
486
491
}
487
492
488
493
public String [] getCompatibleBoards () {
489
- return this .myBoardTxtFile .getAllSectionNames ();
494
+ return this .mySloeberBoardTxtFile .getAllSectionNames ();
490
495
}
491
496
492
497
public String [] getUploadProtocols () {
@@ -496,7 +501,7 @@ public String[] getUploadProtocols() {
496
501
}
497
502
498
503
public String [] getMenuItemNamesFromMenuID (String menuID ) {
499
- return this .myBoardTxtFile .getMenuItemNamesFromMenuID (menuID , this .myBoardID );
504
+ return this .mySloeberBoardTxtFile .getMenuItemNamesFromMenuID (menuID , this .myBoardID );
500
505
}
501
506
502
507
public TreeMap <String , IPath > getAllExamples () {
@@ -505,15 +510,15 @@ public TreeMap<String, IPath> getAllExamples() {
505
510
}
506
511
507
512
public String getMenuNameFromMenuID (String id ) {
508
- return this .myBoardTxtFile .getMenuNameFromID (id );
513
+ return this .mySloeberBoardTxtFile .getMenuNameFromID (id );
509
514
}
510
515
511
516
public String getMenuItemNamedFromMenuItemID (String menuItemID , String menuID ) {
512
- return this .myBoardTxtFile .getMenuItemNameFromMenuItemID (this .myBoardID , menuID , menuItemID );
517
+ return this .mySloeberBoardTxtFile .getMenuItemNameFromMenuItemID (this .myBoardID , menuID , menuItemID );
513
518
}
514
519
515
520
public String getMenuItemIDFromMenuItemName (String menuItemName , String menuID ) {
516
- return this .myBoardTxtFile .getMenuItemIDFromMenuItemName (this .myBoardID , menuID , menuItemName );
521
+ return this .mySloeberBoardTxtFile .getMenuItemIDFromMenuItemName (this .myBoardID , menuID , menuItemName );
517
522
}
518
523
519
524
/**
@@ -529,7 +534,7 @@ public IPath getActualVariantPath() {
529
534
return null ;
530
535
}
531
536
if (myReferencedPlatformVariant == null ) {
532
- return new Path (myBoardTxtFile . getLoadedFile () .getParent ().toString ()).append (VARIANTS_FOLDER_NAME )
537
+ return new Path (myUserSelectedBoardsTxtFile .getParent ().toString ()).append (VARIANTS_FOLDER_NAME )
533
538
.append (boardVariant );
534
539
}
535
540
return myReferencedPlatformVariant .getInstallPath ().append (VARIANTS_FOLDER_NAME ).append (boardVariant );
@@ -573,7 +578,7 @@ public PlatformTxtFile getReferencingPlatformFile() {
573
578
574
579
public Path getreferencingPlatformPath () {
575
580
try {
576
- return new Path (myBoardTxtFile . getLoadedFile () .getParent ());
581
+ return new Path (myUserSelectedBoardsTxtFile .getParent ());
577
582
} catch (@ SuppressWarnings ("unused" ) Exception e ) {
578
583
return new Path (EMPTY );
579
584
}
@@ -617,7 +622,7 @@ public String getUploadPatternKey() {
617
622
public IPath getreferencedCoreHardwarePath () {
618
623
updateWhenDirty ();
619
624
if (myReferencedPlatformCore == null ) {
620
- return new Path ( myBoardTxtFile . getLoadedFile (). toString ()). removeLastSegments ( 1 );
625
+ return getreferencingPlatformPath ( );
621
626
}
622
627
return myReferencedPlatformCore .getInstallPath ();
623
628
}
@@ -663,9 +668,10 @@ public boolean isNetworkUpload() {
663
668
return getHost () != null ;
664
669
}
665
670
666
- protected BoardDescription (File txtFile , String boardID ) {
671
+ protected BoardDescription (File boardsFile , String boardID ) {
667
672
myBoardID = boardID ;
668
- myBoardTxtFile = new BoardTxtFile (txtFile );
673
+ myUserSelectedBoardsTxtFile = boardsFile ;
674
+ mySloeberBoardTxtFile = new BoardTxtFile (myUserSelectedBoardsTxtFile );
669
675
setDefaultOptions ();
670
676
calculateDerivedFields ();
671
677
}
@@ -681,8 +687,8 @@ protected BoardDescription(File txtFile, String boardID) {
681
687
KeyValueTree optionsTree = section .getChild (KEY_SLOEBER_MENU_SELECTION );
682
688
Map <String , String > options = optionsTree .toKeyValues (EMPTY , false );
683
689
684
- File ResolvedFile = resolvePathEnvironmentString (new File (board_txt ));
685
- myBoardTxtFile = new BoardTxtFile (ResolvedFile );
690
+ myUserSelectedBoardsTxtFile = resolvePathEnvironmentString (new File (board_txt ));
691
+ mySloeberBoardTxtFile = new BoardTxtFile (myUserSelectedBoardsTxtFile );
686
692
setDefaultOptions ();
687
693
if (options != null ) {
688
694
// Only add the valid options for this board to our options
@@ -693,7 +699,7 @@ protected BoardDescription(File txtFile, String boardID) {
693
699
private Map <String , String > onlyKeepValidOptions (Map <String , String > options ) {
694
700
Map <String , String > ret = new HashMap <>();
695
701
696
- KeyValueTree tree = myBoardTxtFile .getData ();
702
+ KeyValueTree tree = mySloeberBoardTxtFile .getData ();
697
703
KeyValueTree boardMenuSection = tree .getChild (myBoardID + DOT + MENU );
698
704
if (boardMenuSection != null ) {
699
705
for (Entry <String , String > curoption : options .entrySet ()) {
@@ -816,11 +822,11 @@ public Map<String, String> getEnvVars() {
816
822
allVars .putAll (getEnVarPlatformInfo ());
817
823
818
824
// boards settings not coming from menu selections
819
- allVars .putAll (myBoardTxtFile .getBoardEnvironVars (getBoardID ()));
825
+ allVars .putAll (mySloeberBoardTxtFile .getBoardEnvironVars (getBoardID ()));
820
826
821
827
// board settings from menu selections
822
828
Map <String , String > options = getOptions ();
823
- KeyValueTree rootData = myBoardTxtFile .getData ();
829
+ KeyValueTree rootData = mySloeberBoardTxtFile .getData ();
824
830
KeyValueTree menuData = rootData .getChild (getBoardID () + DOT + MENU );
825
831
for (Entry <String , String > curOption : options .entrySet ()) {
826
832
String menuID = curOption .getKey ();
@@ -1076,27 +1082,30 @@ public static BoardDescription getFromCDT(ICConfigurationDescription confDesc) {
1076
1082
if (packagesIndex != -1 ) {
1077
1083
referencingBoardsFile = sloeberHomePath .append (referencingBoardsFile .substring (packagesIndex )).toString ();
1078
1084
}
1079
- File resolvedFile = resolvePathEnvironmentString (new File (referencingBoardsFile ));
1080
- ret .myBoardTxtFile = new BoardTxtFile (resolvedFile );
1085
+ ret . myUserSelectedBoardsTxtFile = resolvePathEnvironmentString (new File (referencingBoardsFile ));
1086
+ ret .mySloeberBoardTxtFile = new BoardTxtFile (ret . myUserSelectedBoardsTxtFile );
1081
1087
1082
1088
return ret ;
1083
1089
}
1084
1090
1085
1091
public boolean isValid () {
1086
- File boardsFile = myBoardTxtFile .getLoadedFile ();
1092
+ if (!myUserSelectedBoardsTxtFile .exists ()) {
1093
+ return false ;
1094
+ }
1095
+ File boardsFile = mySloeberBoardTxtFile .getLoadedFile ();
1087
1096
if (boardsFile == null ) {
1088
1097
return false ;
1089
1098
}
1090
1099
return boardsFile .exists ();
1091
1100
}
1092
1101
1093
1102
public void reloadTxtFile () {
1094
- myBoardTxtFile .reloadTxtFile ();
1103
+ mySloeberBoardTxtFile .reloadTxtFile ();
1095
1104
1096
1105
}
1097
1106
1098
1107
public Map <String , String > getAllMenus () {
1099
- return myBoardTxtFile .getMenus ();
1108
+ return mySloeberBoardTxtFile .getMenus ();
1100
1109
}
1101
1110
1102
1111
public boolean isSSHUpload () {
0 commit comments