mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-21 15:54:39 +01:00
Uniformly using versions parsed through semver
This commit is contained in:
parent
1b139caef1
commit
7a97be43a5
@ -268,7 +268,7 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
|||||||
Lists.newLinkedList(Lists.transform(uninstalledReleases, new Function<ContributedLibrary, ContributedLibrary>() {
|
Lists.newLinkedList(Lists.transform(uninstalledReleases, new Function<ContributedLibrary, ContributedLibrary>() {
|
||||||
@Override
|
@Override
|
||||||
public ContributedLibrary apply(ContributedLibrary input) {
|
public ContributedLibrary apply(ContributedLibrary input) {
|
||||||
if (installed == null || VersionComparator.VERSION_COMPARATOR.greaterThan(installed.getVersion(), input.getVersion())) {
|
if (installed == null || VersionComparator.VERSION_COMPARATOR.greaterThan(installed.getParsedVersion(), input.getParsedVersion())) {
|
||||||
uninstalledPreviousReleases.add(input);
|
uninstalledPreviousReleases.add(input);
|
||||||
} else {
|
} else {
|
||||||
uninstalledNewerReleases.add(input);
|
uninstalledNewerReleases.add(input);
|
||||||
@ -357,7 +357,7 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
|||||||
|
|
||||||
// ...version.
|
// ...version.
|
||||||
if (installed != null) {
|
if (installed != null) {
|
||||||
Version installedVer = VersionHelper.valueOf(installed.getVersion());
|
String installedVer = installed.getParsedVersion();
|
||||||
if (installedVer == null) {
|
if (installedVer == null) {
|
||||||
desc += " " + _("Version unknown");
|
desc += " " + _("Version unknown");
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,13 +54,13 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel<Contrib
|
|||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final List<ContributedLibrary> releases;
|
public final List<ContributedLibrary> releases;
|
||||||
public final List<Version> versions;
|
public final List<String> versions;
|
||||||
|
|
||||||
public ContributedLibrary selected;
|
public ContributedLibrary selected;
|
||||||
|
|
||||||
public ContributedLibraryReleases(ContributedLibrary library) {
|
public ContributedLibraryReleases(ContributedLibrary library) {
|
||||||
this.name = library.getName();
|
this.name = library.getName();
|
||||||
this.versions = new LinkedList<Version>();
|
this.versions = new LinkedList<String>();
|
||||||
this.releases = new LinkedList<ContributedLibrary>();
|
this.releases = new LinkedList<ContributedLibrary>();
|
||||||
this.selected = null;
|
this.selected = null;
|
||||||
add(library);
|
add(library);
|
||||||
@ -72,7 +72,7 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel<Contrib
|
|||||||
|
|
||||||
public void add(ContributedLibrary library) {
|
public void add(ContributedLibrary library) {
|
||||||
releases.add(library);
|
releases.add(library);
|
||||||
Version version = VersionHelper.valueOf(library.getVersion());
|
String version = library.getParsedVersion();
|
||||||
if (version != null) {
|
if (version != null) {
|
||||||
versions.add(version);
|
versions.add(version);
|
||||||
}
|
}
|
||||||
@ -98,15 +98,6 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel<Contrib
|
|||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectVersion(String version) {
|
|
||||||
for (ContributedLibrary lib : releases) {
|
|
||||||
if (lib.getVersion().equals(version)) {
|
|
||||||
selected = lib;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void select(ContributedLibrary value) {
|
public void select(ContributedLibrary value) {
|
||||||
for (ContributedLibrary plat : releases) {
|
for (ContributedLibrary plat : releases) {
|
||||||
if (plat == value) {
|
if (plat == value) {
|
||||||
@ -222,10 +213,6 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel<Contrib
|
|||||||
return col == DESCRIPTION_COL;
|
return col == DESCRIPTION_COL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Version> getReleasesVersions(int row) {
|
|
||||||
return contributions.get(row).versions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContributedLibraryReleases getReleases(int row) {
|
public ContributedLibraryReleases getReleases(int row) {
|
||||||
return contributions.get(row);
|
return contributions.get(row);
|
||||||
}
|
}
|
||||||
|
@ -100,8 +100,9 @@ public class LibraryInstaller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void install(ContributedLibrary lib, ContributedLibrary replacedLib) throws Exception {
|
public void install(ContributedLibrary lib, ContributedLibrary replacedLib) throws Exception {
|
||||||
if (lib.isInstalled())
|
if (lib.isInstalled()) {
|
||||||
throw new Exception(_("Library is already installed!"));
|
throw new Exception(_("Library is already installed!"));
|
||||||
|
}
|
||||||
|
|
||||||
final MultiStepProgress progress = new MultiStepProgress(3);
|
final MultiStepProgress progress = new MultiStepProgress(3);
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
|||||||
Lists.newLinkedList(Lists.transform(uninstalledReleases, new Function<ContributedPlatform, ContributedPlatform>() {
|
Lists.newLinkedList(Lists.transform(uninstalledReleases, new Function<ContributedPlatform, ContributedPlatform>() {
|
||||||
@Override
|
@Override
|
||||||
public ContributedPlatform apply(ContributedPlatform input) {
|
public ContributedPlatform apply(ContributedPlatform input) {
|
||||||
if (installed == null || VersionComparator.VERSION_COMPARATOR.greaterThan(installed.getVersion(), input.getVersion())) {
|
if (installed == null || VersionComparator.VERSION_COMPARATOR.greaterThan(installed.getParsedVersion(), input.getParsedVersion())) {
|
||||||
uninstalledPreviousReleases.add(input);
|
uninstalledPreviousReleases.add(input);
|
||||||
} else {
|
} else {
|
||||||
uninstalledNewerReleases.add(input);
|
uninstalledNewerReleases.add(input);
|
||||||
@ -357,7 +357,7 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
|||||||
desc += " " + format("by <b>{0}</b>", author);
|
desc += " " + format("by <b>{0}</b>", author);
|
||||||
}
|
}
|
||||||
if (installed != null) {
|
if (installed != null) {
|
||||||
desc += " " + format(_("version <b>{0}</b>"), VersionHelper.valueOf(installed.getVersion())) + " <strong><font color=\"#00979D\">INSTALLED</font></strong>";
|
desc += " " + format(_("version <b>{0}</b>"), installed.getParsedVersion()) + " <strong><font color=\"#00979D\">INSTALLED</font></strong>";
|
||||||
}
|
}
|
||||||
desc += "<br />";
|
desc += "<br />";
|
||||||
|
|
||||||
|
@ -54,14 +54,14 @@ public class ContributionIndexTableModel extends FilteredAbstractTableModel<Cont
|
|||||||
public final ContributedPackage packager;
|
public final ContributedPackage packager;
|
||||||
public final String arch;
|
public final String arch;
|
||||||
public final List<ContributedPlatform> releases;
|
public final List<ContributedPlatform> releases;
|
||||||
public final List<Version> versions;
|
public final List<String> versions;
|
||||||
public ContributedPlatform selected = null;
|
public ContributedPlatform selected = null;
|
||||||
|
|
||||||
public ContributedPlatformReleases(ContributedPlatform platform) {
|
public ContributedPlatformReleases(ContributedPlatform platform) {
|
||||||
this.packager = platform.getParentPackage();
|
this.packager = platform.getParentPackage();
|
||||||
this.arch = platform.getArchitecture();
|
this.arch = platform.getArchitecture();
|
||||||
this.releases = new LinkedList<ContributedPlatform>();
|
this.releases = new LinkedList<ContributedPlatform>();
|
||||||
this.versions = new LinkedList<Version>();
|
this.versions = new LinkedList<String>();
|
||||||
add(platform);
|
add(platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ public class ContributionIndexTableModel extends FilteredAbstractTableModel<Cont
|
|||||||
|
|
||||||
public void add(ContributedPlatform platform) {
|
public void add(ContributedPlatform platform) {
|
||||||
releases.add(platform);
|
releases.add(platform);
|
||||||
Version version = VersionHelper.valueOf(platform.getVersion());
|
String version = platform.getParsedVersion();
|
||||||
if (version != null) {
|
if (version != null) {
|
||||||
versions.add(version);
|
versions.add(version);
|
||||||
}
|
}
|
||||||
@ -99,15 +99,6 @@ public class ContributionIndexTableModel extends FilteredAbstractTableModel<Cont
|
|||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectVersion(String version) {
|
|
||||||
for (ContributedPlatform plat : releases) {
|
|
||||||
if (plat.getVersion().equals(version)) {
|
|
||||||
selected = plat;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void select(ContributedPlatform value) {
|
public void select(ContributedPlatform value) {
|
||||||
for (ContributedPlatform plat : releases) {
|
for (ContributedPlatform plat : releases) {
|
||||||
if (plat == value) {
|
if (plat == value) {
|
||||||
@ -217,10 +208,6 @@ public class ContributionIndexTableModel extends FilteredAbstractTableModel<Cont
|
|||||||
return col == DESCRIPTION_COL;
|
return col == DESCRIPTION_COL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Version> getReleasesVersions(int row) {
|
|
||||||
return contributions.get(row).versions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContributedPlatformReleases getReleases(int row) {
|
public ContributedPlatformReleases getReleases(int row) {
|
||||||
return contributions.get(row);
|
return contributions.get(row);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public abstract class FilteredAbstractTableModel<T> extends AbstractTableModel {
|
|||||||
Collections.sort(contribs, new Comparator<T>() {
|
Collections.sort(contribs, new Comparator<T>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(T contrib1, T contrib2) {
|
public int compare(T contrib1, T contrib2) {
|
||||||
return VersionComparator.VERSION_COMPARATOR.compare(contrib1.getVersion(), contrib2.getVersion());
|
return VersionComparator.VERSION_COMPARATOR.compare(contrib1.getParsedVersion(), contrib2.getParsedVersion());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ public abstract class ContributedLibrary extends DownloadableContribution {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return I18n.format(_("Version {0}"), getVersion());
|
return I18n.format(_("Version {0}"), getParsedVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String info() {
|
public String info() {
|
||||||
@ -106,7 +106,7 @@ public abstract class ContributedLibrary extends DownloadableContribution {
|
|||||||
res += " ContributedLibrary : " + getName() + "\n";
|
res += " ContributedLibrary : " + getName() + "\n";
|
||||||
res += " author : " + getAuthor() + "\n";
|
res += " author : " + getAuthor() + "\n";
|
||||||
res += " maintainer : " + getMaintainer() + "\n";
|
res += " maintainer : " + getMaintainer() + "\n";
|
||||||
res += " version : " + getVersion() + "\n";
|
res += " version : " + getParsedVersion() + "\n";
|
||||||
res += " website : " + getUrl() + "\n";
|
res += " website : " + getUrl() + "\n";
|
||||||
res += " category : " + getCategory() + "\n";
|
res += " category : " + getCategory() + "\n";
|
||||||
res += " license : " + getLicense() + "\n";
|
res += " license : " + getLicense() + "\n";
|
||||||
@ -138,8 +138,8 @@ public abstract class ContributedLibrary extends DownloadableContribution {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String thisVersion = getVersion();
|
String thisVersion = getParsedVersion();
|
||||||
String otherVersion = ((ContributedLibrary) obj).getVersion();
|
String otherVersion = ((ContributedLibrary) obj).getParsedVersion();
|
||||||
|
|
||||||
boolean versionEquals = thisVersion == null || otherVersion == null || thisVersion.equals(otherVersion);
|
boolean versionEquals = thisVersion == null || otherVersion == null || thisVersion.equals(otherVersion);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ public class ContributedLibraryComparator implements Comparator<ContributedLibra
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(ContributedLibrary lib1, ContributedLibrary lib2) {
|
public int compare(ContributedLibrary lib1, ContributedLibrary lib2) {
|
||||||
return VersionComparator.VERSION_COMPARATOR.compare(lib1.getVersion(), lib2.getVersion());
|
return VersionComparator.VERSION_COMPARATOR.compare(lib1.getParsedVersion(), lib2.getParsedVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public abstract class LibrariesIndex {
|
|||||||
|
|
||||||
public ContributedLibrary find(String name, String version) {
|
public ContributedLibrary find(String name, String version) {
|
||||||
for (ContributedLibrary lib : find(name)) {
|
for (ContributedLibrary lib : find(name)) {
|
||||||
if (lib.getVersion().equals(version)) {
|
if (version.equals(lib.getParsedVersion())) {
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ public class LibrariesIndexer {
|
|||||||
|
|
||||||
// Check if we can find the same library in the index
|
// Check if we can find the same library in the index
|
||||||
// and mark it as installed
|
// and mark it as installed
|
||||||
ContributedLibrary foundLib = index.find(lib.getName(), lib.getVersion());
|
ContributedLibrary foundLib = index.find(lib.getName(), lib.getParsedVersion());
|
||||||
if (foundLib != null) {
|
if (foundLib != null) {
|
||||||
foundLib.setInstalled(true);
|
foundLib.setInstalled(true);
|
||||||
foundLib.setInstalledFolder(folder);
|
foundLib.setInstalledFolder(folder);
|
||||||
|
@ -48,8 +48,7 @@ public abstract class ContributedPackage {
|
|||||||
|
|
||||||
public ContributedPlatform findPlatform(String architecture, String version) {
|
public ContributedPlatform findPlatform(String architecture, String version) {
|
||||||
for (ContributedPlatform platform : getPlatforms()) {
|
for (ContributedPlatform platform : getPlatforms()) {
|
||||||
if (platform.getArchitecture().equals(architecture) &&
|
if (platform.getArchitecture().equals(architecture) && version.equals(platform.getParsedVersion()))
|
||||||
platform.getVersion().equals(version))
|
|
||||||
return platform;
|
return platform;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -71,7 +70,7 @@ public abstract class ContributedPackage {
|
|||||||
found = p;
|
found = p;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (version.compare(p.getVersion(), found.getVersion()) > 0)
|
if (version.compare(p.getParsedVersion(), found.getParsedVersion()) > 0)
|
||||||
found = p;
|
found = p;
|
||||||
}
|
}
|
||||||
return found;
|
return found;
|
||||||
@ -98,7 +97,7 @@ public abstract class ContributedPackage {
|
|||||||
}
|
}
|
||||||
res += "\n category : " + plat.getCategory();
|
res += "\n category : " + plat.getCategory();
|
||||||
res += "\n architecture : " +
|
res += "\n architecture : " +
|
||||||
plat.getArchitecture() + " " + plat.getVersion() + "\n";
|
plat.getArchitecture() + " " + plat.getParsedVersion() + "\n";
|
||||||
if (plat.getToolsDependencies() != null)
|
if (plat.getToolsDependencies() != null)
|
||||||
for (ContributedToolReference t : plat.getToolsDependencies()) {
|
for (ContributedToolReference t : plat.getToolsDependencies()) {
|
||||||
res += " tool dep : " + t.getName() + " " +
|
res += " tool dep : " + t.getName() + " " +
|
||||||
|
@ -87,6 +87,6 @@ public abstract class ContributedPlatform extends DownloadableContribution {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getVersion();
|
return getParsedVersion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ public class ContributedPlatformComparator implements Comparator<ContributedPlat
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(ContributedPlatform lib1, ContributedPlatform lib2) {
|
public int compare(ContributedPlatform lib1, ContributedPlatform lib2) {
|
||||||
return VersionComparator.VERSION_COMPARATOR.compare(lib1.getVersion(), lib2.getVersion());
|
return VersionComparator.VERSION_COMPARATOR.compare(lib1.getParsedVersion(), lib2.getParsedVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ public class ContributionInstaller {
|
|||||||
progress.setStatus(_("Installing boards..."));
|
progress.setStatus(_("Installing boards..."));
|
||||||
onProgress(progress);
|
onProgress(progress);
|
||||||
File platformFolder = new File(packageFolder, "hardware" + File.separator + platform.getArchitecture());
|
File platformFolder = new File(packageFolder, "hardware" + File.separator + platform.getArchitecture());
|
||||||
File destFolder = new File(platformFolder, platform.getVersion());
|
File destFolder = new File(platformFolder, platform.getParsedVersion());
|
||||||
destFolder.mkdirs();
|
destFolder.mkdirs();
|
||||||
new ArchiveExtractor(BaseNoGui.getPlatform()).extract(platform.getDownloadedFile(), destFolder, 1);
|
new ArchiveExtractor(BaseNoGui.getPlatform()).extract(platform.getDownloadedFile(), destFolder, 1);
|
||||||
platform.setInstalled(true);
|
platform.setInstalled(true);
|
||||||
|
@ -28,6 +28,9 @@
|
|||||||
*/
|
*/
|
||||||
package cc.arduino.contributions.packages;
|
package cc.arduino.contributions.packages;
|
||||||
|
|
||||||
|
import cc.arduino.contributions.VersionHelper;
|
||||||
|
import com.github.zafarkhaja.semver.Version;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public abstract class DownloadableContribution {
|
public abstract class DownloadableContribution {
|
||||||
@ -90,6 +93,14 @@ public abstract class DownloadableContribution {
|
|||||||
this.readOnly = readOnly;
|
this.readOnly = readOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParsedVersion() {
|
||||||
|
Version version = VersionHelper.valueOf(getVersion());
|
||||||
|
if (version == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return version.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String res = "";
|
String res = "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user