1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-26 17:42:18 +03:00

Uniformly using versions parsed through semver

This commit is contained in:
Federico Fissore
2015-04-01 17:11:48 +02:00
parent 1b139caef1
commit 7a97be43a5
15 changed files with 37 additions and 52 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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