3737import io .sloeber .core .Activator ;
3838import io .sloeber .core .Messages ;
3939import io .sloeber .core .api .ConfigurationPreferences ;
40- import io .sloeber .core .api .Const ;
4140import io .sloeber .core .api .VersionNumber ;
4241import io .sloeber .core .tools .KeyValue ;
4342import io .sloeber .core .txt .BoardTxtFile ;
@@ -66,14 +65,10 @@ public class BoardDescription {
6665 private IArduinoPlatformVersion myReferencedPlatformVariant = null ;
6766 private IArduinoPlatformVersion myReferencedPlatformCore = null ;
6867 private IArduinoPlatformVersion myReferencedPlatformUpload = null ;
69- private String myJsonFileName = null ;
7068 private String myJsonURL = null ;
7169
7270 private boolean myIsDirty = true ;
7371
74- public String jsonURL () {
75- return myJsonURL ;
76- }
7772
7873 @ Override
7974 public String toString () {
@@ -281,7 +276,7 @@ public static List<BoardDescription> makeBoardDescriptors(File boardFile) {
281276 Map <String , String > boardSection = txtFile .getSection (curboardID );
282277 if (boardSection != null ) {
283278 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 ));
285280 }
286281 }
287282 }
@@ -296,16 +291,21 @@ public static List<BoardDescription> makeBoardDescriptors(File boardFile) {
296291 * @param options
297292 * if null default options are taken
298293 */
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+
300296 File expandedBoardsFile = resolvePathEnvironmentString (boardsFile );
301297 if (!expandedBoardsFile .exists ()) {
302298 Activator .log (new Status (IStatus .ERROR , Activator .getId (), "BoardsFile " + boardsFile + " does not exist" )); //$NON-NLS-1$//$NON-NLS-2$
303299 return ;
304300 }
301+ if (jsonURL != null ) {
302+ myJsonURL = jsonURL ;
303+ } else {
304+ myJsonURL = BoardsManager .getjsonURLFormBoardsFile (expandedBoardsFile );
305+ }
305306 myBoardID = boardID ;
306307 myUserSelectedBoardsTxtFile = boardsFile ;
307308 mySloeberBoardTxtFile = new BoardTxtFile (expandedBoardsFile );
308- getJSonInfo ();
309309 setDefaultOptions ();
310310 if (options != null ) {
311311 myOptions .putAll (options );
@@ -316,13 +316,13 @@ public BoardDescription() {
316316 myUserSelectedBoardsTxtFile = new File (myStorageNode .get (KEY_LAST_USED_BOARDS_FILE , EMPTY ));
317317 if (!myUserSelectedBoardsTxtFile .exists ()) {
318318
319- IArduinoPlatformVersion platform = BoardsManager .getNewestInstalledPlatform (VENDOR_ARDUINO , AVR );
319+ IArduinoPlatformVersion platform = BoardsManager .getNewestInstalledPlatform ( VENDOR_ARDUINO , AVR );
320320 if (platform == null ) {
321321 platform = BoardsManager .getAnyInstalledPlatform ();
322322 }
323323 myUserSelectedBoardsTxtFile = platform .getBoardsFile ();
324324 mySloeberBoardTxtFile = new BoardTxtFile (myUserSelectedBoardsTxtFile );
325- getJSonInfo ( platform );
325+ myJsonURL = BoardsManager . getjsonURLFormBoardsFile ( myUserSelectedBoardsTxtFile );
326326
327327 if (mySloeberBoardTxtFile .getAllBoardIDs ().contains (UNO )) {
328328 myBoardID = UNO ;
@@ -335,38 +335,16 @@ public BoardDescription() {
335335 myBoardID = myStorageNode .get (KEY_LAST_USED_BOARD , EMPTY );
336336 myUploadPort = myStorageNode .get (KEY_LAST_USED_UPLOAD_PORT , EMPTY );
337337 myProgrammer = myStorageNode .get (KEY_LAST_USED_UPLOAD_PROTOCOL , EMPTY );
338- myJsonFileName = myStorageNode .get (KEY_LAST_USED_JSON_FILENAME , EMPTY );
339338 myJsonURL = myStorageNode .get (KEY_LAST_USED_JSON_URL , EMPTY );
340339 myOptions = KeyValue .makeMap (myStorageNode .get (KEY_LAST_USED_BOARD_MENU_OPTIONS , EMPTY ));
341340 }
342341
343342 }
344343
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- }
365344
366345 public BoardDescription (BoardDescription srcObject ) {
367346 myUserSelectedBoardsTxtFile = srcObject .myUserSelectedBoardsTxtFile ;
368347 mySloeberBoardTxtFile = srcObject .mySloeberBoardTxtFile ;
369- myJsonFileName = srcObject .myJsonFileName ;
370348 myJsonURL = srcObject .myJsonURL ;
371349 myBoardID = srcObject .myBoardID ;
372350 myUploadPort = srcObject .myUploadPort ;
@@ -424,7 +402,6 @@ public void saveUserSelection() {
424402 myStorageNode .put (KEY_LAST_USED_BOARD , myBoardID );
425403 myStorageNode .put (KEY_LAST_USED_UPLOAD_PORT , myUploadPort );
426404 myStorageNode .put (KEY_LAST_USED_UPLOAD_PROTOCOL , myProgrammer );
427- myStorageNode .put (KEY_LAST_USED_JSON_FILENAME , myJsonFileName );
428405 myStorageNode .put (KEY_LAST_USED_JSON_URL , myJsonURL );
429406 myStorageNode .put (KEY_LAST_USED_BOARD_MENU_OPTIONS , KeyValue .makeString (myOptions ));
430407 }
@@ -768,13 +745,6 @@ public boolean isNetworkUpload() {
768745 return getHost () != null ;
769746 }
770747
771- protected BoardDescription (File boardsFile , String boardID ) {
772- myBoardID = boardID ;
773- myUserSelectedBoardsTxtFile = boardsFile ;
774- mySloeberBoardTxtFile = new BoardTxtFile (myUserSelectedBoardsTxtFile );
775- calculateDerivedFields ();
776- getJSonInfo ();
777- }
778748
779749 BoardDescription (TxtFile configFile , String prefix ) {
780750
@@ -788,7 +758,6 @@ protected BoardDescription(File boardsFile, String boardID) {
788758 Map <String , String > options = optionsTree .toKeyValues (EMPTY );
789759
790760 KeyValueTree boardSection = tree .getChild (BOARD );
791- myJsonFileName = boardSection .getValue (JSON_NAME );
792761 myJsonURL = boardSection .getValue (JSON_URL );
793762
794763 myUserSelectedBoardsTxtFile = resolvePathEnvironmentString (new File (board_txt ));
@@ -814,7 +783,6 @@ public BoardDescription(KeyValueTree keyValues) {
814783 String txtFile = boardvalueTree .getValue (KEY_SLOEBER_BOARD_TXT );
815784
816785 KeyValueTree jSonvalueTree = keyValues .getChild (KEY_JSON );
817- myJsonFileName = jSonvalueTree .getValue (KEY_JSON_FILENAME );
818786 myJsonURL = jSonvalueTree .getValue (KEY_JSON_URL );
819787
820788 myUserSelectedBoardsTxtFile = resolvePathEnvironmentString (new File (txtFile ));
@@ -869,26 +837,12 @@ public void serialize(KeyValueTree keyValueTree) {
869837 boardvalueTree .addChild (KEY_SLOEBER_BOARD_TXT , board_txt );
870838
871839 KeyValueTree jSonvalueTree = keyValueTree .addChild (KEY_JSON );
872- jSonvalueTree .addChild (KEY_JSON_FILENAME , myJsonFileName );
873840 jSonvalueTree .addChild (KEY_JSON_URL , myJsonURL );
874841
875842 KeyValueTree menuvalueTree = keyValueTree .addChild (KEY_SLOEBER_MENU_SELECTION );
876843 for (Entry <String , String > curOption : myOptions .entrySet ()) {
877844 menuvalueTree .addValue (curOption .getKey (), curOption .getValue ());
878845 }
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;
892846 }
893847
894848 private Map <String , String > onlyKeepValidOptions (Map <String , String > options ) {
@@ -1065,7 +1019,7 @@ private Map<String, String> getEnVarPlatformInfo() throws IOException {
10651019 ret .putAll (getEnvVarPlatformFileTools (myReferencedPlatformCore ));
10661020
10671021 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 ,
10691023 getArchitecture ());
10701024 ret .putAll (getEnvVarPlatformFileTools (latestArduinoPlatform ));
10711025
0 commit comments