From 310a5df5e1462dfbace92e2d8a581bb2d18b6cd1 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 28 Feb 2020 13:08:00 +0100 Subject: [PATCH] Rename ContributeLibrary and ContributeLibraryReleases the classes have been renamed as: ContributedLibrary -> ContributedLibraryRelease ContributedLibraryReleases -> ContributedLibrary The reason is that a ContributedLibrary will have a name and a list of releases, each one containing the relative metadata. The changes to reflect that will be made in the next commits. --- .../filters/UpdatableLibraryPredicate.java | 10 +- .../ContributedLibraryReleasesComparator.java | 12 +- .../ui/ContributedLibraryTableCellEditor.java | 26 +- .../ui/ContributedLibraryTableCellJPanel.java | 8 +- .../libraries/ui/DropdownAllLibraries.java | 6 +- .../ui/DropdownInstalledLibraryItem.java | 10 +- .../ui/DropdownLibraryOfCategoryItem.java | 12 +- .../ui/DropdownLibraryOfTypeItem.java | 10 +- .../ui/DropdownUpdatableLibrariesItem.java | 12 +- .../ui/LibrariesIndexTableModel.java | 36 +-- .../libraries/ui/LibraryManagerUI.java | 16 +- .../ui/MultiLibraryInstallDialog.java | 8 +- app/src/processing/app/Base.java | 8 +- .../contributions/UpdatableLibraryTest.java | 6 +- .../contributions/VersionComparator.java | 8 +- .../libraries/ContributedLibrary.java | 232 +++++------------- .../libraries/ContributedLibraryRelease.java | 223 +++++++++++++++++ .../libraries/ContributedLibraryReleases.java | 109 -------- .../libraries/LibrariesIndex.java | 38 +-- .../libraries/LibrariesIndexer.java | 4 +- .../libraries/LibraryInstaller.java | 14 +- .../UnavailableContributedLibrary.java | 2 +- 22 files changed, 405 insertions(+), 405 deletions(-) create mode 100644 arduino-core/src/cc/arduino/contributions/libraries/ContributedLibraryRelease.java delete mode 100644 arduino-core/src/cc/arduino/contributions/libraries/ContributedLibraryReleases.java diff --git a/app/src/cc/arduino/contributions/libraries/filters/UpdatableLibraryPredicate.java b/app/src/cc/arduino/contributions/libraries/filters/UpdatableLibraryPredicate.java index e96f17594..de254f734 100644 --- a/app/src/cc/arduino/contributions/libraries/filters/UpdatableLibraryPredicate.java +++ b/app/src/cc/arduino/contributions/libraries/filters/UpdatableLibraryPredicate.java @@ -33,11 +33,11 @@ import java.util.List; import java.util.function.Predicate; import cc.arduino.contributions.VersionComparator; -import cc.arduino.contributions.libraries.ContributedLibrary; +import cc.arduino.contributions.libraries.ContributedLibraryRelease; import cc.arduino.contributions.libraries.LibrariesIndexer; import processing.app.BaseNoGui; -public class UpdatableLibraryPredicate implements Predicate { +public class UpdatableLibraryPredicate implements Predicate { LibrariesIndexer librariesIndexer; @@ -50,13 +50,13 @@ public class UpdatableLibraryPredicate implements Predicate } @Override - public boolean test(ContributedLibrary lib) { + public boolean test(ContributedLibraryRelease lib) { if (!lib.isLibraryInstalled()) { return false; } String libraryName = lib.getName(); - List libraries = librariesIndexer.getIndex().find(libraryName); - ContributedLibrary latest = libraries.stream().reduce(VersionComparator::max).get(); + List libraries = librariesIndexer.getIndex().find(libraryName); + ContributedLibraryRelease latest = libraries.stream().reduce(VersionComparator::max).get(); return !latest.isLibraryInstalled(); } } diff --git a/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryReleasesComparator.java b/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryReleasesComparator.java index 11436b2cc..380892f13 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryReleasesComparator.java +++ b/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryReleasesComparator.java @@ -29,14 +29,14 @@ package cc.arduino.contributions.libraries.ui; +import cc.arduino.contributions.libraries.ContributedLibraryRelease; import cc.arduino.contributions.libraries.ContributedLibrary; -import cc.arduino.contributions.libraries.ContributedLibraryReleases; import java.util.Arrays; import java.util.Comparator; import java.util.List; -public class ContributedLibraryReleasesComparator implements Comparator { +public class ContributedLibraryReleasesComparator implements Comparator { private final String firstType; @@ -45,9 +45,9 @@ public class ContributedLibraryReleasesComparator implements Comparator types1 = lib1.getTypes(); List types2 = lib2.getTypes(); @@ -66,7 +66,7 @@ public class ContributedLibraryReleasesComparator implements Comparator { JComboBox chooser = editorCell.downgradeChooser; - ContributedLibrary lib = (ContributedLibrary) chooser.getSelectedItem(); + ContributedLibraryRelease lib = (ContributedLibraryRelease) chooser.getSelectedItem(); onInstall(lib, editorValue.getInstalled()); }); editorCell.versionToInstallChooser.addActionListener(e -> { - editorValue.select((ContributedLibrary) editorCell.versionToInstallChooser.getSelectedItem()); + editorValue.select((ContributedLibraryRelease) editorCell.versionToInstallChooser.getSelectedItem()); if (editorCell.versionToInstallChooser.getSelectedIndex() != 0) { InstallerTableCell.dropdownSelected(true); } @@ -83,10 +83,10 @@ public class ContributedLibraryTableCellEditor extends InstallerTableCell { setEnabled(true); - final Optional mayInstalled = editorValue.getInstalled(); + final Optional mayInstalled = editorValue.getInstalled(); - List releases = editorValue.getReleases(); - List notInstalled = new LinkedList<>(releases); + List releases = editorValue.getReleases(); + List notInstalled = new LinkedList<>(releases); if (mayInstalled.isPresent()) { notInstalled.remove(editorValue.getInstalled().get()); } @@ -97,8 +97,8 @@ public class ContributedLibraryTableCellEditor extends InstallerTableCell { editorCell.downgradeChooser.removeAllItems(); editorCell.downgradeChooser.addItem(tr("Select version")); - final List notInstalledPrevious = new LinkedList<>(); - final List notInstalledNewer = new LinkedList<>(); + final List notInstalledPrevious = new LinkedList<>(); + final List notInstalledNewer = new LinkedList<>(); notInstalled.stream().forEach(input -> { if (!mayInstalled.isPresent() @@ -139,12 +139,12 @@ public class ContributedLibraryTableCellEditor extends InstallerTableCell { editorCell.statusLabel.setText(status); } - protected void onRemove(ContributedLibrary selected) { + protected void onRemove(ContributedLibraryRelease selected) { // Empty } - protected void onInstall(ContributedLibrary selected, - Optional mayInstalled) { + protected void onInstall(ContributedLibraryRelease selected, + Optional mayInstalled) { // Empty } diff --git a/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellJPanel.java b/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellJPanel.java index 4f8c15f56..c822a1d00 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellJPanel.java +++ b/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellJPanel.java @@ -15,8 +15,8 @@ import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.StyleSheet; import cc.arduino.contributions.DownloadableContributionVersionComparator; +import cc.arduino.contributions.libraries.ContributedLibraryRelease; import cc.arduino.contributions.libraries.ContributedLibrary; -import cc.arduino.contributions.libraries.ContributedLibraryReleases; import cc.arduino.contributions.ui.InstallerTableCell; import processing.app.Base; import processing.app.PreferencesData; @@ -119,15 +119,15 @@ public class ContributedLibraryTableCellJPanel extends JPanel { add(Box.createVerticalStrut(15)); - ContributedLibraryReleases releases = (ContributedLibraryReleases) value; + ContributedLibrary releases = (ContributedLibrary) value; // FIXME: happens on macosx, don't know why if (releases == null) return; - ContributedLibrary selected = releases.getSelected(); + ContributedLibraryRelease selected = releases.getSelected(); titledBorder.setTitle(selected.getName()); - Optional mayInstalled = releases.getInstalled(); + Optional mayInstalled = releases.getInstalled(); boolean installable, upgradable; if (!mayInstalled.isPresent()) { diff --git a/app/src/cc/arduino/contributions/libraries/ui/DropdownAllLibraries.java b/app/src/cc/arduino/contributions/libraries/ui/DropdownAllLibraries.java index ce50aca14..c68fc8fd6 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/DropdownAllLibraries.java +++ b/app/src/cc/arduino/contributions/libraries/ui/DropdownAllLibraries.java @@ -29,21 +29,21 @@ package cc.arduino.contributions.libraries.ui; -import cc.arduino.contributions.libraries.ContributedLibraryReleases; +import cc.arduino.contributions.libraries.ContributedLibrary; import cc.arduino.contributions.ui.DropdownItem; import java.util.function.Predicate; import static processing.app.I18n.tr; -public class DropdownAllLibraries implements DropdownItem { +public class DropdownAllLibraries implements DropdownItem { public String toString() { return tr("All"); } @Override - public Predicate getFilterPredicate() { + public Predicate getFilterPredicate() { return x -> true; } diff --git a/app/src/cc/arduino/contributions/libraries/ui/DropdownInstalledLibraryItem.java b/app/src/cc/arduino/contributions/libraries/ui/DropdownInstalledLibraryItem.java index e5b42e3b3..fc9ea338a 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/DropdownInstalledLibraryItem.java +++ b/app/src/cc/arduino/contributions/libraries/ui/DropdownInstalledLibraryItem.java @@ -33,20 +33,20 @@ import static processing.app.I18n.tr; import java.util.function.Predicate; -import cc.arduino.contributions.libraries.ContributedLibraryReleases; +import cc.arduino.contributions.libraries.ContributedLibrary; import cc.arduino.contributions.ui.DropdownItem; -public class DropdownInstalledLibraryItem implements DropdownItem { +public class DropdownInstalledLibraryItem implements DropdownItem { public String toString() { return tr("Installed"); } @Override - public Predicate getFilterPredicate() { - return new Predicate() { + public Predicate getFilterPredicate() { + return new Predicate() { @Override - public boolean test(ContributedLibraryReleases t) { + public boolean test(ContributedLibrary t) { return t.getInstalled().isPresent(); } }; diff --git a/app/src/cc/arduino/contributions/libraries/ui/DropdownLibraryOfCategoryItem.java b/app/src/cc/arduino/contributions/libraries/ui/DropdownLibraryOfCategoryItem.java index 0d07b3ccf..b980b360f 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/DropdownLibraryOfCategoryItem.java +++ b/app/src/cc/arduino/contributions/libraries/ui/DropdownLibraryOfCategoryItem.java @@ -29,15 +29,15 @@ package cc.arduino.contributions.libraries.ui; +import cc.arduino.contributions.libraries.ContributedLibraryRelease; import cc.arduino.contributions.libraries.ContributedLibrary; -import cc.arduino.contributions.libraries.ContributedLibraryReleases; import cc.arduino.contributions.ui.DropdownItem; import java.util.function.Predicate; import static processing.app.I18n.tr; -public class DropdownLibraryOfCategoryItem implements DropdownItem { +public class DropdownLibraryOfCategoryItem implements DropdownItem { private final String category; @@ -50,11 +50,11 @@ public class DropdownLibraryOfCategoryItem implements DropdownItem getFilterPredicate() { - return new Predicate() { + public Predicate getFilterPredicate() { + return new Predicate() { @Override - public boolean test(ContributedLibraryReleases rel) { - ContributedLibrary lib = rel.getLatest(); + public boolean test(ContributedLibrary rel) { + ContributedLibraryRelease lib = rel.getLatest(); return category.equals(lib.getCategory()); } }; diff --git a/app/src/cc/arduino/contributions/libraries/ui/DropdownLibraryOfTypeItem.java b/app/src/cc/arduino/contributions/libraries/ui/DropdownLibraryOfTypeItem.java index 28f44a018..2b9b0644f 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/DropdownLibraryOfTypeItem.java +++ b/app/src/cc/arduino/contributions/libraries/ui/DropdownLibraryOfTypeItem.java @@ -29,7 +29,7 @@ package cc.arduino.contributions.libraries.ui; -import cc.arduino.contributions.libraries.ContributedLibraryReleases; +import cc.arduino.contributions.libraries.ContributedLibrary; import cc.arduino.contributions.ui.DropdownItem; import java.util.List; @@ -37,7 +37,7 @@ import java.util.function.Predicate; import static processing.app.I18n.tr; -public class DropdownLibraryOfTypeItem implements DropdownItem { +public class DropdownLibraryOfTypeItem implements DropdownItem { private final String type; @@ -50,10 +50,10 @@ public class DropdownLibraryOfTypeItem implements DropdownItem getFilterPredicate() { - return new Predicate() { + public Predicate getFilterPredicate() { + return new Predicate() { @Override - public boolean test(ContributedLibraryReleases lib) { + public boolean test(ContributedLibrary lib) { List types = lib.getLatest().getTypes(); return types != null && types.contains(type); } diff --git a/app/src/cc/arduino/contributions/libraries/ui/DropdownUpdatableLibrariesItem.java b/app/src/cc/arduino/contributions/libraries/ui/DropdownUpdatableLibrariesItem.java index 2c75498f8..09355080e 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/DropdownUpdatableLibrariesItem.java +++ b/app/src/cc/arduino/contributions/libraries/ui/DropdownUpdatableLibrariesItem.java @@ -29,8 +29,8 @@ package cc.arduino.contributions.libraries.ui; +import cc.arduino.contributions.libraries.ContributedLibraryRelease; import cc.arduino.contributions.libraries.ContributedLibrary; -import cc.arduino.contributions.libraries.ContributedLibraryReleases; import cc.arduino.contributions.ui.DropdownItem; import java.util.Optional; @@ -38,14 +38,14 @@ import java.util.function.Predicate; import static processing.app.I18n.tr; -public class DropdownUpdatableLibrariesItem implements DropdownItem { +public class DropdownUpdatableLibrariesItem implements DropdownItem { @Override - public Predicate getFilterPredicate() { - return new Predicate() { + public Predicate getFilterPredicate() { + return new Predicate() { @Override - public boolean test(ContributedLibraryReleases lib) { - Optional mayInstalled = lib.getInstalled(); + public boolean test(ContributedLibrary lib) { + Optional mayInstalled = lib.getInstalled(); if (!mayInstalled.isPresent()) { return false; } diff --git a/app/src/cc/arduino/contributions/libraries/ui/LibrariesIndexTableModel.java b/app/src/cc/arduino/contributions/libraries/ui/LibrariesIndexTableModel.java index ceed4562f..60020a054 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/LibrariesIndexTableModel.java +++ b/app/src/cc/arduino/contributions/libraries/ui/LibrariesIndexTableModel.java @@ -29,8 +29,8 @@ package cc.arduino.contributions.libraries.ui; +import cc.arduino.contributions.libraries.ContributedLibraryRelease; import cc.arduino.contributions.libraries.ContributedLibrary; -import cc.arduino.contributions.libraries.ContributedLibraryReleases; import cc.arduino.contributions.packages.ContributedPlatform; import cc.arduino.contributions.ui.FilteredAbstractTableModel; import processing.app.BaseNoGui; @@ -42,19 +42,19 @@ import java.util.function.Predicate; @SuppressWarnings("serial") public class LibrariesIndexTableModel - extends FilteredAbstractTableModel { + extends FilteredAbstractTableModel { - private final List contributions = new ArrayList<>(); + private final List contributions = new ArrayList<>(); private final String[] columnNames = { "Description" }; private final Class[] columnTypes = { ContributedPlatform.class }; - Predicate selectedCategoryFilter = null; + Predicate selectedCategoryFilter = null; String selectedFilters[] = null; public void updateIndexFilter(String filters[], - Predicate additionalFilter) { + Predicate additionalFilter) { selectedCategoryFilter = additionalFilter; selectedFilters = filters; update(); @@ -117,7 +117,7 @@ public class LibrariesIndexTableModel if (row >= contributions.size()) { return null; } - ContributedLibraryReleases contribution = contributions.get(row); + ContributedLibrary contribution = contributions.get(row); return contribution;// .getSelected(); } @@ -126,11 +126,11 @@ public class LibrariesIndexTableModel return true; } - public ContributedLibraryReleases getReleases(int row) { + public ContributedLibrary getReleases(int row) { return contributions.get(row); } - public ContributedLibrary getSelectedRelease(int row) { + public ContributedLibraryRelease getSelectedRelease(int row) { return contributions.get(row).getSelected(); } @@ -139,12 +139,12 @@ public class LibrariesIndexTableModel fireTableDataChanged(); } - private boolean filterCondition(ContributedLibraryReleases lib) { + private boolean filterCondition(ContributedLibrary lib) { if (selectedCategoryFilter != null && !selectedCategoryFilter.test(lib)) { return false; } - ContributedLibrary latest = lib.getLatest(); + ContributedLibraryRelease latest = lib.getLatest(); String compoundTargetSearchText = latest.getName() + " " + latest.getParagraph() + " " + latest.getSentence(); @@ -158,10 +158,10 @@ public class LibrariesIndexTableModel return true; } - public void updateLibrary(ContributedLibrary lib) { + public void updateLibrary(ContributedLibraryRelease lib) { // Find the row interested in the change int row = -1; - for (ContributedLibraryReleases releases : contributions) { + for (ContributedLibrary releases : contributions) { if (releases.shouldContain(lib)) row = contributions.indexOf(releases); } @@ -170,7 +170,7 @@ public class LibrariesIndexTableModel // If the library is found in the list send update event // or insert event on the specific row... - for (ContributedLibraryReleases releases : contributions) { + for (ContributedLibrary releases : contributions) { if (releases.shouldContain(lib)) { if (row == -1) { row = contributions.indexOf(releases); @@ -185,24 +185,24 @@ public class LibrariesIndexTableModel fireTableRowsDeleted(row, row); } - private List rebuildContributionsFromIndex() { - List res = new ArrayList<>(); + private List rebuildContributionsFromIndex() { + List res = new ArrayList<>(); BaseNoGui.librariesIndexer.getIndex().getLibraries(). // forEach(lib -> { - for (ContributedLibraryReleases contribution : res) { + for (ContributedLibrary contribution : res) { if (!contribution.shouldContain(lib)) continue; contribution.add(lib); return; } - res.add(new ContributedLibraryReleases(lib)); + res.add(new ContributedLibrary(lib)); }); return res; } private void updateContributions() { - List all = rebuildContributionsFromIndex(); + List all = rebuildContributionsFromIndex(); contributions.clear(); all.stream().filter(this::filterCondition).forEach(contributions::add); Collections.sort(contributions, diff --git a/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java b/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java index 69ab10006..2ddbe1ada 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java +++ b/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java @@ -48,8 +48,8 @@ import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.table.TableCellRenderer; +import cc.arduino.contributions.libraries.ContributedLibraryRelease; import cc.arduino.contributions.libraries.ContributedLibrary; -import cc.arduino.contributions.libraries.ContributedLibraryReleases; import cc.arduino.contributions.libraries.LibraryInstaller; import cc.arduino.contributions.libraries.LibraryTypeComparator; import cc.arduino.contributions.libraries.ui.MultiLibraryInstallDialog.Result; @@ -62,7 +62,7 @@ import cc.arduino.utils.Progress; import processing.app.BaseNoGui; @SuppressWarnings("serial") -public class LibraryManagerUI extends InstallerJDialog { +public class LibraryManagerUI extends InstallerJDialog { private final JComboBox typeChooser; private final LibraryInstaller installer; @@ -85,7 +85,7 @@ public class LibraryManagerUI extends InstallerJDialog mayInstalledLibrary) { + protected void onInstall(ContributedLibraryRelease selectedLibrary, Optional mayInstalledLibrary) { if (mayInstalledLibrary.isPresent() && selectedLibrary.isIDEBuiltIn()) { onRemovePressed(mayInstalledLibrary.get()); } else { @@ -94,7 +94,7 @@ public class LibraryManagerUI extends InstallerJDialog selected = (DropdownItem) typeChooser.getSelectedItem(); + DropdownItem selected = (DropdownItem) typeChooser.getSelectedItem(); previousRowAtPoint = -1; if (selected != null && extraFilter != selected.getFilterPredicate()) { extraFilter = selected.getFilterPredicate(); @@ -217,8 +217,8 @@ public class LibraryManagerUI extends InstallerJDialog deps = BaseNoGui.librariesIndexer.getIndex().resolveDependeciesOf(lib); + public void onInstallPressed(final ContributedLibraryRelease lib) { + List deps = BaseNoGui.librariesIndexer.getIndex().resolveDependeciesOf(lib); boolean depsInstalled = deps.stream().allMatch(l -> l.getInstalledLibrary().isPresent() || l.getName().equals(lib.getName())); Result installDeps; if (!depsInstalled) { @@ -257,7 +257,7 @@ public class LibraryManagerUI extends InstallerJDialog dependencies) { + public MultiLibraryInstallDialog(Window parent, ContributedLibraryRelease lib, + List dependencies) { super(parent, format(tr("Dependencies for library {0}:{1}"), lib.getName(), lib.getParsedVersion()), ModalityType.APPLICATION_MODAL); @@ -115,7 +115,7 @@ public class MultiLibraryInstallDialog extends JDialog { String desc = format(tr("The library {0} needs some other library
dependencies currently not installed:"), libName); desc += "

"; - for (ContributedLibrary l : dependencies) { + for (ContributedLibraryRelease l : dependencies) { if (l.getName().equals(lib.getName())) continue; if (l.getInstalledLibrary().isPresent()) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index ef2d19770..a6f73bec8 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -27,7 +27,7 @@ import cc.arduino.Constants; import cc.arduino.UpdatableBoardsLibsFakeURLsHandler; import cc.arduino.UploaderUtils; import cc.arduino.contributions.*; -import cc.arduino.contributions.libraries.ContributedLibrary; +import cc.arduino.contributions.libraries.ContributedLibraryRelease; import cc.arduino.contributions.libraries.LibrariesIndexer; import cc.arduino.contributions.libraries.LibraryInstaller; import cc.arduino.contributions.libraries.LibraryOfSameTypeComparator; @@ -368,7 +368,7 @@ public class Base { for (String library : parser.getLibraryToInstall().split(",")) { String[] libraryToInstallParts = library.split(":"); - ContributedLibrary selected = null; + ContributedLibraryRelease selected = null; if (libraryToInstallParts.length == 2) { Optional version = VersionHelper.valueOf(libraryToInstallParts[1]); if (!version.isPresent()) { @@ -377,7 +377,7 @@ public class Base { } selected = indexer.getIndex().find(libraryToInstallParts[0], version.get().toString()); } else if (libraryToInstallParts.length == 1) { - List librariesByName = indexer.getIndex().find(libraryToInstallParts[0]); + List librariesByName = indexer.getIndex().find(libraryToInstallParts[0]); Collections.sort(librariesByName, new DownloadableContributionVersionComparator()); if (!librariesByName.isEmpty()) { selected = librariesByName.get(librariesByName.size() - 1); @@ -388,7 +388,7 @@ public class Base { System.exit(1); } - Optional mayInstalled = indexer.getIndex().getInstalled(libraryToInstallParts[0]); + Optional mayInstalled = indexer.getIndex().getInstalled(libraryToInstallParts[0]); if (mayInstalled.isPresent() && selected.isIDEBuiltIn()) { System.out.println(tr(I18n .format("Library {0} is available as built-in in the IDE.\nRemoving the other version {1} installed in the sketchbook...", diff --git a/app/test/cc/arduino/contributions/UpdatableLibraryTest.java b/app/test/cc/arduino/contributions/UpdatableLibraryTest.java index 0dab3531c..f2434bb4f 100644 --- a/app/test/cc/arduino/contributions/UpdatableLibraryTest.java +++ b/app/test/cc/arduino/contributions/UpdatableLibraryTest.java @@ -10,7 +10,7 @@ import java.util.List; import org.junit.Test; -import cc.arduino.contributions.libraries.ContributedLibrary; +import cc.arduino.contributions.libraries.ContributedLibraryRelease; import cc.arduino.contributions.libraries.LibrariesIndexer; import processing.app.BaseNoGui; import processing.app.packages.UserLibraryFolder; @@ -38,7 +38,7 @@ public class UpdatableLibraryTest { indexer.parseIndex(); indexer.setLibrariesFoldersAndRescan(folders); - ContributedLibrary sdLib = indexer.getIndex().getInstalled("SD").get(); + ContributedLibraryRelease sdLib = indexer.getIndex().getInstalled("SD").get(); assertTrue("SD lib is installed", sdLib.isLibraryInstalled()); assertEquals("SD installed version", "1.1.1", sdLib.getParsedVersion()); @@ -64,7 +64,7 @@ public class UpdatableLibraryTest { indexer.parseIndex(); indexer.setLibrariesFoldersAndRescan(folders); - ContributedLibrary l = indexer.getIndex().getInstalled("Bridge").get(); + ContributedLibraryRelease l = indexer.getIndex().getInstalled("Bridge").get(); assertTrue("Bridge lib is installed", l.isLibraryInstalled()); assertEquals("Bridge installed version", "1.6.3", l.getParsedVersion()); diff --git a/arduino-core/src/cc/arduino/contributions/VersionComparator.java b/arduino-core/src/cc/arduino/contributions/VersionComparator.java index af6a1fdb3..cf76c8433 100644 --- a/arduino-core/src/cc/arduino/contributions/VersionComparator.java +++ b/arduino-core/src/cc/arduino/contributions/VersionComparator.java @@ -31,7 +31,7 @@ package cc.arduino.contributions; import com.github.zafarkhaja.semver.Version; -import cc.arduino.contributions.libraries.ContributedLibrary; +import cc.arduino.contributions.libraries.ContributedLibraryRelease; import java.util.Comparator; import java.util.Optional; @@ -70,15 +70,15 @@ public class VersionComparator implements Comparator { return greaterThan(a, b) ? a : b; } - public static ContributedLibrary max(ContributedLibrary a, ContributedLibrary b) { + public static ContributedLibraryRelease max(ContributedLibraryRelease a, ContributedLibraryRelease b) { return greaterThan(a, b) ? a : b; } - public static boolean greaterThan(ContributedLibrary a, ContributedLibrary b) { + public static boolean greaterThan(ContributedLibraryRelease a, ContributedLibraryRelease b) { return greaterThan(a.getParsedVersion(), b.getParsedVersion()); } - public static int compareTo(ContributedLibrary a, ContributedLibrary b) { + public static int compareTo(ContributedLibraryRelease a, ContributedLibraryRelease b) { return compareTo(a.getParsedVersion(), b.getParsedVersion()); } } diff --git a/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibrary.java b/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibrary.java index 603b46909..3dd5f8fd9 100644 --- a/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibrary.java +++ b/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibrary.java @@ -1,7 +1,7 @@ /* * This file is part of Arduino. * - * Copyright 2014 Arduino LLC (http://www.arduino.cc/) + * Copyright 2015 Arduino LLC (http://www.arduino.cc/) * * Arduino is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,195 +29,81 @@ package cc.arduino.contributions.libraries; -import cc.arduino.contributions.DownloadableContribution; -import processing.app.I18n; -import processing.app.packages.UserLibrary; -import static processing.app.I18n.tr; +import cc.arduino.contributions.VersionComparator; +import processing.app.packages.UserLibraryFolder.Location; -import java.util.Comparator; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.Optional; -import cc.arduino.contributions.VersionHelper; +public class ContributedLibrary { -public class ContributedLibrary extends DownloadableContribution { + private List releases = new LinkedList<>(); + private List versions = new LinkedList<>(); + private ContributedLibraryRelease latest = null; + private ContributedLibraryRelease selected = null; - private String url; - private String version; - private String checksum; - private long size; - private String archiveFileName; - private String name; - private String maintainer; - private String author; - private String website; - private String category; - private String licence; - private String paragraph; - private String sentence; - private ArrayList architectures; - private ArrayList types; - private ArrayList dependencies; - private ArrayList providesIncludes; - - public String getUrl() { return url; } - - public String getVersion() { return version; } - - public String getChecksum() { return checksum; } - - public long getSize() { return size; } - - public String getArchiveFileName() { return archiveFileName; } - - public String getName() { return name; } - - public String getMaintainer() { return maintainer; } - - public String getAuthor() { return author; } - - public String getWebsite() { return website; } - - public String getCategory() { return category; } - - public void setCategory(String category) { this.category = category; } - - public String getLicense() { return licence; } - - public String getParagraph() { return paragraph; } - - public String getSentence() { return sentence; } - - public List getArchitectures() { return architectures; } - - public List getTypes() { return types; } - - public List getDependencies() { return dependencies; } - - public List getProvidesIncludes() { return providesIncludes; } - - public static final Comparator CASE_INSENSITIVE_ORDER = (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()); - - private Optional installedLib = Optional.empty(); - - public Optional getInstalledLibrary() { - return installedLib; + public ContributedLibrary(ContributedLibraryRelease release) { + add(release); } - public boolean isLibraryInstalled() { - return installedLib.isPresent(); + public ContributedLibrary(List releases) { + releases.forEach(this::add); } - public void setInstalledUserLibrary(UserLibrary installed) { - this.installedLib = Optional.of(installed); + public List getReleases() { + return releases; } - public void unsetInstalledUserLibrary() { - installedLib = Optional.empty(); - } - - public boolean isIDEBuiltIn() { - if (!installedLib.isPresent()) { - return false; - } - return installedLib.get().isIDEBuiltIn(); - } - - /** - * Returns true if the library declares to support the specified - * architecture (through the "architectures" property field). - * - * @param reqArch - * @return - */ - public boolean supportsArchitecture(String reqArch) { - return getArchitectures().contains(reqArch) || getArchitectures().contains("*"); - } - - /** - * Returns true if the library declares to support at least one of the - * specified architectures. - * - * @param reqArchs A List of architectures to check - * @return - */ - public boolean supportsArchitecture(List reqArchs) { - if (reqArchs.contains("*")) + public boolean shouldContain(ContributedLibraryRelease release) { + if (latest == null) { return true; - for (String reqArch : reqArchs) - if (supportsArchitecture(reqArch)) - return true; - return false; - } - - @Override - public String toString() { - return I18n.format(tr("Version {0}"), getParsedVersion()); - } - - public String info() { - String res = ""; - res += " ContributedLibrary : " + getName() + "\n"; - res += " author : " + getAuthor() + "\n"; - res += " maintainer : " + getMaintainer() + "\n"; - res += " version : " + getParsedVersion() + "\n"; - res += " website : " + getUrl() + "\n"; - res += " category : " + getCategory() + "\n"; - res += " license : " + getLicense() + "\n"; - res += " descrip : " + getSentence() + "\n"; - if (getParagraph() != null && !getParagraph().isEmpty()) - res += " " + getParagraph() + "\n"; - res += " architectures : "; - if (getArchitectures() != null) - for (String a : getArchitectures()) { - res += a + ","; - } - res += "\n"; - res += " requires :\n"; - if (getDependencies() != null) - for (ContributedLibraryDependency r : getDependencies()) { - res += " " + r; - } - res += "\n"; - - // DownloadableContribution - res += super.toString(); - - return res; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof ContributedLibrary)) { - return false; } - ContributedLibrary other = (ContributedLibrary) obj; - String thisVersion = getParsedVersion(); - String otherVersion = other.getParsedVersion(); - - boolean versionEquals = (thisVersion != null - && thisVersion.equals(otherVersion)); - - // Important: for legacy libs, versions are null. Two legacy libs must - // always pass this test. - if (thisVersion == null && otherVersion == null) - versionEquals = true; - - String thisName = getName(); - String otherName = other.getName(); - boolean nameEquals = thisName != null && thisName.equals(otherName); - - return versionEquals && nameEquals; + return release.getName().equals(latest.getName()); } - public boolean isBefore(ContributedLibrary other) { - return VersionHelper.compare(getVersion(), other.getVersion()) < 0; + public void add(ContributedLibraryRelease release) { + if (latest == null) { + latest = release; + } + releases.add(release); + String version = release.getParsedVersion(); + if (version != null) { + versions.add(version); + } + if (VersionComparator.greaterThan(version, latest.getParsedVersion())) { + latest = release; + } + selected = latest; } - @Override - public int hashCode() { - String hashingData = "CONTRIBUTEDLIB" + getName() + getVersion(); - return hashingData.hashCode(); + public Optional getInstalled() { + return releases.stream() // + .filter(ContributedLibraryRelease::isLibraryInstalled) // + .reduce((x, y) -> { + Location lx = x.getInstalledLibrary().get().getLocation(); + Location ly = y.getInstalledLibrary().get().getLocation(); + if (lx == ly) { + return VersionComparator.max(x, y); + } + return lx == Location.SKETCHBOOK ? x : y; + }); + } + + public ContributedLibraryRelease getLatest() { + return latest; + } + + public ContributedLibraryRelease getSelected() { + return selected; + } + + public void select(ContributedLibraryRelease lib) { + for (ContributedLibraryRelease r : releases) { + if (r == lib) { + selected = r; + return; + } + } } } diff --git a/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibraryRelease.java b/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibraryRelease.java new file mode 100644 index 000000000..719edd1f5 --- /dev/null +++ b/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibraryRelease.java @@ -0,0 +1,223 @@ +/* + * This file is part of Arduino. + * + * Copyright 2014 Arduino LLC (http://www.arduino.cc/) + * + * Arduino is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As a special exception, you may use this file as part of a free software + * library without restriction. Specifically, if other files instantiate + * templates or use macros or inline functions from this file, or you compile + * this file and link it with other files to produce an executable, this + * file does not by itself cause the resulting executable to be covered by + * the GNU General Public License. This exception does not however + * invalidate any other reasons why the executable file might be covered by + * the GNU General Public License. + */ + +package cc.arduino.contributions.libraries; + +import cc.arduino.contributions.DownloadableContribution; +import processing.app.I18n; +import processing.app.packages.UserLibrary; +import static processing.app.I18n.tr; + +import java.util.Comparator; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import cc.arduino.contributions.VersionHelper; + +public class ContributedLibraryRelease extends DownloadableContribution { + + private String url; + private String version; + private String checksum; + private long size; + private String archiveFileName; + private String name; + private String maintainer; + private String author; + private String website; + private String category; + private String licence; + private String paragraph; + private String sentence; + private ArrayList architectures; + private ArrayList types; + private ArrayList dependencies; + private ArrayList providesIncludes; + + public String getUrl() { return url; } + + public String getVersion() { return version; } + + public String getChecksum() { return checksum; } + + public long getSize() { return size; } + + public String getArchiveFileName() { return archiveFileName; } + + public String getName() { return name; } + + public String getMaintainer() { return maintainer; } + + public String getAuthor() { return author; } + + public String getWebsite() { return website; } + + public String getCategory() { return category; } + + public void setCategory(String category) { this.category = category; } + + public String getLicense() { return licence; } + + public String getParagraph() { return paragraph; } + + public String getSentence() { return sentence; } + + public List getArchitectures() { return architectures; } + + public List getTypes() { return types; } + + public List getDependencies() { return dependencies; } + + public List getProvidesIncludes() { return providesIncludes; } + + public static final Comparator CASE_INSENSITIVE_ORDER = (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()); + + private Optional installedLib = Optional.empty(); + + public Optional getInstalledLibrary() { + return installedLib; + } + + public boolean isLibraryInstalled() { + return installedLib.isPresent(); + } + + public void setInstalledUserLibrary(UserLibrary installed) { + this.installedLib = Optional.of(installed); + } + + public void unsetInstalledUserLibrary() { + installedLib = Optional.empty(); + } + + public boolean isIDEBuiltIn() { + if (!installedLib.isPresent()) { + return false; + } + return installedLib.get().isIDEBuiltIn(); + } + + /** + * Returns true if the library declares to support the specified + * architecture (through the "architectures" property field). + * + * @param reqArch + * @return + */ + public boolean supportsArchitecture(String reqArch) { + return getArchitectures().contains(reqArch) || getArchitectures().contains("*"); + } + + /** + * Returns true if the library declares to support at least one of the + * specified architectures. + * + * @param reqArchs A List of architectures to check + * @return + */ + public boolean supportsArchitecture(List reqArchs) { + if (reqArchs.contains("*")) + return true; + for (String reqArch : reqArchs) + if (supportsArchitecture(reqArch)) + return true; + return false; + } + + @Override + public String toString() { + return I18n.format(tr("Version {0}"), getParsedVersion()); + } + + public String info() { + String res = ""; + res += " ContributedLibrary : " + getName() + "\n"; + res += " author : " + getAuthor() + "\n"; + res += " maintainer : " + getMaintainer() + "\n"; + res += " version : " + getParsedVersion() + "\n"; + res += " website : " + getUrl() + "\n"; + res += " category : " + getCategory() + "\n"; + res += " license : " + getLicense() + "\n"; + res += " descrip : " + getSentence() + "\n"; + if (getParagraph() != null && !getParagraph().isEmpty()) + res += " " + getParagraph() + "\n"; + res += " architectures : "; + if (getArchitectures() != null) + for (String a : getArchitectures()) { + res += a + ","; + } + res += "\n"; + res += " requires :\n"; + if (getDependencies() != null) + for (ContributedLibraryDependency r : getDependencies()) { + res += " " + r; + } + res += "\n"; + + // DownloadableContribution + res += super.toString(); + + return res; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ContributedLibraryRelease)) { + return false; + } + ContributedLibraryRelease other = (ContributedLibraryRelease) obj; + String thisVersion = getParsedVersion(); + String otherVersion = other.getParsedVersion(); + + boolean versionEquals = (thisVersion != null + && thisVersion.equals(otherVersion)); + + // Important: for legacy libs, versions are null. Two legacy libs must + // always pass this test. + if (thisVersion == null && otherVersion == null) + versionEquals = true; + + String thisName = getName(); + String otherName = other.getName(); + boolean nameEquals = thisName != null && thisName.equals(otherName); + + return versionEquals && nameEquals; + } + + public boolean isBefore(ContributedLibraryRelease other) { + return VersionHelper.compare(getVersion(), other.getVersion()) < 0; + } + + @Override + public int hashCode() { + String hashingData = "CONTRIBUTEDLIB" + getName() + getVersion(); + return hashingData.hashCode(); + } +} diff --git a/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibraryReleases.java b/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibraryReleases.java deleted file mode 100644 index 7a2a75a44..000000000 --- a/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibraryReleases.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This file is part of Arduino. - * - * Copyright 2015 Arduino LLC (http://www.arduino.cc/) - * - * Arduino is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate - * templates or use macros or inline functions from this file, or you compile - * this file and link it with other files to produce an executable, this - * file does not by itself cause the resulting executable to be covered by - * the GNU General Public License. This exception does not however - * invalidate any other reasons why the executable file might be covered by - * the GNU General Public License. - */ - -package cc.arduino.contributions.libraries; - -import cc.arduino.contributions.VersionComparator; -import processing.app.packages.UserLibraryFolder.Location; - -import java.util.LinkedList; -import java.util.List; -import java.util.Optional; - -public class ContributedLibraryReleases { - - private List releases = new LinkedList<>(); - private List versions = new LinkedList<>(); - private ContributedLibrary latest = null; - private ContributedLibrary selected = null; - - public ContributedLibraryReleases(ContributedLibrary library) { - add(library); - } - - public ContributedLibraryReleases(List libraries) { - libraries.forEach(this::add); - } - - public List getReleases() { - return releases; - } - - public boolean shouldContain(ContributedLibrary lib) { - if (latest == null) { - return true; - } - return lib.getName().equals(latest.getName()); - } - - public void add(ContributedLibrary library) { - if (latest == null) { - latest = library; - } - releases.add(library); - String version = library.getParsedVersion(); - if (version != null) { - versions.add(version); - } - if (VersionComparator.greaterThan(version, latest.getParsedVersion())) { - latest = library; - } - selected = latest; - } - - public Optional getInstalled() { - return releases.stream() // - .filter(ContributedLibrary::isLibraryInstalled) // - .reduce((x, y) -> { - Location lx = x.getInstalledLibrary().get().getLocation(); - Location ly = y.getInstalledLibrary().get().getLocation(); - if (lx == ly) { - return VersionComparator.max(x, y); - } - return lx == Location.SKETCHBOOK ? x : y; - }); - } - - public ContributedLibrary getLatest() { - return latest; - } - - public ContributedLibrary getSelected() { - return selected; - } - - public void select(ContributedLibrary lib) { - for (ContributedLibrary r : releases) { - if (r == lib) { - selected = r; - return; - } - } - } -} diff --git a/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndex.java b/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndex.java index 02ff0475c..39aef62bd 100644 --- a/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndex.java +++ b/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndex.java @@ -42,23 +42,23 @@ import cc.arduino.contributions.VersionComparator; public class LibrariesIndex { - private ArrayList list = new ArrayList<>(); + private ArrayList list = new ArrayList<>(); - public List getLibraries() { + public List getLibraries() { return list; } - public List find(final String name) { + public List find(final String name) { return getLibraries().stream() // .filter(l -> name.equals(l.getName())) // .collect(Collectors.toList()); } - public ContributedLibrary find(String name, String version) { + public ContributedLibraryRelease find(String name, String version) { if (name == null || version == null) { return null; } - for (ContributedLibrary lib : find(name)) { + for (ContributedLibraryRelease lib : find(name)) { if (version.equals(lib.getParsedVersion())) { return lib; } @@ -69,7 +69,7 @@ public class LibrariesIndex { @Override public String toString() { StringBuilder sb = new StringBuilder(); - for (ContributedLibrary library : getLibraries()) { + for (ContributedLibraryRelease library : getLibraries()) { sb.append(library.toString()); } return sb.toString(); @@ -77,7 +77,7 @@ public class LibrariesIndex { public List getCategories() { List categories = new LinkedList<>(); - for (ContributedLibrary lib : getLibraries()) { + for (ContributedLibraryRelease lib : getLibraries()) { if (lib.getCategory() != null && !categories.contains(lib.getCategory())) { categories.add(lib.getCategory()); } @@ -89,7 +89,7 @@ public class LibrariesIndex { public List getTypes() { Collection typesAccumulator = new HashSet<>(); - for (ContributedLibrary lib : getLibraries()) { + for (ContributedLibraryRelease lib : getLibraries()) { if (lib.getTypes() != null) { typesAccumulator.addAll(lib.getTypes()); } @@ -101,13 +101,13 @@ public class LibrariesIndex { return types; } - public Optional getInstalled(String name) { - ContributedLibraryReleases rel = new ContributedLibraryReleases(find(name)); + public Optional getInstalled(String name) { + ContributedLibrary rel = new ContributedLibrary(find(name)); return rel.getInstalled(); } - public List resolveDependeciesOf(ContributedLibrary library) { - List solution = new ArrayList<>(); + public List resolveDependeciesOf(ContributedLibraryRelease library) { + List solution = new ArrayList<>(); solution.add(library); if (resolveDependeciesOf(solution, library)) { return solution; @@ -116,8 +116,8 @@ public class LibrariesIndex { } } - public boolean resolveDependeciesOf(List solution, - ContributedLibrary library) { + public boolean resolveDependeciesOf(List solution, + ContributedLibraryRelease library) { List requirements = library.getDependencies(); if (requirements == null) { // No deps for this library, great! @@ -133,7 +133,7 @@ public class LibrariesIndex { continue; // Generate possible matching dependencies - List possibleDeps = findMatchingDependencies(dep); + List possibleDeps = findMatchingDependencies(dep); // If there are no dependencies available add as "missing" lib if (possibleDeps.isEmpty()) { @@ -142,8 +142,8 @@ public class LibrariesIndex { } // Pick the installed version if available - ContributedLibrary selected; - Optional installed = possibleDeps.stream() + ContributedLibraryRelease selected; + Optional installed = possibleDeps.stream() .filter(l -> l.getInstalledLibrary().isPresent()).findAny(); if (installed.isPresent()) { selected = installed.get(); @@ -161,8 +161,8 @@ public class LibrariesIndex { return true; } - private List findMatchingDependencies(ContributedLibraryDependency dep) { - List available = find(dep.getName()); + private List findMatchingDependencies(ContributedLibraryDependency dep) { + List available = find(dep.getName()); if (dep.getVersion() == null || dep.getVersion().isEmpty()) return available; diff --git a/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java b/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java index 57460fc19..fedfc8f3e 100644 --- a/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java +++ b/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java @@ -154,7 +154,7 @@ public class LibrariesIndexer { return; } - for (ContributedLibrary lib : index.getLibraries()) { + for (ContributedLibraryRelease lib : index.getLibraries()) { lib.unsetInstalledUserLibrary(); } @@ -234,7 +234,7 @@ public class LibrariesIndexer { if (loc != Location.CORE && loc != Location.REFERENCED_CORE) { // Check if we can find the same library in the index // and mark it as installed - ContributedLibrary foundLib = index.find(lib.getName(), lib.getVersion()); + ContributedLibraryRelease foundLib = index.find(lib.getName(), lib.getVersion()); if (foundLib != null) { foundLib.setInstalledUserLibrary(lib); lib.setTypes(foundLib.getTypes()); diff --git a/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java b/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java index 3f00f909b..5c65268b6 100644 --- a/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java +++ b/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java @@ -111,16 +111,16 @@ public class LibraryInstaller { } - public void install(ContributedLibrary lib, ProgressListener progressListener) throws Exception { - ArrayList libs = new ArrayList<>(); + public void install(ContributedLibraryRelease lib, ProgressListener progressListener) throws Exception { + ArrayList libs = new ArrayList<>(); libs.add(lib); install(libs, progressListener); } - public synchronized void install(List libs, ProgressListener progressListener) throws Exception { + public synchronized void install(List libs, ProgressListener progressListener) throws Exception { MultiStepProgress progress = new MultiStepProgress(3 * libs.size() + 1); - for (ContributedLibrary lib : libs) { + for (ContributedLibraryRelease lib : libs) { // Do install library (3 steps) performInstall(lib, progressListener, progress); } @@ -129,7 +129,7 @@ public class LibraryInstaller { rescanLibraryIndex(progress, progressListener); } - private void performInstall(ContributedLibrary lib, ProgressListener progressListener, MultiStepProgress progress) throws Exception { + private void performInstall(ContributedLibraryRelease lib, ProgressListener progressListener, MultiStepProgress progress) throws Exception { if (lib.isLibraryInstalled()) { System.out.println(I18n.format(tr("Library is already installed: {0}:{1}"), lib.getName(), lib.getParsedVersion())); return; @@ -140,7 +140,7 @@ public class LibraryInstaller { // Check if we are replacing an already installed lib LibrariesIndex index = BaseNoGui.librariesIndexer.getIndex(); - Optional replacedLib = index.find(lib.getName()).stream() // + Optional replacedLib = index.find(lib.getName()).stream() // .filter(l -> l.getInstalledLibrary().isPresent()) // .filter(l -> l.getInstalledLibrary().get().getInstalledFolder().equals(destFolder)) // .findAny(); @@ -184,7 +184,7 @@ public class LibraryInstaller { progress.stepDone(); } - public synchronized void remove(ContributedLibrary lib, ProgressListener progressListener) throws IOException { + public synchronized void remove(ContributedLibraryRelease lib, ProgressListener progressListener) throws IOException { if (lib.isIDEBuiltIn()) { return; } diff --git a/arduino-core/src/cc/arduino/contributions/libraries/UnavailableContributedLibrary.java b/arduino-core/src/cc/arduino/contributions/libraries/UnavailableContributedLibrary.java index 277d969de..d7bfa36a3 100644 --- a/arduino-core/src/cc/arduino/contributions/libraries/UnavailableContributedLibrary.java +++ b/arduino-core/src/cc/arduino/contributions/libraries/UnavailableContributedLibrary.java @@ -32,7 +32,7 @@ package cc.arduino.contributions.libraries; import java.util.ArrayList; import java.util.List; -public class UnavailableContributedLibrary extends ContributedLibrary { +public class UnavailableContributedLibrary extends ContributedLibraryRelease { private String name; private String version;