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