43
43
import org .apache .commons .compress .archivers .zip .ZipArchiveInputStream ;
44
44
import org .apache .commons .compress .compressors .bzip2 .BZip2CompressorInputStream ;
45
45
import org .apache .commons .compress .compressors .gzip .GzipCompressorInputStream ;
46
- import org .eclipse .core .runtime .CoreException ;
47
46
import org .eclipse .core .runtime .IPath ;
48
47
import org .eclipse .core .runtime .IProgressMonitor ;
49
48
import org .eclipse .core .runtime .IStatus ;
@@ -90,40 +89,36 @@ public static void addPackageURLs(HashSet<String> packageUrlsToAdd, boolean forc
90
89
*/
91
90
public static void startup_Pluging (IProgressMonitor monitor ) {
92
91
loadIndices (ConfigurationPreferences .getUpdateJasonFilesValue ());
93
- try {
94
- List <Board > allBoards = getInstalledBoards ();
95
- if (allBoards .isEmpty ()) { // If boards are installed do nothing
96
- InstallDefaultLibraries (monitor );
97
- MyMultiStatus mstatus = new MyMultiStatus ("Failed to configer Sloeber" ); //$NON-NLS-1$
98
-
99
- // Downmload sample programs
100
- mstatus .addErrors (downloadAndInstall (Defaults .EXAMPLES_URL , Defaults .EXAMPLE_PACKAGE ,
101
- Paths .get (ConfigurationPreferences .getInstallationPathExamples ().toString ()), false , monitor ));
102
-
103
- if (mstatus .isOK ()) {
104
- // if successfully installed the examples: add the boards
105
-
106
- Package pkg = packageIndices .get (0 ).getPackages ().get (0 );
107
- if (pkg != null ) {
108
- ArduinoPlatform platform = pkg .getLatestPlatform (Defaults .PLATFORM_NAME );
109
- if (platform == null ) {
110
- ArduinoPlatform [] platformList = new ArduinoPlatform [pkg .getLatestPlatforms ().size ()];
111
- pkg .getLatestPlatforms ().toArray (platformList );
112
- platform = platformList [0 ];
113
- }
114
- if (platform != null ) {
115
- mstatus .addErrors (downloadAndInstall (platform , false , monitor ));
116
- }
92
+ List <Board > allBoards = getInstalledBoards ();
93
+ if (allBoards .isEmpty ()) { // If boards are installed do nothing
94
+ InstallDefaultLibraries (monitor );
95
+ MyMultiStatus mstatus = new MyMultiStatus ("Failed to configer Sloeber" ); //$NON-NLS-1$
96
+
97
+ // Downnload sample programs
98
+ mstatus .addErrors (downloadAndInstall (Defaults .EXAMPLES_URL , Defaults .EXAMPLE_PACKAGE ,
99
+ Paths .get (ConfigurationPreferences .getInstallationPathExamples ().toString ()), false , monitor ));
100
+
101
+ if (mstatus .isOK ()) {
102
+ // if successfully installed the examples: add the boards
103
+
104
+ Package pkg = getPackageIndices ().get (0 ).getPackages ().get (0 );
105
+ if (pkg != null ) {
106
+ ArduinoPlatform platform = pkg .getLatestPlatform (Defaults .PLATFORM_NAME );
107
+ if (platform == null ) {
108
+ ArduinoPlatform [] platformList = new ArduinoPlatform [pkg .getLatestPlatforms ().size ()];
109
+ pkg .getLatestPlatforms ().toArray (platformList );
110
+ platform = platformList [0 ];
111
+ }
112
+ if (platform != null ) {
113
+ mstatus .addErrors (downloadAndInstall (platform , false , monitor ));
117
114
}
118
115
}
119
- if (!mstatus .isOK ()) {
120
- StatusManager stMan = StatusManager .getManager ();
121
- stMan .handle (mstatus , StatusManager .LOG | StatusManager .SHOW | StatusManager .BLOCK );
122
- }
123
-
124
116
}
125
- } catch (CoreException e ) {
126
- e .printStackTrace ();
117
+ if (!mstatus .isOK ()) {
118
+ StatusManager stMan = StatusManager .getManager ();
119
+ stMan .handle (mstatus , StatusManager .LOG | StatusManager .SHOW | StatusManager .BLOCK );
120
+ }
121
+
127
122
}
128
123
myIsReady = true ;
129
124
@@ -294,8 +289,8 @@ static public LibraryIndex getLibraryIndex() {
294
289
return libraryIndex ;
295
290
}
296
291
297
- static public Board getBoard (String boardName , String platformName , String packageName ) throws CoreException {
298
- for (PackageIndex index : packageIndices ) {
292
+ static public Board getBoard (String boardName , String platformName , String packageName ) {
293
+ for (PackageIndex index : getPackageIndices () ) {
299
294
Package pkg = index .getPackage (packageName );
300
295
if (pkg != null ) {
301
296
ArduinoPlatform platform = pkg .getLatestPlatform (platformName );
@@ -310,9 +305,9 @@ static public Board getBoard(String boardName, String platformName, String packa
310
305
return null ;
311
306
}
312
307
313
- static public List <Board > getBoards () throws CoreException {
308
+ static public List <Board > getBoards () {
314
309
List <Board > boards = new ArrayList <>();
315
- for (PackageIndex index : packageIndices ) {
310
+ for (PackageIndex index : getPackageIndices () ) {
316
311
for (Package pkg : index .getPackages ()) {
317
312
for (ArduinoPlatform platform : pkg .getLatestPlatforms ()) {
318
313
boards .addAll (platform .getBoards ());
@@ -324,7 +319,7 @@ static public List<Board> getBoards() throws CoreException {
324
319
325
320
public static List <ArduinoPlatform > getPlatforms () {
326
321
List <ArduinoPlatform > platforms = new ArrayList <>();
327
- for (PackageIndex index : packageIndices ) {
322
+ for (PackageIndex index : getPackageIndices () ) {
328
323
for (Package pkg : index .getPackages ()) {
329
324
platforms .addAll (pkg .getPlatforms ());
330
325
}
@@ -334,7 +329,7 @@ public static List<ArduinoPlatform> getPlatforms() {
334
329
335
330
public static IPath getPlatformInstallPath (String vendor , String architecture ) {
336
331
337
- for (PackageIndex index : packageIndices ) {
332
+ for (PackageIndex index : getPackageIndices () ) {
338
333
for (Package pkg : index .getPackages ()) {
339
334
for (ArduinoPlatform curPlatform : pkg .getInstalledPlatforms ()) {
340
335
if (architecture .equalsIgnoreCase (curPlatform .getArchitecture ())
@@ -354,7 +349,7 @@ public static IPath getPlatformInstallPath(String vendor, String architecture) {
354
349
* @return the found platform otherwise null
355
350
*/
356
351
public static ArduinoPlatform getPlatform (File platformTxt ) {
357
- for (PackageIndex index : packageIndices ) {
352
+ for (PackageIndex index : getPackageIndices () ) {
358
353
for (Package pkg : index .getPackages ()) {
359
354
for (ArduinoPlatform curPlatform : pkg .getPlatforms ()) {
360
355
if (curPlatform .getPlatformFile ().equals (platformTxt )) {
@@ -368,7 +363,7 @@ public static ArduinoPlatform getPlatform(File platformTxt) {
368
363
369
364
static public List <ArduinoPlatform > getInstalledPlatforms () {
370
365
List <ArduinoPlatform > platforms = new ArrayList <>();
371
- for (PackageIndex index : packageIndices ) {
366
+ for (PackageIndex index : getPackageIndices () ) {
372
367
for (Package pkg : index .getPackages ()) {
373
368
374
369
platforms .addAll (pkg .getInstalledPlatforms ());
@@ -378,9 +373,9 @@ static public List<ArduinoPlatform> getInstalledPlatforms() {
378
373
return platforms ;
379
374
}
380
375
381
- static public List <Board > getInstalledBoards () throws CoreException {
376
+ static public List <Board > getInstalledBoards () {
382
377
List <Board > boards = new ArrayList <>();
383
- for (PackageIndex index : packageIndices ) {
378
+ for (PackageIndex index : getPackageIndices () ) {
384
379
for (Package pkg : index .getPackages ()) {
385
380
for (ArduinoPlatform platform : pkg .getInstalledPlatforms ()) {
386
381
boards .addAll (platform .getBoards ());
@@ -392,14 +387,14 @@ static public List<Board> getInstalledBoards() throws CoreException {
392
387
393
388
static public List <Package > getPackages () {
394
389
List <Package > packages = new ArrayList <>();
395
- for (PackageIndex index : packageIndices ) {
390
+ for (PackageIndex index : getPackageIndices () ) {
396
391
packages .addAll (index .getPackages ());
397
392
}
398
393
return packages ;
399
394
}
400
395
401
396
static public Package getPackage (String JasonName , String packageName ) {
402
- for (PackageIndex index : packageIndices ) {
397
+ for (PackageIndex index : getPackageIndices () ) {
403
398
if (index .getJsonFileName ().equals (JasonName )) {
404
399
return index .getPackage (packageName );
405
400
}
@@ -408,7 +403,7 @@ static public Package getPackage(String JasonName, String packageName) {
408
403
}
409
404
410
405
static public Package getPackage (String packageName ) {
411
- for (PackageIndex index : packageIndices ) {
406
+ for (PackageIndex index : getPackageIndices () ) {
412
407
Package pkg = index .getPackage (packageName );
413
408
if (pkg != null ) {
414
409
return pkg ;
@@ -418,7 +413,7 @@ static public Package getPackage(String packageName) {
418
413
}
419
414
420
415
static public Tool getTool (String packageName , String toolName , String version ) {
421
- for (PackageIndex index : packageIndices ) {
416
+ for (PackageIndex index : getPackageIndices () ) {
422
417
Package pkg = index .getPackage (packageName );
423
418
if (pkg != null ) {
424
419
Tool tool = pkg .getTool (toolName , version );
@@ -666,7 +661,10 @@ public static IStatus extract(ArchiveInputStream in, File destFolder, int stripP
666
661
if (entry .getKey ().exists () && overwrite ) {
667
662
entry .getKey ().delete ();
668
663
}
669
- symlink (entry .getValue (), entry .getKey ());
664
+ // do not make symlinks in windows
665
+ if (!Platform .getOS ().equals (Platform .OS_WIN32 )) {
666
+ symlink (entry .getValue (), entry .getKey ());
667
+ }
670
668
entry .getKey ().setLastModified (symLinksModifiedTimes .get (entry .getKey ()).longValue ());
671
669
}
672
670
@@ -855,7 +853,7 @@ public static void setBoardsPackageURL(String[] newBoardJsonUrls) {
855
853
loadIndices (false );
856
854
}
857
855
858
- public static String getBoardsPackageURLs () {
856
+ public static String getDefaultBoardsPackageURLs () {
859
857
return ConfigurationPreferences .getDefaultBoardsPackageURLs ();
860
858
}
861
859
0 commit comments