mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
Merge remote-tracking branch 'arduino/master'
This commit is contained in:
commit
8f2514f7c1
@ -29,14 +29,13 @@
|
||||
|
||||
package cc.arduino.contributions;
|
||||
|
||||
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
||||
import cc.arduino.contributions.libraries.LibraryInstaller;
|
||||
import cc.arduino.contributions.libraries.filters.UpdatableLibraryPredicate;
|
||||
import cc.arduino.contributions.packages.ContributionInstaller;
|
||||
import cc.arduino.contributions.packages.ContributionsIndexer;
|
||||
import cc.arduino.contributions.packages.filters.UpdatablePlatformPredicate;
|
||||
import cc.arduino.view.NotificationPopup;
|
||||
import processing.app.Base;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.I18n;
|
||||
|
||||
import javax.swing.*;
|
||||
@ -49,21 +48,17 @@ public class ContributionsSelfCheck extends TimerTask {
|
||||
|
||||
private final Base base;
|
||||
private final HyperlinkListener hyperlinkListener;
|
||||
private final ContributionsIndexer contributionsIndexer;
|
||||
private final ContributionInstaller contributionInstaller;
|
||||
private final LibrariesIndexer librariesIndexer;
|
||||
private final LibraryInstaller libraryInstaller;
|
||||
private final ProgressListener progressListener;
|
||||
|
||||
private volatile boolean cancelled;
|
||||
private volatile NotificationPopup notificationPopup;
|
||||
|
||||
public ContributionsSelfCheck(Base base, HyperlinkListener hyperlinkListener, ContributionsIndexer contributionsIndexer, ContributionInstaller contributionInstaller, LibrariesIndexer librariesIndexer, LibraryInstaller libraryInstaller) {
|
||||
public ContributionsSelfCheck(Base base, HyperlinkListener hyperlinkListener, ContributionInstaller contributionInstaller, LibraryInstaller libraryInstaller) {
|
||||
this.base = base;
|
||||
this.hyperlinkListener = hyperlinkListener;
|
||||
this.contributionsIndexer = contributionsIndexer;
|
||||
this.contributionInstaller = contributionInstaller;
|
||||
this.librariesIndexer = librariesIndexer;
|
||||
this.libraryInstaller = libraryInstaller;
|
||||
this.progressListener = new NoopProgressListener();
|
||||
this.cancelled = false;
|
||||
@ -74,12 +69,12 @@ public class ContributionsSelfCheck extends TimerTask {
|
||||
updateContributionIndex();
|
||||
updateLibrariesIndex();
|
||||
|
||||
long updatablePlatforms = contributionsIndexer.getPackages().stream()
|
||||
long updatablePlatforms = BaseNoGui.indexer.getPackages().stream()
|
||||
.flatMap(pack -> pack.getPlatforms().stream())
|
||||
.filter(new UpdatablePlatformPredicate(contributionsIndexer)).count();
|
||||
.filter(new UpdatablePlatformPredicate()).count();
|
||||
|
||||
long updatableLibraries = librariesIndexer.getInstalledLibraries().stream()
|
||||
.filter(new UpdatableLibraryPredicate(librariesIndexer))
|
||||
long updatableLibraries = BaseNoGui.librariesIndexer.getInstalledLibraries().stream()
|
||||
.filter(new UpdatableLibraryPredicate())
|
||||
.count();
|
||||
|
||||
if (updatableLibraries <= 0 && updatablePlatforms <= 0) {
|
||||
|
@ -31,26 +31,21 @@ package cc.arduino.contributions.libraries.filters;
|
||||
|
||||
import cc.arduino.contributions.filters.InstalledPredicate;
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.LibrariesIndex;
|
||||
import processing.app.BaseNoGui;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class InstalledLibraryPredicate implements Predicate<ContributedLibrary> {
|
||||
|
||||
private final LibrariesIndex index;
|
||||
|
||||
public InstalledLibraryPredicate(LibrariesIndex index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(ContributedLibrary input) {
|
||||
if (input.isInstalled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
List<ContributedLibrary> libraries = index.find(input.getName());
|
||||
List<ContributedLibrary> libraries = BaseNoGui.librariesIndexer.getIndex().find(input.getName());
|
||||
|
||||
return libraries.stream()
|
||||
.filter(new InstalledPredicate())
|
||||
.count() > 0;
|
||||
|
@ -31,7 +31,7 @@ package cc.arduino.contributions.libraries.filters;
|
||||
|
||||
import cc.arduino.contributions.VersionComparator;
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.packages.UserLibrary;
|
||||
|
||||
import java.util.List;
|
||||
@ -39,22 +39,20 @@ import java.util.function.Predicate;
|
||||
|
||||
public class UpdatableLibraryPredicate implements Predicate<ContributedLibrary> {
|
||||
|
||||
private final LibrariesIndexer indexer;
|
||||
private final VersionComparator versionComparator;
|
||||
|
||||
public UpdatableLibraryPredicate(LibrariesIndexer indexer) {
|
||||
this.indexer = indexer;
|
||||
public UpdatableLibraryPredicate() {
|
||||
this.versionComparator = new VersionComparator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(ContributedLibrary contributedLibrary) {
|
||||
String libraryName = contributedLibrary.getName();
|
||||
UserLibrary installed = indexer.getInstalledLibraries().getByName(libraryName);
|
||||
UserLibrary installed = BaseNoGui.librariesIndexer.getInstalledLibraries().getByName(libraryName);
|
||||
if (installed == null) {
|
||||
return false;
|
||||
}
|
||||
List<ContributedLibrary> libraries = indexer.getIndex().find(libraryName);
|
||||
List<ContributedLibrary> libraries = BaseNoGui.librariesIndexer.getIndex().find(libraryName);
|
||||
return libraries.stream()
|
||||
.filter(library -> versionComparator.greaterThan(library.getParsedVersion(), installed.getParsedVersion()))
|
||||
.count() > 0;
|
||||
|
@ -30,7 +30,6 @@
|
||||
package cc.arduino.contributions.libraries.ui;
|
||||
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.LibrariesIndex;
|
||||
import cc.arduino.contributions.libraries.filters.InstalledLibraryPredicate;
|
||||
import cc.arduino.contributions.ui.DropdownItem;
|
||||
|
||||
@ -40,19 +39,13 @@ import static processing.app.I18n.tr;
|
||||
|
||||
public class DropdownInstalledLibraryItem implements DropdownItem<ContributedLibrary> {
|
||||
|
||||
private final LibrariesIndex index;
|
||||
|
||||
public DropdownInstalledLibraryItem(LibrariesIndex index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return tr("Installed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate<ContributedLibrary> getFilterPredicate() {
|
||||
return new InstalledLibraryPredicate(index);
|
||||
return new InstalledLibraryPredicate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,7 +30,6 @@
|
||||
package cc.arduino.contributions.libraries.ui;
|
||||
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
||||
import cc.arduino.contributions.libraries.filters.UpdatableLibraryPredicate;
|
||||
import cc.arduino.contributions.ui.DropdownItem;
|
||||
|
||||
@ -40,15 +39,9 @@ import static processing.app.I18n.tr;
|
||||
|
||||
public class DropdownUpdatableLibrariesItem implements DropdownItem<ContributedLibrary> {
|
||||
|
||||
private final LibrariesIndexer indexer;
|
||||
|
||||
public DropdownUpdatableLibrariesItem(LibrariesIndexer indexer) {
|
||||
this.indexer = indexer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate<ContributedLibrary> getFilterPredicate() {
|
||||
return new UpdatableLibraryPredicate(indexer);
|
||||
return new UpdatableLibraryPredicate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,9 +30,9 @@
|
||||
package cc.arduino.contributions.libraries.ui;
|
||||
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.ui.FilteredAbstractTableModel;
|
||||
import processing.app.BaseNoGui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -51,12 +51,6 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel<Contrib
|
||||
|
||||
private final Class<?>[] columnTypes = {ContributedPlatform.class};
|
||||
|
||||
private LibrariesIndexer indexer;
|
||||
|
||||
public void setIndexer(LibrariesIndexer _index) {
|
||||
indexer = _index;
|
||||
}
|
||||
|
||||
Predicate<ContributedLibrary> selectedCategoryFilter = null;
|
||||
String selectedFilters[] = null;
|
||||
|
||||
@ -202,8 +196,8 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel<Contrib
|
||||
|
||||
private void updateContributions() {
|
||||
contributions.clear();
|
||||
indexer.getIndex().getLibraries().forEach(this::applyFilterToLibrary);
|
||||
indexer.getInstalledLibraries().forEach(this::applyFilterToLibrary);
|
||||
BaseNoGui.librariesIndexer.getIndex().getLibraries().forEach(this::applyFilterToLibrary);
|
||||
BaseNoGui.librariesIndexer.getInstalledLibraries().forEach(this::applyFilterToLibrary);
|
||||
Collections.sort(contributions, new ContributedLibraryReleasesComparator("Arduino"));
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ package cc.arduino.contributions.libraries.ui;
|
||||
|
||||
import cc.arduino.contributions.DownloadableContribution;
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
||||
import cc.arduino.contributions.libraries.LibraryInstaller;
|
||||
import cc.arduino.contributions.libraries.LibraryTypeComparator;
|
||||
import cc.arduino.contributions.ui.*;
|
||||
@ -136,17 +135,12 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
||||
categoryChooser.removeActionListener(categoryChooserActionListener);
|
||||
typeChooser.removeActionListener(typeChooserActionListener);
|
||||
|
||||
// TODO: Remove setIndexer and make getContribModel
|
||||
// return a FilteredAbstractTableModel
|
||||
LibrariesIndexer indexer = BaseNoGui.librariesIndexer;
|
||||
getContribModel().setIndexer(indexer);
|
||||
|
||||
categoryFilter = null;
|
||||
categoryChooser.removeAllItems();
|
||||
|
||||
// Load categories
|
||||
categoryChooser.addItem(new DropdownAllItem());
|
||||
Collection<String> categories = indexer.getIndex().getCategories();
|
||||
Collection<String> categories = BaseNoGui.librariesIndexer.getIndex().getCategories();
|
||||
for (String category : categories) {
|
||||
categoryChooser.addItem(new DropdownLibraryOfCategoryItem(category));
|
||||
}
|
||||
@ -163,9 +157,9 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
||||
typeFilter = null;
|
||||
typeChooser.removeAllItems();
|
||||
typeChooser.addItem(new DropdownAllItem());
|
||||
typeChooser.addItem(new DropdownUpdatableLibrariesItem(indexer));
|
||||
typeChooser.addItem(new DropdownInstalledLibraryItem(indexer.getIndex()));
|
||||
java.util.List<String> types = new LinkedList<>(indexer.getIndex().getTypes());
|
||||
typeChooser.addItem(new DropdownUpdatableLibrariesItem());
|
||||
typeChooser.addItem(new DropdownInstalledLibraryItem());
|
||||
java.util.List<String> types = new LinkedList<>(BaseNoGui.librariesIndexer.getIndex().getTypes());
|
||||
Collections.sort(types, new LibraryTypeComparator());
|
||||
for (String type : types) {
|
||||
typeChooser.addItem(new DropdownLibraryOfTypeItem(type));
|
||||
|
@ -31,18 +31,16 @@ package cc.arduino.contributions.packages.filters;
|
||||
|
||||
import cc.arduino.contributions.VersionComparator;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.packages.ContributionsIndexer;
|
||||
import processing.app.BaseNoGui;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class UpdatablePlatformPredicate implements Predicate<ContributedPlatform> {
|
||||
|
||||
private final ContributionsIndexer indexer;
|
||||
private final VersionComparator versionComparator;
|
||||
|
||||
public UpdatablePlatformPredicate(ContributionsIndexer indexer) {
|
||||
this.indexer = indexer;
|
||||
public UpdatablePlatformPredicate() {
|
||||
this.versionComparator = new VersionComparator();
|
||||
}
|
||||
|
||||
@ -51,12 +49,12 @@ public class UpdatablePlatformPredicate implements Predicate<ContributedPlatform
|
||||
String packageName = contributedPlatform.getParentPackage().getName();
|
||||
String architecture = contributedPlatform.getArchitecture();
|
||||
|
||||
ContributedPlatform installed = indexer.getInstalled(packageName, architecture);
|
||||
ContributedPlatform installed = BaseNoGui.indexer.getInstalled(packageName, architecture);
|
||||
if (installed == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<ContributedPlatform> platforms = indexer.getIndex().findPlatforms(packageName, architecture);
|
||||
List<ContributedPlatform> platforms = BaseNoGui.indexer.getIndex().findPlatforms(packageName, architecture);
|
||||
return platforms.stream()
|
||||
.filter(platform -> versionComparator.greaterThan(platform.getParsedVersion(), installed.getParsedVersion()))
|
||||
.count() > 0;
|
||||
|
@ -34,8 +34,8 @@ import cc.arduino.contributions.filters.InstalledPredicate;
|
||||
import cc.arduino.contributions.packages.ContributedBoard;
|
||||
import cc.arduino.contributions.packages.ContributedPackage;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.packages.ContributionsIndexer;
|
||||
import cc.arduino.contributions.ui.FilteredAbstractTableModel;
|
||||
import processing.app.BaseNoGui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -115,16 +115,10 @@ public class ContributionIndexTableModel extends FilteredAbstractTableModel<Cont
|
||||
|
||||
private final Class<?>[] columnTypes = {ContributedPlatform.class};
|
||||
|
||||
private ContributionsIndexer indexer;
|
||||
|
||||
public void setIndexer(ContributionsIndexer indexer) {
|
||||
this.indexer = indexer;
|
||||
}
|
||||
|
||||
public void updateIndexFilter(String[] filters, Stream<Predicate<ContributedPlatform>> additionalFilters) {
|
||||
contributions.clear();
|
||||
Predicate<ContributedPlatform> filter = additionalFilters.reduce(Predicate::and).get();
|
||||
for (ContributedPackage pack : indexer.getPackages()) {
|
||||
for (ContributedPackage pack : BaseNoGui.indexer.getPackages()) {
|
||||
for (ContributedPlatform platform : pack.getPlatforms()) {
|
||||
String compoundTargetSearchText = platform.getName() + "\n" + platform.getBoards().stream().map(ContributedBoard::getName).collect(Collectors.joining(" "));
|
||||
if (!filter.test(platform)) {
|
||||
|
@ -32,7 +32,6 @@ package cc.arduino.contributions.packages.ui;
|
||||
import cc.arduino.contributions.DownloadableContribution;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.packages.ContributionInstaller;
|
||||
import cc.arduino.contributions.packages.ContributionsIndexer;
|
||||
import cc.arduino.contributions.ui.*;
|
||||
import cc.arduino.utils.Progress;
|
||||
import processing.app.BaseNoGui;
|
||||
@ -94,9 +93,6 @@ public class ContributionManagerUI extends InstallerJDialog {
|
||||
|
||||
categoryChooser.removeActionListener(categoryChooserActionListener);
|
||||
|
||||
ContributionsIndexer indexer = BaseNoGui.indexer;
|
||||
getContribModel().setIndexer(indexer);
|
||||
|
||||
categoryFilter = null;
|
||||
categoryChooser.removeAllItems();
|
||||
|
||||
@ -106,8 +102,8 @@ public class ContributionManagerUI extends InstallerJDialog {
|
||||
|
||||
// Enable categories combo only if there are two or more choices
|
||||
categoryChooser.addItem(new DropdownAllCoresItem());
|
||||
categoryChooser.addItem(new DropdownUpdatableCoresItem(indexer));
|
||||
Collection<String> categories = indexer.getCategories();
|
||||
categoryChooser.addItem(new DropdownUpdatableCoresItem());
|
||||
Collection<String> categories = BaseNoGui.indexer.getCategories();
|
||||
for (String s : categories) {
|
||||
categoryChooser.addItem(new DropdownCoreOfCategoryItem(s));
|
||||
}
|
||||
|
@ -30,7 +30,6 @@
|
||||
package cc.arduino.contributions.packages.ui;
|
||||
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.packages.ContributionsIndexer;
|
||||
import cc.arduino.contributions.packages.filters.UpdatablePlatformPredicate;
|
||||
import cc.arduino.contributions.ui.DropdownItem;
|
||||
|
||||
@ -40,15 +39,9 @@ import static processing.app.I18n.tr;
|
||||
|
||||
public class DropdownUpdatableCoresItem implements DropdownItem<ContributedPlatform> {
|
||||
|
||||
private final ContributionsIndexer indexer;
|
||||
|
||||
public DropdownUpdatableCoresItem(ContributionsIndexer indexer) {
|
||||
this.indexer = indexer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate<ContributedPlatform> getFilterPredicate() {
|
||||
return new UpdatablePlatformPredicate(indexer);
|
||||
return new UpdatablePlatformPredicate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -301,8 +301,8 @@ public class Base {
|
||||
this.pdeKeywords = new PdeKeywords();
|
||||
this.pdeKeywords.reload();
|
||||
|
||||
contributionInstaller = new ContributionInstaller(BaseNoGui.indexer, BaseNoGui.getPlatform(), new GPGDetachedSignatureVerifier());
|
||||
libraryInstaller = new LibraryInstaller(BaseNoGui.librariesIndexer, BaseNoGui.getPlatform());
|
||||
contributionInstaller = new ContributionInstaller(BaseNoGui.getPlatform(), new GPGDetachedSignatureVerifier());
|
||||
libraryInstaller = new LibraryInstaller(BaseNoGui.getPlatform());
|
||||
|
||||
parser.parseArgumentsPhase2();
|
||||
|
||||
@ -379,7 +379,7 @@ public class Base {
|
||||
System.exit(0);
|
||||
|
||||
} else if (parser.isInstallLibrary()) {
|
||||
LibrariesIndexer indexer = new LibrariesIndexer(BaseNoGui.getSettingsFolder(), new ContributionsIndexer(BaseNoGui.getSettingsFolder(), BaseNoGui.getPlatform(), new GPGDetachedSignatureVerifier()));
|
||||
LibrariesIndexer indexer = new LibrariesIndexer(BaseNoGui.getSettingsFolder());
|
||||
ProgressListener progressListener = new ConsoleProgressListener();
|
||||
indexer.parseIndex();
|
||||
BaseNoGui.onBoardOrPortChange();
|
||||
@ -462,7 +462,7 @@ public class Base {
|
||||
if (PreferencesData.getBoolean("update.check")) {
|
||||
new UpdateCheck(this);
|
||||
|
||||
contributionsSelfCheck = new ContributionsSelfCheck(this, new UpdatableBoardsLibsFakeURLsHandler(this), BaseNoGui.indexer, contributionInstaller, BaseNoGui.librariesIndexer, libraryInstaller);
|
||||
contributionsSelfCheck = new ContributionsSelfCheck(this, new UpdatableBoardsLibsFakeURLsHandler(this), contributionInstaller, libraryInstaller);
|
||||
new Timer(false).schedule(contributionsSelfCheck, Constants.BOARDS_LIBS_UPDATABLE_CHECK_START_PERIOD);
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,8 @@ import java.nio.file.LinkOption;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static processing.app.I18n.tr;
|
||||
import static processing.app.I18n.format;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class DownloadableContributionsDownloader {
|
||||
|
||||
|
@ -33,7 +33,6 @@ import cc.arduino.Constants;
|
||||
import cc.arduino.contributions.libraries.filters.LibraryInstalledInsideCore;
|
||||
import cc.arduino.contributions.libraries.filters.TypePredicate;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.packages.ContributionsIndexer;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.module.mrbean.MrBeanModule;
|
||||
@ -58,7 +57,6 @@ import static processing.app.I18n.tr;
|
||||
|
||||
public class LibrariesIndexer {
|
||||
|
||||
private final ContributionsIndexer contributionsIndexer;
|
||||
private LibrariesIndex index;
|
||||
private final LibraryList installedLibraries = new LibraryList();
|
||||
private final LibraryList installedLibrariesWithDuplicates = new LibraryList();
|
||||
@ -69,8 +67,7 @@ public class LibrariesIndexer {
|
||||
|
||||
private final List<String> badLibNotified = new ArrayList<>();
|
||||
|
||||
public LibrariesIndexer(File preferencesFolder, ContributionsIndexer contributionsIndexer) {
|
||||
this.contributionsIndexer = contributionsIndexer;
|
||||
public LibrariesIndexer(File preferencesFolder) {
|
||||
this.indexFile = new File(preferencesFolder, "library_index.json");
|
||||
this.stagingFolder = new File(new File(preferencesFolder, "staging"), "libraries");
|
||||
}
|
||||
@ -123,8 +120,8 @@ public class LibrariesIndexer {
|
||||
scanInstalledLibraries(folder, folder.equals(sketchbookLibrariesFolder));
|
||||
}
|
||||
|
||||
installedLibraries.stream().filter(new TypePredicate("Contributed")).filter(new LibraryInstalledInsideCore(contributionsIndexer)).forEach(userLibrary -> {
|
||||
ContributedPlatform platform = contributionsIndexer.getPlatformByFolder(userLibrary.getInstalledFolder());
|
||||
installedLibraries.stream().filter(new TypePredicate("Contributed")).filter(new LibraryInstalledInsideCore()).forEach(userLibrary -> {
|
||||
ContributedPlatform platform = BaseNoGui.indexer.getPlatformByFolder(userLibrary.getInstalledFolder());
|
||||
userLibrary.setTypes(Collections.singletonList(platform.getCategory()));
|
||||
});
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import cc.arduino.contributions.GZippedJsonDownloader;
|
||||
import cc.arduino.contributions.ProgressListener;
|
||||
import cc.arduino.utils.ArchiveExtractor;
|
||||
import cc.arduino.utils.MultiStepProgress;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.I18n;
|
||||
import processing.app.Platform;
|
||||
import processing.app.helpers.FileUtils;
|
||||
@ -47,22 +48,18 @@ import static processing.app.I18n.tr;
|
||||
|
||||
public class LibraryInstaller {
|
||||
|
||||
private final LibrariesIndexer indexer;
|
||||
private final DownloadableContributionsDownloader downloader;
|
||||
private final Platform platform;
|
||||
|
||||
public LibraryInstaller(LibrariesIndexer indexer, Platform platform) {
|
||||
this.indexer = indexer;
|
||||
public LibraryInstaller(Platform platform) {
|
||||
this.platform = platform;
|
||||
File stagingFolder = indexer.getStagingFolder();
|
||||
downloader = new DownloadableContributionsDownloader(stagingFolder);
|
||||
}
|
||||
|
||||
public synchronized void updateIndex(ProgressListener progressListener) throws Exception {
|
||||
final MultiStepProgress progress = new MultiStepProgress(2);
|
||||
|
||||
DownloadableContributionsDownloader downloader = new DownloadableContributionsDownloader(BaseNoGui.librariesIndexer.getStagingFolder());
|
||||
// Step 1: Download index
|
||||
File outputFile = indexer.getIndexFile();
|
||||
File outputFile = BaseNoGui.librariesIndexer.getIndexFile();
|
||||
File tmpFile = new File(outputFile.getAbsolutePath() + ".tmp");
|
||||
try {
|
||||
GZippedJsonDownloader gZippedJsonDownloader = new GZippedJsonDownloader(downloader, new URL(Constants.LIBRARY_INDEX_URL), new URL(Constants.LIBRARY_INDEX_URL_GZ));
|
||||
@ -91,6 +88,8 @@ public class LibraryInstaller {
|
||||
return;
|
||||
}
|
||||
|
||||
DownloadableContributionsDownloader downloader = new DownloadableContributionsDownloader(BaseNoGui.librariesIndexer.getStagingFolder());
|
||||
|
||||
final MultiStepProgress progress = new MultiStepProgress(3);
|
||||
|
||||
// Step 1: Download library
|
||||
@ -108,7 +107,7 @@ public class LibraryInstaller {
|
||||
// Step 2: Unpack library on the correct location
|
||||
progress.setStatus(I18n.format(tr("Installing library: {0}"), lib.getName()));
|
||||
progressListener.onProgress(progress);
|
||||
File libsFolder = indexer.getSketchbookLibrariesFolder();
|
||||
File libsFolder = BaseNoGui.librariesIndexer.getSketchbookLibrariesFolder();
|
||||
File tmpFolder = FileUtils.createTempFolder(libsFolder);
|
||||
try {
|
||||
new ArchiveExtractor(platform).extract(lib.getDownloadedFile(), tmpFolder, 1);
|
||||
@ -149,7 +148,7 @@ public class LibraryInstaller {
|
||||
private void rescanLibraryIndex(MultiStepProgress progress, ProgressListener progressListener) {
|
||||
progress.setStatus(tr("Updating list of installed libraries"));
|
||||
progressListener.onProgress(progress);
|
||||
indexer.rescanLibraries();
|
||||
BaseNoGui.librariesIndexer.rescanLibraries();
|
||||
progress.stepDone();
|
||||
}
|
||||
}
|
||||
|
@ -30,21 +30,15 @@
|
||||
package cc.arduino.contributions.libraries.filters;
|
||||
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.packages.ContributionsIndexer;
|
||||
import processing.app.BaseNoGui;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class LibraryInstalledInsideCore implements Predicate<ContributedLibrary> {
|
||||
|
||||
private final ContributionsIndexer indexer;
|
||||
|
||||
public LibraryInstalledInsideCore(ContributionsIndexer indexer) {
|
||||
this.indexer = indexer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(ContributedLibrary contributedLibrary) {
|
||||
return indexer.isFolderInsidePlatform(contributedLibrary.getInstalledFolder());
|
||||
return BaseNoGui.indexer.isFolderInsidePlatform(contributedLibrary.getInstalledFolder());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -97,4 +97,17 @@ public abstract class ContributedPlatform extends DownloadableContribution {
|
||||
public String toString() {
|
||||
return getParsedVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof ContributedPlatform)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ContributedPlatform obj1 = (ContributedPlatform) obj;
|
||||
return getParentPackage().getName().equals(obj1.getParentPackage().getName()) && getArchitecture().equals(obj1.getArchitecture()) && getVersion().equals(obj1.getVersion()) && getName().equals(obj1.getName());
|
||||
}
|
||||
}
|
||||
|
@ -37,10 +37,7 @@ import java.io.File;
|
||||
|
||||
public class ContributedTargetPlatform extends LegacyTargetPlatform {
|
||||
|
||||
public ContributedTargetPlatform(String _name, File _folder,
|
||||
TargetPackage parent,
|
||||
ContributionsIndex index)
|
||||
throws TargetPlatformException {
|
||||
public ContributedTargetPlatform(String _name, File _folder, TargetPackage parent) throws TargetPlatformException {
|
||||
super(_name, _folder, parent);
|
||||
}
|
||||
}
|
||||
|
@ -68,4 +68,16 @@ public abstract class ContributedTool {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof ContributedTool)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ContributedTool obj1 = (ContributedTool) obj;
|
||||
return getName().equals(obj1.getName()) && getVersion().equals(obj1.getVersion());
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ import cc.arduino.contributions.DownloadableContribution;
|
||||
import cc.arduino.contributions.DownloadableContributionsDownloader;
|
||||
import cc.arduino.contributions.ProgressListener;
|
||||
import cc.arduino.contributions.SignatureVerifier;
|
||||
import cc.arduino.contributions.filters.InstalledPredicate;
|
||||
import cc.arduino.filters.FileExecutablePredicate;
|
||||
import cc.arduino.utils.ArchiveExtractor;
|
||||
import cc.arduino.utils.MultiStepProgress;
|
||||
@ -41,6 +42,7 @@ import org.apache.commons.exec.CommandLine;
|
||||
import org.apache.commons.exec.DefaultExecutor;
|
||||
import org.apache.commons.exec.Executor;
|
||||
import org.apache.commons.exec.PumpStreamHandler;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.I18n;
|
||||
import processing.app.Platform;
|
||||
import processing.app.PreferencesData;
|
||||
@ -62,17 +64,12 @@ import static processing.app.I18n.tr;
|
||||
|
||||
public class ContributionInstaller {
|
||||
|
||||
private final ContributionsIndexer indexer;
|
||||
private final DownloadableContributionsDownloader downloader;
|
||||
private final Platform platform;
|
||||
private final SignatureVerifier signatureVerifier;
|
||||
|
||||
public ContributionInstaller(ContributionsIndexer contributionsIndexer, Platform platform, SignatureVerifier signatureVerifier) {
|
||||
public ContributionInstaller(Platform platform, SignatureVerifier signatureVerifier) {
|
||||
this.platform = platform;
|
||||
this.signatureVerifier = signatureVerifier;
|
||||
File stagingFolder = contributionsIndexer.getStagingFolder();
|
||||
indexer = contributionsIndexer;
|
||||
downloader = new DownloadableContributionsDownloader(stagingFolder);
|
||||
}
|
||||
|
||||
public synchronized List<String> install(ContributedPlatform contributedPlatform, ProgressListener progressListener) throws Exception {
|
||||
@ -95,6 +92,8 @@ public class ContributionInstaller {
|
||||
}
|
||||
}
|
||||
|
||||
DownloadableContributionsDownloader downloader = new DownloadableContributionsDownloader(BaseNoGui.indexer.getStagingFolder());
|
||||
|
||||
// Calculate progress increases
|
||||
MultiStepProgress progress = new MultiStepProgress((tools.size() + 1) * 2);
|
||||
|
||||
@ -118,7 +117,7 @@ public class ContributionInstaller {
|
||||
}
|
||||
|
||||
ContributedPackage pack = contributedPlatform.getParentPackage();
|
||||
File packageFolder = new File(indexer.getPackagesFolder(), pack.getName());
|
||||
File packageFolder = new File(BaseNoGui.indexer.getPackagesFolder(), pack.getName());
|
||||
|
||||
// TODO: Extract to temporary folders and move to the final destination only
|
||||
// once everything is successfully unpacked. If the operation fails remove
|
||||
@ -137,7 +136,7 @@ public class ContributionInstaller {
|
||||
i++;
|
||||
ContributedTool tool = entry.getValue();
|
||||
DownloadableContribution toolContrib = tool.getDownloadableContribution(platform);
|
||||
Path destFolder = Paths.get(indexer.getPackagesFolder().getAbsolutePath(), entry.getKey().getPackager(), "tools", tool.getName(), tool.getVersion());
|
||||
Path destFolder = Paths.get(BaseNoGui.indexer.getPackagesFolder().getAbsolutePath(), entry.getKey().getPackager(), "tools", tool.getName(), tool.getVersion());
|
||||
|
||||
Files.createDirectories(destFolder);
|
||||
assert toolContrib.getDownloadedFile() != null;
|
||||
@ -237,6 +236,7 @@ public class ContributionInstaller {
|
||||
}
|
||||
|
||||
public synchronized List<String> remove(ContributedPlatform contributedPlatform) {
|
||||
BaseNoGui.indexer.getPackages().stream().flatMap(p -> p.getPlatforms().stream()).filter(new InstalledPredicate()).peek(pl -> System.out.println(pl.getName() + " " + pl.getVersion())).collect(Collectors.toList());
|
||||
if (contributedPlatform == null || contributedPlatform.isReadOnly()) {
|
||||
return new LinkedList<>();
|
||||
}
|
||||
@ -247,13 +247,9 @@ public class ContributionInstaller {
|
||||
errors.add(tr("Error running post install script"));
|
||||
}
|
||||
|
||||
FileUtils.recursiveDelete(contributedPlatform.getInstalledFolder());
|
||||
contributedPlatform.setInstalled(false);
|
||||
contributedPlatform.setInstalledFolder(null);
|
||||
|
||||
// Check if the tools are no longer needed
|
||||
for (ContributedTool tool : contributedPlatform.getResolvedTools()) {
|
||||
if (indexer.isContributedToolUsed(tool)) {
|
||||
if (BaseNoGui.indexer.isContributedToolUsed(contributedPlatform, tool)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -273,6 +269,10 @@ public class ContributionInstaller {
|
||||
}
|
||||
}
|
||||
|
||||
FileUtils.recursiveDelete(contributedPlatform.getInstalledFolder());
|
||||
contributedPlatform.setInstalled(false);
|
||||
contributedPlatform.setInstalledFolder(null);
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
@ -324,8 +324,9 @@ public class ContributionInstaller {
|
||||
String statusText = tr("Downloading platforms index...");
|
||||
URL url = new URL(packageIndexUrl);
|
||||
String[] urlPathParts = url.getFile().split("/");
|
||||
File outputFile = indexer.getIndexFile(urlPathParts[urlPathParts.length - 1]);
|
||||
File outputFile = BaseNoGui.indexer.getIndexFile(urlPathParts[urlPathParts.length - 1]);
|
||||
File tmpFile = new File(outputFile.getAbsolutePath() + ".tmp");
|
||||
DownloadableContributionsDownloader downloader = new DownloadableContributionsDownloader(BaseNoGui.indexer.getStagingFolder());
|
||||
downloader.download(url, tmpFile, progress, statusText, progressListener);
|
||||
|
||||
Files.deleteIfExists(outputFile.toPath());
|
||||
@ -335,7 +336,7 @@ public class ContributionInstaller {
|
||||
}
|
||||
|
||||
public synchronized void deleteUnknownFiles(List<String> downloadedPackageIndexFiles) throws IOException {
|
||||
File preferencesFolder = indexer.getIndexFile(".").getParentFile();
|
||||
File preferencesFolder = BaseNoGui.indexer.getIndexFile(".").getParentFile();
|
||||
File[] additionalPackageIndexFiles = preferencesFolder.listFiles(new PackageIndexFilenameFilter(Constants.DEFAULT_INDEX_FILE_NAME));
|
||||
if (additionalPackageIndexFiles == null) {
|
||||
return;
|
||||
|
@ -310,7 +310,7 @@ public class ContributionsIndexer {
|
||||
File folder = platform.getInstalledFolder();
|
||||
|
||||
try {
|
||||
TargetPlatform targetPlatform = new ContributedTargetPlatform(arch, folder, targetPackage, index);
|
||||
TargetPlatform targetPlatform = new ContributedTargetPlatform(arch, folder, targetPackage);
|
||||
if (!targetPackage.hasPlatform(targetPlatform)) {
|
||||
targetPackage.addPlatform(targetPlatform);
|
||||
}
|
||||
@ -332,11 +332,15 @@ public class ContributionsIndexer {
|
||||
return packages;
|
||||
}
|
||||
|
||||
public boolean isContributedToolUsed(ContributedTool tool) {
|
||||
public boolean isContributedToolUsed(ContributedPlatform platformToIgnore, ContributedTool tool) {
|
||||
for (ContributedPackage pack : index.getPackages()) {
|
||||
for (ContributedPlatform platform : pack.getPlatforms()) {
|
||||
if (!platform.isInstalled())
|
||||
if (platformToIgnore.equals(platform)) {
|
||||
continue;
|
||||
}
|
||||
if (!platform.isInstalled()) {
|
||||
continue;
|
||||
}
|
||||
for (ContributedTool requiredTool : platform.getResolvedTools()) {
|
||||
if (requiredTool.equals(tool))
|
||||
return true;
|
||||
|
@ -39,8 +39,12 @@ import com.jcraft.jsch.Session;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.I18n;
|
||||
import processing.app.PreferencesData;
|
||||
import processing.app.debug.*;
|
||||
import processing.app.helpers.*;
|
||||
import processing.app.debug.RunnerException;
|
||||
import processing.app.debug.TargetPlatform;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.helpers.PreferencesMapException;
|
||||
import processing.app.helpers.StringReplacer;
|
||||
import processing.app.helpers.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -34,9 +34,9 @@
|
||||
|
||||
package cc.arduino.packages.uploaders;
|
||||
|
||||
import cc.arduino.LoadVIDPIDSpecificPreferences;
|
||||
import cc.arduino.packages.Uploader;
|
||||
import processing.app.*;
|
||||
import cc.arduino.LoadVIDPIDSpecificPreferences;
|
||||
import processing.app.debug.RunnerException;
|
||||
import processing.app.debug.TargetPlatform;
|
||||
import processing.app.helpers.OSUtils;
|
||||
|
@ -608,7 +608,7 @@ public class BaseNoGui {
|
||||
loadHardware(getSketchbookHardwareFolder());
|
||||
createToolPreferences(indexer.getInstalledTools(), true);
|
||||
|
||||
librariesIndexer = new LibrariesIndexer(BaseNoGui.getSettingsFolder(), indexer);
|
||||
librariesIndexer = new LibrariesIndexer(BaseNoGui.getSettingsFolder());
|
||||
File librariesIndexFile = librariesIndexer.getIndexFile();
|
||||
copyStockLibraryIndexIfUpstreamIsMissing(librariesIndexFile);
|
||||
try {
|
||||
|
@ -7,6 +7,8 @@ ARDUINO 1.6.7
|
||||
* Added support to file:// protocol for boards manager URLs
|
||||
* Portable sketchbook folder can now be any arbitrary location
|
||||
* Fixed a bug that caused Boards Manager to install the same tool twice or more, thus wasting disk space, if other cores where using tools delivered by arduino
|
||||
* Fixed various Boards manager glitches, in particular when removing a board
|
||||
* Windows: Arduino IDE icon is now in high definition, bye bye that blurry icon
|
||||
|
||||
[libraries]
|
||||
* SPI: Added SPI.transfer16(...) function to SAM core.
|
||||
|
Loading…
x
Reference in New Issue
Block a user