1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-14 11:29:26 +01:00

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.
This commit is contained in:
Cristian Maglie 2020-02-28 13:08:00 +01:00
parent 9500b34719
commit 310a5df5e1
22 changed files with 405 additions and 405 deletions

View File

@ -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<ContributedLibrary> {
public class UpdatableLibraryPredicate implements Predicate<ContributedLibraryRelease> {
LibrariesIndexer librariesIndexer;
@ -50,13 +50,13 @@ public class UpdatableLibraryPredicate implements Predicate<ContributedLibrary>
}
@Override
public boolean test(ContributedLibrary lib) {
public boolean test(ContributedLibraryRelease lib) {
if (!lib.isLibraryInstalled()) {
return false;
}
String libraryName = lib.getName();
List<ContributedLibrary> libraries = librariesIndexer.getIndex().find(libraryName);
ContributedLibrary latest = libraries.stream().reduce(VersionComparator::max).get();
List<ContributedLibraryRelease> libraries = librariesIndexer.getIndex().find(libraryName);
ContributedLibraryRelease latest = libraries.stream().reduce(VersionComparator::max).get();
return !latest.isLibraryInstalled();
}
}

View File

@ -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<ContributedLibraryReleases> {
public class ContributedLibraryReleasesComparator implements Comparator<ContributedLibrary> {
private final String firstType;
@ -45,9 +45,9 @@ public class ContributedLibraryReleasesComparator implements Comparator<Contribu
}
@Override
public int compare(ContributedLibraryReleases o1, ContributedLibraryReleases o2) {
ContributedLibrary lib1 = o1.getLatest();
ContributedLibrary lib2 = o2.getLatest();
public int compare(ContributedLibrary o1, ContributedLibrary o2) {
ContributedLibraryRelease lib1 = o1.getLatest();
ContributedLibraryRelease lib2 = o2.getLatest();
List<String> types1 = lib1.getTypes();
List<String> types2 = lib2.getTypes();
@ -66,7 +66,7 @@ public class ContributedLibraryReleasesComparator implements Comparator<Contribu
return compareName(lib1, lib2);
}
private int compareName(ContributedLibrary lib1, ContributedLibrary lib2) {
private int compareName(ContributedLibraryRelease lib1, ContributedLibraryRelease lib2) {
return lib1.getName().compareToIgnoreCase(lib2.getName());
}

View File

@ -43,15 +43,15 @@ import javax.swing.JTable;
import cc.arduino.contributions.DownloadableContributionVersionComparator;
import cc.arduino.contributions.VersionComparator;
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 cc.arduino.utils.ReverseComparator;
@SuppressWarnings("serial")
public class ContributedLibraryTableCellEditor extends InstallerTableCell {
private ContributedLibraryReleases editorValue;
private ContributedLibrary editorValue;
private ContributedLibraryTableCellJPanel editorCell;
@Override
@ -63,7 +63,7 @@ public class ContributedLibraryTableCellEditor extends InstallerTableCell {
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row,
int column) {
editorValue = (ContributedLibraryReleases) value;
editorValue = (ContributedLibrary) value;
editorCell = new ContributedLibraryTableCellJPanel(table, value, true);
editorCell.installButton
@ -71,11 +71,11 @@ public class ContributedLibraryTableCellEditor extends InstallerTableCell {
editorValue.getInstalled()));
editorCell.downgradeButton.addActionListener(e -> {
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<ContributedLibrary> mayInstalled = editorValue.getInstalled();
final Optional<ContributedLibraryRelease> mayInstalled = editorValue.getInstalled();
List<ContributedLibrary> releases = editorValue.getReleases();
List<ContributedLibrary> notInstalled = new LinkedList<>(releases);
List<ContributedLibraryRelease> releases = editorValue.getReleases();
List<ContributedLibraryRelease> 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<ContributedLibrary> notInstalledPrevious = new LinkedList<>();
final List<ContributedLibrary> notInstalledNewer = new LinkedList<>();
final List<ContributedLibraryRelease> notInstalledPrevious = new LinkedList<>();
final List<ContributedLibraryRelease> 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<ContributedLibrary> mayInstalled) {
protected void onInstall(ContributedLibraryRelease selected,
Optional<ContributedLibraryRelease> mayInstalled) {
// Empty
}

View File

@ -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<ContributedLibrary> mayInstalled = releases.getInstalled();
Optional<ContributedLibraryRelease> mayInstalled = releases.getInstalled();
boolean installable, upgradable;
if (!mayInstalled.isPresent()) {

View File

@ -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<ContributedLibraryReleases> {
public class DropdownAllLibraries implements DropdownItem<ContributedLibrary> {
public String toString() {
return tr("All");
}
@Override
public Predicate<ContributedLibraryReleases> getFilterPredicate() {
public Predicate<ContributedLibrary> getFilterPredicate() {
return x -> true;
}

View File

@ -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<ContributedLibraryReleases> {
public class DropdownInstalledLibraryItem implements DropdownItem<ContributedLibrary> {
public String toString() {
return tr("Installed");
}
@Override
public Predicate<ContributedLibraryReleases> getFilterPredicate() {
return new Predicate<ContributedLibraryReleases>() {
public Predicate<ContributedLibrary> getFilterPredicate() {
return new Predicate<ContributedLibrary>() {
@Override
public boolean test(ContributedLibraryReleases t) {
public boolean test(ContributedLibrary t) {
return t.getInstalled().isPresent();
}
};

View File

@ -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<ContributedLibraryReleases> {
public class DropdownLibraryOfCategoryItem implements DropdownItem<ContributedLibrary> {
private final String category;
@ -50,11 +50,11 @@ public class DropdownLibraryOfCategoryItem implements DropdownItem<ContributedLi
}
@Override
public Predicate<ContributedLibraryReleases> getFilterPredicate() {
return new Predicate<ContributedLibraryReleases>() {
public Predicate<ContributedLibrary> getFilterPredicate() {
return new Predicate<ContributedLibrary>() {
@Override
public boolean test(ContributedLibraryReleases rel) {
ContributedLibrary lib = rel.getLatest();
public boolean test(ContributedLibrary rel) {
ContributedLibraryRelease lib = rel.getLatest();
return category.equals(lib.getCategory());
}
};

View File

@ -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<ContributedLibraryReleases> {
public class DropdownLibraryOfTypeItem implements DropdownItem<ContributedLibrary> {
private final String type;
@ -50,10 +50,10 @@ public class DropdownLibraryOfTypeItem implements DropdownItem<ContributedLibrar
}
@Override
public Predicate<ContributedLibraryReleases> getFilterPredicate() {
return new Predicate<ContributedLibraryReleases>() {
public Predicate<ContributedLibrary> getFilterPredicate() {
return new Predicate<ContributedLibrary>() {
@Override
public boolean test(ContributedLibraryReleases lib) {
public boolean test(ContributedLibrary lib) {
List<String> types = lib.getLatest().getTypes();
return types != null && types.contains(type);
}

View File

@ -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<ContributedLibraryReleases> {
public class DropdownUpdatableLibrariesItem implements DropdownItem<ContributedLibrary> {
@Override
public Predicate<ContributedLibraryReleases> getFilterPredicate() {
return new Predicate<ContributedLibraryReleases>() {
public Predicate<ContributedLibrary> getFilterPredicate() {
return new Predicate<ContributedLibrary>() {
@Override
public boolean test(ContributedLibraryReleases lib) {
Optional<ContributedLibrary> mayInstalled = lib.getInstalled();
public boolean test(ContributedLibrary lib) {
Optional<ContributedLibraryRelease> mayInstalled = lib.getInstalled();
if (!mayInstalled.isPresent()) {
return false;
}

View File

@ -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<ContributedLibraryReleases> {
extends FilteredAbstractTableModel<ContributedLibrary> {
private final List<ContributedLibraryReleases> contributions = new ArrayList<>();
private final List<ContributedLibrary> contributions = new ArrayList<>();
private final String[] columnNames = { "Description" };
private final Class<?>[] columnTypes = { ContributedPlatform.class };
Predicate<ContributedLibraryReleases> selectedCategoryFilter = null;
Predicate<ContributedLibrary> selectedCategoryFilter = null;
String selectedFilters[] = null;
public void updateIndexFilter(String filters[],
Predicate<ContributedLibraryReleases> additionalFilter) {
Predicate<ContributedLibrary> 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<ContributedLibraryReleases> rebuildContributionsFromIndex() {
List<ContributedLibraryReleases> res = new ArrayList<>();
private List<ContributedLibrary> rebuildContributionsFromIndex() {
List<ContributedLibrary> 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<ContributedLibraryReleases> all = rebuildContributionsFromIndex();
List<ContributedLibrary> all = rebuildContributionsFromIndex();
contributions.clear();
all.stream().filter(this::filterCondition).forEach(contributions::add);
Collections.sort(contributions,

View File

@ -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<ContributedLibraryReleases> {
public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
private final JComboBox typeChooser;
private final LibraryInstaller installer;
@ -85,7 +85,7 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibraryRelease
protected InstallerTableCell createCellEditor() {
return new ContributedLibraryTableCellEditor() {
@Override
protected void onInstall(ContributedLibrary selectedLibrary, Optional<ContributedLibrary> mayInstalledLibrary) {
protected void onInstall(ContributedLibraryRelease selectedLibrary, Optional<ContributedLibraryRelease> mayInstalledLibrary) {
if (mayInstalledLibrary.isPresent() && selectedLibrary.isIDEBuiltIn()) {
onRemovePressed(mayInstalledLibrary.get());
} else {
@ -94,7 +94,7 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibraryRelease
}
@Override
protected void onRemove(ContributedLibrary library) {
protected void onRemove(ContributedLibraryRelease library) {
onRemovePressed(library);
}
};
@ -120,7 +120,7 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibraryRelease
protected final ActionListener typeChooserActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
DropdownItem<ContributedLibraryReleases> selected = (DropdownItem<ContributedLibraryReleases>) typeChooser.getSelectedItem();
DropdownItem<ContributedLibrary> selected = (DropdownItem<ContributedLibrary>) typeChooser.getSelectedItem();
previousRowAtPoint = -1;
if (selected != null && extraFilter != selected.getFilterPredicate()) {
extraFilter = selected.getFilterPredicate();
@ -217,8 +217,8 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibraryRelease
installerThread.start();
}
public void onInstallPressed(final ContributedLibrary lib) {
List<ContributedLibrary> deps = BaseNoGui.librariesIndexer.getIndex().resolveDependeciesOf(lib);
public void onInstallPressed(final ContributedLibraryRelease lib) {
List<ContributedLibraryRelease> 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<ContributedLibraryRelease
installerThread.start();
}
public void onRemovePressed(final ContributedLibrary lib) {
public void onRemovePressed(final ContributedLibraryRelease lib) {
boolean managedByIndex = BaseNoGui.librariesIndexer.getIndex().getLibraries().contains(lib);
if (!managedByIndex) {

View File

@ -51,7 +51,7 @@ import javax.swing.text.Document;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.StyleSheet;
import cc.arduino.contributions.libraries.ContributedLibrary;
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
import cc.arduino.contributions.libraries.UnavailableContributedLibrary;
import processing.app.Base;
import processing.app.Theme;
@ -64,8 +64,8 @@ public class MultiLibraryInstallDialog extends JDialog {
private Result result = Result.CANCEL;
public MultiLibraryInstallDialog(Window parent, ContributedLibrary lib,
List<ContributedLibrary> dependencies) {
public MultiLibraryInstallDialog(Window parent, ContributedLibraryRelease lib,
List<ContributedLibraryRelease> 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<br />dependencies currently not installed:"),
libName);
desc += "<br/><br/>";
for (ContributedLibrary l : dependencies) {
for (ContributedLibraryRelease l : dependencies) {
if (l.getName().equals(lib.getName()))
continue;
if (l.getInstalledLibrary().isPresent())

View File

@ -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> 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<ContributedLibrary> librariesByName = indexer.getIndex().find(libraryToInstallParts[0]);
List<ContributedLibraryRelease> 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<ContributedLibrary> mayInstalled = indexer.getIndex().getInstalled(libraryToInstallParts[0]);
Optional<ContributedLibraryRelease> 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...",

View File

@ -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());

View File

@ -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<String> {
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());
}
}

View File

@ -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<ContributedLibraryRelease> releases = new LinkedList<>();
private List<String> 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<String> architectures;
private ArrayList<String> types;
private ArrayList<ContributedLibraryDependency> dependencies;
private ArrayList<String> 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<String> getArchitectures() { return architectures; }
public List<String> getTypes() { return types; }
public List<ContributedLibraryDependency> getDependencies() { return dependencies; }
public List<String> getProvidesIncludes() { return providesIncludes; }
public static final Comparator<ContributedLibrary> CASE_INSENSITIVE_ORDER = (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName());
private Optional<UserLibrary> installedLib = Optional.empty();
public Optional<UserLibrary> getInstalledLibrary() {
return installedLib;
public ContributedLibrary(ContributedLibraryRelease release) {
add(release);
}
public boolean isLibraryInstalled() {
return installedLib.isPresent();
public ContributedLibrary(List<ContributedLibraryRelease> releases) {
releases.forEach(this::add);
}
public void setInstalledUserLibrary(UserLibrary installed) {
this.installedLib = Optional.of(installed);
public List<ContributedLibraryRelease> getReleases() {
return releases;
}
public void unsetInstalledUserLibrary() {
installedLib = Optional.empty();
}
public boolean isIDEBuiltIn() {
if (!installedLib.isPresent()) {
return false;
}
return installedLib.get().isIDEBuiltIn();
}
/**
* Returns <b>true</b> 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 <b>true</b> 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<String> 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;
}
return release.getName().equals(latest.getName());
}
@Override
public String toString() {
return I18n.format(tr("Version {0}"), getParsedVersion());
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;
}
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 + ",";
public Optional<ContributedLibraryRelease> 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);
}
res += "\n";
res += " requires :\n";
if (getDependencies() != null)
for (ContributedLibraryDependency r : getDependencies()) {
res += " " + r;
}
res += "\n";
// DownloadableContribution
res += super.toString();
return res;
return lx == Location.SKETCHBOOK ? x : y;
});
}
@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;
public ContributedLibraryRelease getLatest() {
return latest;
}
public boolean isBefore(ContributedLibrary other) {
return VersionHelper.compare(getVersion(), other.getVersion()) < 0;
public ContributedLibraryRelease getSelected() {
return selected;
}
@Override
public int hashCode() {
String hashingData = "CONTRIBUTEDLIB" + getName() + getVersion();
return hashingData.hashCode();
public void select(ContributedLibraryRelease lib) {
for (ContributedLibraryRelease r : releases) {
if (r == lib) {
selected = r;
return;
}
}
}
}

View File

@ -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<String> architectures;
private ArrayList<String> types;
private ArrayList<ContributedLibraryDependency> dependencies;
private ArrayList<String> 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<String> getArchitectures() { return architectures; }
public List<String> getTypes() { return types; }
public List<ContributedLibraryDependency> getDependencies() { return dependencies; }
public List<String> getProvidesIncludes() { return providesIncludes; }
public static final Comparator<ContributedLibraryRelease> CASE_INSENSITIVE_ORDER = (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName());
private Optional<UserLibrary> installedLib = Optional.empty();
public Optional<UserLibrary> 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 <b>true</b> 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 <b>true</b> 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<String> 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();
}
}

View File

@ -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<ContributedLibrary> releases = new LinkedList<>();
private List<String> versions = new LinkedList<>();
private ContributedLibrary latest = null;
private ContributedLibrary selected = null;
public ContributedLibraryReleases(ContributedLibrary library) {
add(library);
}
public ContributedLibraryReleases(List<ContributedLibrary> libraries) {
libraries.forEach(this::add);
}
public List<ContributedLibrary> 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<ContributedLibrary> 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;
}
}
}
}

View File

@ -42,23 +42,23 @@ import cc.arduino.contributions.VersionComparator;
public class LibrariesIndex {
private ArrayList<ContributedLibrary> list = new ArrayList<>();
private ArrayList<ContributedLibraryRelease> list = new ArrayList<>();
public List<ContributedLibrary> getLibraries() {
public List<ContributedLibraryRelease> getLibraries() {
return list;
}
public List<ContributedLibrary> find(final String name) {
public List<ContributedLibraryRelease> 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<String> getCategories() {
List<String> 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<String> getTypes() {
Collection<String> 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<ContributedLibrary> getInstalled(String name) {
ContributedLibraryReleases rel = new ContributedLibraryReleases(find(name));
public Optional<ContributedLibraryRelease> getInstalled(String name) {
ContributedLibrary rel = new ContributedLibrary(find(name));
return rel.getInstalled();
}
public List<ContributedLibrary> resolveDependeciesOf(ContributedLibrary library) {
List<ContributedLibrary> solution = new ArrayList<>();
public List<ContributedLibraryRelease> resolveDependeciesOf(ContributedLibraryRelease library) {
List<ContributedLibraryRelease> solution = new ArrayList<>();
solution.add(library);
if (resolveDependeciesOf(solution, library)) {
return solution;
@ -116,8 +116,8 @@ public class LibrariesIndex {
}
}
public boolean resolveDependeciesOf(List<ContributedLibrary> solution,
ContributedLibrary library) {
public boolean resolveDependeciesOf(List<ContributedLibraryRelease> solution,
ContributedLibraryRelease library) {
List<ContributedLibraryDependency> 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<ContributedLibrary> possibleDeps = findMatchingDependencies(dep);
List<ContributedLibraryRelease> 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<ContributedLibrary> installed = possibleDeps.stream()
ContributedLibraryRelease selected;
Optional<ContributedLibraryRelease> 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<ContributedLibrary> findMatchingDependencies(ContributedLibraryDependency dep) {
List<ContributedLibrary> available = find(dep.getName());
private List<ContributedLibraryRelease> findMatchingDependencies(ContributedLibraryDependency dep) {
List<ContributedLibraryRelease> available = find(dep.getName());
if (dep.getVersion() == null || dep.getVersion().isEmpty())
return available;

View File

@ -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());

View File

@ -111,16 +111,16 @@ public class LibraryInstaller {
}
public void install(ContributedLibrary lib, ProgressListener progressListener) throws Exception {
ArrayList<ContributedLibrary> libs = new ArrayList<>();
public void install(ContributedLibraryRelease lib, ProgressListener progressListener) throws Exception {
ArrayList<ContributedLibraryRelease> libs = new ArrayList<>();
libs.add(lib);
install(libs, progressListener);
}
public synchronized void install(List<ContributedLibrary> libs, ProgressListener progressListener) throws Exception {
public synchronized void install(List<ContributedLibraryRelease> 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<ContributedLibrary> replacedLib = index.find(lib.getName()).stream() //
Optional<ContributedLibraryRelease> 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;
}

View File

@ -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;