1
1
package io .sloeber .core .api ;
2
2
3
+ import static io .sloeber .core .Messages .*;
3
4
import static java .nio .file .StandardCopyOption .*;
4
5
5
6
import java .io .File ;
35
36
import com .google .gson .Gson ;
36
37
37
38
import io .sloeber .core .Activator ;
38
- import io .sloeber .core .Messages ;
39
39
import io .sloeber .core .api .PackageManager .PlatformTree .IndexFile ;
40
40
import io .sloeber .core .api .PackageManager .PlatformTree .InstallableVersion ;
41
41
import io .sloeber .core .api .PackageManager .PlatformTree .Platform ;
59
59
*/
60
60
public class PackageManager {
61
61
62
- private static final String FILE = Messages .FILE ;
63
- private static final String FOLDER = Messages .FOLDER ;
62
+ public static final String LOCAL = "local" ; //$NON-NLS-1$
64
63
protected static List <PackageIndex > packageIndices ;
65
64
private static boolean myHasbeenLogged = false ;
66
65
private static boolean platformsDirty = true ;// reset global variables at startup
67
66
private final static int MAX_HTTP_REDIRECTIONS = 5 ;
68
67
private static HashMap <String , String > myWorkbenchEnvironmentVariables = new HashMap <>();
69
68
70
69
/**
71
- * Gets the board descriptor based on the information provided. If
70
+ * Gets the board description based on the information provided. If
72
71
* jsonFileName="local" the board is assumed not to be installed by the boards
73
72
* manager. Otherwise the boardsmanager is queried to find the board descriptor.
74
73
* In this case the latest installed board will be returned
@@ -91,9 +90,9 @@ public class PackageManager {
91
90
* file) or null for defaults
92
91
* @return The class BoardDescriptor or null
93
92
*/
94
- static public BoardDescription getBoardDescriptor (String jsonFileName , String packageName , String architectureName ,
93
+ static public BoardDescription getBoardDescription (String jsonFileName , String packageName , String architectureName ,
95
94
String boardID , Map <String , String > options ) {
96
- if (jsonFileName .equals ("local" )) { //$NON-NLS-1$
95
+ if (LOCAL .equals (jsonFileName )) {
97
96
return new BoardDescription (new File (packageName ), boardID , options );
98
97
}
99
98
return getNewestBoardIDFromBoardsManager (jsonFileName , packageName , architectureName , boardID , options );
@@ -129,7 +128,7 @@ public static void addPackageURLs(HashSet<String> packageUrlsToAdd, boolean forc
129
128
130
129
public static void setPackageURLs (HashSet <String > packageUrls , boolean forceDownload ) {
131
130
if (!isReady ()) {
132
- Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , Messages . BoardsManagerIsBussy , new Exception ()));
131
+ Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , BoardsManagerIsBussy , new Exception ()));
133
132
return ;
134
133
}
135
134
ConfigurationPreferences .setJsonURLs (packageUrls );
@@ -138,7 +137,7 @@ public static void setPackageURLs(HashSet<String> packageUrls, boolean forceDown
138
137
139
138
public static void removePackageURLs (Set <String > packageUrlsToRemove ) {
140
139
if (!isReady ()) {
141
- Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , Messages . BoardsManagerIsBussy , new Exception ()));
140
+ Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , BoardsManagerIsBussy , new Exception ()));
142
141
return ;
143
142
}
144
143
InternalPackageManager .removePackageURLs (packageUrlsToRemove );
@@ -157,7 +156,7 @@ public static void removePackageURLs(Set<String> packageUrlsToRemove) {
157
156
*/
158
157
public static void installsubsetOfLatestPlatforms (int fromIndex , int toIndex ) {
159
158
if (!isReady ()) {
160
- Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , Messages . BoardsManagerIsBussy , new Exception ()));
159
+ Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , BoardsManagerIsBussy , new Exception ()));
161
160
return ;
162
161
}
163
162
platformsDirty = true ;
@@ -185,7 +184,7 @@ public static void installAllLatestPlatforms() {
185
184
186
185
public static void installLatestPlatform (String JasonName , String packageName , String architectureName ) {
187
186
if (!isReady ()) {
188
- Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , Messages . BoardsManagerIsBussy , new Exception ()));
187
+ Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , BoardsManagerIsBussy , new Exception ()));
189
188
return ;
190
189
}
191
190
platformsDirty = true ;
@@ -243,7 +242,7 @@ public static File[] getAllBoardsFiles() {
243
242
}
244
243
if (boardFiles .size () == 0 ) {
245
244
Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID ,
246
- Messages . Helpers_No_boards_txt_found .replace (FILE , String .join ("\n " , hardwareFolders )), null )); //$NON-NLS-1$
245
+ Helpers_No_boards_txt_found .replace (FILE , String .join ("\n " , hardwareFolders )), null )); //$NON-NLS-1$
247
246
return null ;
248
247
}
249
248
return boardFiles .toArray (new File [boardFiles .size ()]);
@@ -255,7 +254,7 @@ private static void searchFiles(File folder, TreeSet<File> Hardwarelists, String
255
254
if (a == null ) {
256
255
if (!myHasbeenLogged ) {
257
256
Common .log (new Status (IStatus .INFO , Const .CORE_PLUGIN_ID ,
258
- Messages . Helpers_Error_The_folder_is_empty .replace (FOLDER , folder .toString ()), null ));
257
+ Helpers_Error_The_folder_is_empty .replace (FOLDER , folder .toString ()), null ));
259
258
myHasbeenLogged = true ;
260
259
}
261
260
return ;
@@ -569,7 +568,7 @@ public Platform getPlatform(Package curPackage, ArduinoPlatform curInternalPlatf
569
568
570
569
public static IStatus setPlatformTree (PlatformTree platformTree , IProgressMonitor monitor , MultiStatus status ) {
571
570
if (!isReady ()) {
572
- status .add (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , Messages . BoardsManagerIsBussy , null ));
571
+ status .add (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , BoardsManagerIsBussy , null ));
573
572
return status ;
574
573
}
575
574
if (!ConfigurationPreferences .getUpdateJasonFilesFlag ()) {
@@ -617,7 +616,7 @@ public static TreeMap<String, String> getAllmenus() {
617
616
*/
618
617
public static void onlyKeepLatestPlatforms () {
619
618
if (!isReady ()) {
620
- Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , Messages . BoardsManagerIsBussy , new Exception ()));
619
+ Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , BoardsManagerIsBussy , new Exception ()));
621
620
return ;
622
621
}
623
622
InternalPackageManager .onlyKeepLatestPlatforms ();
@@ -626,7 +625,7 @@ public static void onlyKeepLatestPlatforms() {
626
625
627
626
public static void setPrivateHardwarePaths (String [] hardWarePaths ) {
628
627
if (!isReady ()) {
629
- Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , Messages . BoardsManagerIsBussy , new Exception ()));
628
+ Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , BoardsManagerIsBussy , new Exception ()));
630
629
return ;
631
630
}
632
631
InstancePreferences .setPrivateHardwarePaths (hardWarePaths );
@@ -690,7 +689,7 @@ static private void loadPackage(File jsonFile) {
690
689
packageIndices .add (index );
691
690
} catch (Exception e ) {
692
691
Common .log (new Status (IStatus .ERROR , Activator .getId (),
693
- Messages . Manager_Failed_to_parse .replace (FILE , jsonFile .getAbsolutePath ()), e ));
692
+ Manager_Failed_to_parse .replace (FILE , jsonFile .getAbsolutePath ()), e ));
694
693
jsonFile .delete ();// Delete the file so it stops damaging
695
694
}
696
695
}
@@ -822,7 +821,7 @@ public static String[] getJsonURLList() {
822
821
*/
823
822
public static void setJsonURLs (String [] newJsonUrls ) {
824
823
if (!isReady ()) {
825
- Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , Messages . BoardsManagerIsBussy , new Exception ()));
824
+ Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , BoardsManagerIsBussy , new Exception ()));
826
825
return ;
827
826
}
828
827
@@ -858,7 +857,7 @@ public static String getDefaultURLs() {
858
857
859
858
public static void removeAllInstalledPlatforms () {
860
859
if (!isReady ()) {
861
- Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , Messages . BoardsManagerIsBussy , new Exception ()));
860
+ Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , BoardsManagerIsBussy , new Exception ()));
862
861
return ;
863
862
}
864
863
try {
0 commit comments