37
37
import io .sloeber .core .Activator ;
38
38
import io .sloeber .core .Messages ;
39
39
import io .sloeber .core .api .ConfigurationPreferences ;
40
- import io .sloeber .core .api .Const ;
41
40
import io .sloeber .core .api .VersionNumber ;
42
41
import io .sloeber .core .tools .KeyValue ;
43
42
import io .sloeber .core .txt .BoardTxtFile ;
@@ -66,14 +65,10 @@ public class BoardDescription {
66
65
private IArduinoPlatformVersion myReferencedPlatformVariant = null ;
67
66
private IArduinoPlatformVersion myReferencedPlatformCore = null ;
68
67
private IArduinoPlatformVersion myReferencedPlatformUpload = null ;
69
- private String myJsonFileName = null ;
70
68
private String myJsonURL = null ;
71
69
72
70
private boolean myIsDirty = true ;
73
71
74
- public String jsonURL () {
75
- return myJsonURL ;
76
- }
77
72
78
73
@ Override
79
74
public String toString () {
@@ -281,7 +276,7 @@ public static List<BoardDescription> makeBoardDescriptors(File boardFile) {
281
276
Map <String , String > boardSection = txtFile .getSection (curboardID );
282
277
if (boardSection != null ) {
283
278
if (!"true" .equalsIgnoreCase (boardSection .get ("hide" ))) { //$NON-NLS-1$ //$NON-NLS-2$
284
- boards .add (new BoardDescription (boardFile , curboardID , null ));
279
+ boards .add (new BoardDescription (null , boardFile , curboardID , null ));
285
280
}
286
281
}
287
282
}
@@ -296,16 +291,21 @@ public static List<BoardDescription> makeBoardDescriptors(File boardFile) {
296
291
* @param options
297
292
* if null default options are taken
298
293
*/
299
- public BoardDescription (File boardsFile , String boardID , Map <String , String > options ) {
294
+ public BoardDescription (String jsonURL ,File boardsFile , String boardID , Map <String , String > options ) {
295
+
300
296
File expandedBoardsFile = resolvePathEnvironmentString (boardsFile );
301
297
if (!expandedBoardsFile .exists ()) {
302
298
Activator .log (new Status (IStatus .ERROR , Activator .getId (), "BoardsFile " + boardsFile + " does not exist" )); //$NON-NLS-1$//$NON-NLS-2$
303
299
return ;
304
300
}
301
+ if (jsonURL != null ) {
302
+ myJsonURL = jsonURL ;
303
+ } else {
304
+ myJsonURL = BoardsManager .getjsonURLFormBoardsFile (expandedBoardsFile );
305
+ }
305
306
myBoardID = boardID ;
306
307
myUserSelectedBoardsTxtFile = boardsFile ;
307
308
mySloeberBoardTxtFile = new BoardTxtFile (expandedBoardsFile );
308
- getJSonInfo ();
309
309
setDefaultOptions ();
310
310
if (options != null ) {
311
311
myOptions .putAll (options );
@@ -316,13 +316,13 @@ public BoardDescription() {
316
316
myUserSelectedBoardsTxtFile = new File (myStorageNode .get (KEY_LAST_USED_BOARDS_FILE , EMPTY ));
317
317
if (!myUserSelectedBoardsTxtFile .exists ()) {
318
318
319
- IArduinoPlatformVersion platform = BoardsManager .getNewestInstalledPlatform (VENDOR_ARDUINO , AVR );
319
+ IArduinoPlatformVersion platform = BoardsManager .getNewestInstalledPlatform ( VENDOR_ARDUINO , AVR );
320
320
if (platform == null ) {
321
321
platform = BoardsManager .getAnyInstalledPlatform ();
322
322
}
323
323
myUserSelectedBoardsTxtFile = platform .getBoardsFile ();
324
324
mySloeberBoardTxtFile = new BoardTxtFile (myUserSelectedBoardsTxtFile );
325
- getJSonInfo ( platform );
325
+ myJsonURL = BoardsManager . getjsonURLFormBoardsFile ( myUserSelectedBoardsTxtFile );
326
326
327
327
if (mySloeberBoardTxtFile .getAllBoardIDs ().contains (UNO )) {
328
328
myBoardID = UNO ;
@@ -335,38 +335,16 @@ public BoardDescription() {
335
335
myBoardID = myStorageNode .get (KEY_LAST_USED_BOARD , EMPTY );
336
336
myUploadPort = myStorageNode .get (KEY_LAST_USED_UPLOAD_PORT , EMPTY );
337
337
myProgrammer = myStorageNode .get (KEY_LAST_USED_UPLOAD_PROTOCOL , EMPTY );
338
- myJsonFileName = myStorageNode .get (KEY_LAST_USED_JSON_FILENAME , EMPTY );
339
338
myJsonURL = myStorageNode .get (KEY_LAST_USED_JSON_URL , EMPTY );
340
339
myOptions = KeyValue .makeMap (myStorageNode .get (KEY_LAST_USED_BOARD_MENU_OPTIONS , EMPTY ));
341
340
}
342
341
343
342
}
344
343
345
- private void getJSonInfo (IArduinoPlatformVersion platform ) {
346
- IArduinoPlatformPackageIndex packageIndex = platform .getParent ().getParent ().getPackageIndex ();
347
- myJsonFileName = packageIndex .getJsonFile ().getName ();
348
- myJsonURL = packageIndex .getJsonURL ();
349
- }
350
-
351
- private void getJSonInfo () {
352
- IArduinoPlatformVersion platform = BoardsManager .getNewestInstalledPlatform (getVendor (), getArchitecture ());
353
- if (platform == null ) {
354
- platform = BoardsManager .getNewestInstalledPlatform (VENDOR_ARDUINO , AVR );
355
- }
356
- if (platform == null ) {
357
- platform = BoardsManager .getAnyInstalledPlatform ();
358
- }
359
- if (platform != null ) {
360
- myUserSelectedBoardsTxtFile = platform .getBoardsFile ();
361
- mySloeberBoardTxtFile = new BoardTxtFile (myUserSelectedBoardsTxtFile );
362
- getJSonInfo (platform );
363
- }
364
- }
365
344
366
345
public BoardDescription (BoardDescription srcObject ) {
367
346
myUserSelectedBoardsTxtFile = srcObject .myUserSelectedBoardsTxtFile ;
368
347
mySloeberBoardTxtFile = srcObject .mySloeberBoardTxtFile ;
369
- myJsonFileName = srcObject .myJsonFileName ;
370
348
myJsonURL = srcObject .myJsonURL ;
371
349
myBoardID = srcObject .myBoardID ;
372
350
myUploadPort = srcObject .myUploadPort ;
@@ -424,7 +402,6 @@ public void saveUserSelection() {
424
402
myStorageNode .put (KEY_LAST_USED_BOARD , myBoardID );
425
403
myStorageNode .put (KEY_LAST_USED_UPLOAD_PORT , myUploadPort );
426
404
myStorageNode .put (KEY_LAST_USED_UPLOAD_PROTOCOL , myProgrammer );
427
- myStorageNode .put (KEY_LAST_USED_JSON_FILENAME , myJsonFileName );
428
405
myStorageNode .put (KEY_LAST_USED_JSON_URL , myJsonURL );
429
406
myStorageNode .put (KEY_LAST_USED_BOARD_MENU_OPTIONS , KeyValue .makeString (myOptions ));
430
407
}
@@ -768,13 +745,6 @@ public boolean isNetworkUpload() {
768
745
return getHost () != null ;
769
746
}
770
747
771
- protected BoardDescription (File boardsFile , String boardID ) {
772
- myBoardID = boardID ;
773
- myUserSelectedBoardsTxtFile = boardsFile ;
774
- mySloeberBoardTxtFile = new BoardTxtFile (myUserSelectedBoardsTxtFile );
775
- calculateDerivedFields ();
776
- getJSonInfo ();
777
- }
778
748
779
749
BoardDescription (TxtFile configFile , String prefix ) {
780
750
@@ -788,7 +758,6 @@ protected BoardDescription(File boardsFile, String boardID) {
788
758
Map <String , String > options = optionsTree .toKeyValues (EMPTY );
789
759
790
760
KeyValueTree boardSection = tree .getChild (BOARD );
791
- myJsonFileName = boardSection .getValue (JSON_NAME );
792
761
myJsonURL = boardSection .getValue (JSON_URL );
793
762
794
763
myUserSelectedBoardsTxtFile = resolvePathEnvironmentString (new File (board_txt ));
@@ -814,7 +783,6 @@ public BoardDescription(KeyValueTree keyValues) {
814
783
String txtFile = boardvalueTree .getValue (KEY_SLOEBER_BOARD_TXT );
815
784
816
785
KeyValueTree jSonvalueTree = keyValues .getChild (KEY_JSON );
817
- myJsonFileName = jSonvalueTree .getValue (KEY_JSON_FILENAME );
818
786
myJsonURL = jSonvalueTree .getValue (KEY_JSON_URL );
819
787
820
788
myUserSelectedBoardsTxtFile = resolvePathEnvironmentString (new File (txtFile ));
@@ -869,26 +837,12 @@ public void serialize(KeyValueTree keyValueTree) {
869
837
boardvalueTree .addChild (KEY_SLOEBER_BOARD_TXT , board_txt );
870
838
871
839
KeyValueTree jSonvalueTree = keyValueTree .addChild (KEY_JSON );
872
- jSonvalueTree .addChild (KEY_JSON_FILENAME , myJsonFileName );
873
840
jSonvalueTree .addChild (KEY_JSON_URL , myJsonURL );
874
841
875
842
KeyValueTree menuvalueTree = keyValueTree .addChild (KEY_SLOEBER_MENU_SELECTION );
876
843
for (Entry <String , String > curOption : myOptions .entrySet ()) {
877
844
menuvalueTree .addValue (curOption .getKey (), curOption .getValue ());
878
845
}
879
-
880
- // allVars.put(KEY_SLOEBER_PROGRAMMER, myProgrammer);
881
- // allVars.put(KEY_SLOEBER_BOARD_ID, myBoardID);
882
- // allVars.put(KEY_SLOEBER_BOARD_TXT, board_txt);
883
- // allVars.put(KEY_SLOEBER_UPLOAD_PORT, myUploadPort);
884
- //
885
- // allVars.put(KEY_JSON_FILENAME, myJsonFileName);
886
- // allVars.put(KEY_JSON_URL, myJsonURL);
887
- //
888
- // for (Entry<String, String> curOption : myOptions.entrySet()) {
889
- // allVars.put(KEY_SLOEBER_MENU_SELECTION + DOT + curOption.getKey(), curOption.getValue());
890
- // }
891
- // return allVars;
892
846
}
893
847
894
848
private Map <String , String > onlyKeepValidOptions (Map <String , String > options ) {
@@ -1065,7 +1019,7 @@ private Map<String, String> getEnVarPlatformInfo() throws IOException {
1065
1019
ret .putAll (getEnvVarPlatformFileTools (myReferencedPlatformCore ));
1066
1020
1067
1021
BoardsManager .update (false );// This way we know the boardsmanager is started or we wait for the lock
1068
- IArduinoPlatformVersion latestArduinoPlatform = BoardsManager .getNewestInstalledPlatform (Const . VENDOR_ARDUINO ,
1022
+ IArduinoPlatformVersion latestArduinoPlatform = BoardsManager .getNewestInstalledPlatform (VENDOR_ARDUINO ,
1069
1023
getArchitecture ());
1070
1024
ret .putAll (getEnvVarPlatformFileTools (latestArduinoPlatform ));
1071
1025
0 commit comments