Skip to content

Commit

Permalink
Merge pull request esp8266#2947 from Lauszus/MultipleLibraries
Browse files Browse the repository at this point in the history
Allow library manager to install multiple libraries at once.
  • Loading branch information
ffissore committed Apr 9, 2015
2 parents 87e2e68 + 7d08b58 commit 7032fcf
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,28 +368,30 @@ protected void onProgress(Progress progress) {
indexer.setLibrariesFolders(BaseNoGui.getLibrariesPath());
installer.updateIndex();

String[] libraryToInstallParts = parser.getLibraryToInstall().split(":");

ContributedLibrary selected=null;
if (libraryToInstallParts.length == 2) {
selected = indexer.getIndex().find(libraryToInstallParts[0], VersionHelper.valueOf(libraryToInstallParts[1]).toString());
} else if (libraryToInstallParts.length == 1) {
List<ContributedLibrary> librariesByName = indexer.getIndex().find(libraryToInstallParts[0]);
Collections.sort(librariesByName, new DownloadableContributionVersionComparator());
if (!librariesByName.isEmpty()) {
selected = librariesByName.get(librariesByName.size() - 1);
for (String library : parser.getLibraryToInstall().split(",")) {
String[] libraryToInstallParts = library.split(":");

ContributedLibrary selected=null;
if (libraryToInstallParts.length == 2) {
selected = indexer.getIndex().find(libraryToInstallParts[0], VersionHelper.valueOf(libraryToInstallParts[1]).toString());
} else if (libraryToInstallParts.length == 1) {
List<ContributedLibrary> librariesByName = indexer.getIndex().find(libraryToInstallParts[0]);
Collections.sort(librariesByName, new DownloadableContributionVersionComparator());
if (!librariesByName.isEmpty()) {
selected = librariesByName.get(librariesByName.size() - 1);
}
}
if (selected == null) {
System.out.println(_("Selected library is not available"));
System.exit(1);
}
}
if (selected == null) {
System.out.println(_("Selected library is not available"));
System.exit(1);
}

ContributedLibrary installed = indexer.getIndex().getInstalled(libraryToInstallParts[0]);
if (selected.isReadOnly()) {
installer.remove(installed);
} else {
installer.install(selected, installed);
ContributedLibrary installed = indexer.getIndex().getInstalled(libraryToInstallParts[0]);
if (selected.isReadOnly()) {
installer.remove(installed);
} else {
installer.install(selected, installed);
}
}

System.exit(0);
Expand Down

0 comments on commit 7032fcf

Please sign in to comment.