Skip to content

Commit 7a97be4

Browse files
author
Federico Fissore
committed
Uniformly using versions parsed through semver
1 parent 1b139ca commit 7a97be4

15 files changed

+37
-52
lines changed

app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCell.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public Component getTableCellEditorComponent(JTable table, Object value,
268268
Lists.newLinkedList(Lists.transform(uninstalledReleases, new Function<ContributedLibrary, ContributedLibrary>() {
269269
@Override
270270
public ContributedLibrary apply(ContributedLibrary input) {
271-
if (installed == null || VersionComparator.VERSION_COMPARATOR.greaterThan(installed.getVersion(), input.getVersion())) {
271+
if (installed == null || VersionComparator.VERSION_COMPARATOR.greaterThan(installed.getParsedVersion(), input.getParsedVersion())) {
272272
uninstalledPreviousReleases.add(input);
273273
} else {
274274
uninstalledNewerReleases.add(input);
@@ -357,7 +357,7 @@ private Component getUpdatedCellComponent(Object value, boolean isSelected, int
357357

358358
// ...version.
359359
if (installed != null) {
360-
Version installedVer = VersionHelper.valueOf(installed.getVersion());
360+
String installedVer = installed.getParsedVersion();
361361
if (installedVer == null) {
362362
desc += " " + _("Version unknown");
363363
} else {

app/src/cc/arduino/contributions/libraries/ui/LibrariesIndexTableModel.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ public static class ContributedLibraryReleases implements Comparable<Contributed
5454

5555
public final String name;
5656
public final List<ContributedLibrary> releases;
57-
public final List<Version> versions;
57+
public final List<String> versions;
5858

5959
public ContributedLibrary selected;
6060

6161
public ContributedLibraryReleases(ContributedLibrary library) {
6262
this.name = library.getName();
63-
this.versions = new LinkedList<Version>();
63+
this.versions = new LinkedList<String>();
6464
this.releases = new LinkedList<ContributedLibrary>();
6565
this.selected = null;
6666
add(library);
@@ -72,7 +72,7 @@ public boolean shouldContain(ContributedLibrary lib) {
7272

7373
public void add(ContributedLibrary library) {
7474
releases.add(library);
75-
Version version = VersionHelper.valueOf(library.getVersion());
75+
String version = library.getParsedVersion();
7676
if (version != null) {
7777
versions.add(version);
7878
}
@@ -98,15 +98,6 @@ public ContributedLibrary getSelected() {
9898
return selected;
9999
}
100100

101-
public void selectVersion(String version) {
102-
for (ContributedLibrary lib : releases) {
103-
if (lib.getVersion().equals(version)) {
104-
selected = lib;
105-
return;
106-
}
107-
}
108-
}
109-
110101
public void select(ContributedLibrary value) {
111102
for (ContributedLibrary plat : releases) {
112103
if (plat == value) {
@@ -222,10 +213,6 @@ public boolean isCellEditable(int row, int col) {
222213
return col == DESCRIPTION_COL;
223214
}
224215

225-
public List<Version> getReleasesVersions(int row) {
226-
return contributions.get(row).versions;
227-
}
228-
229216
public ContributedLibraryReleases getReleases(int row) {
230217
return contributions.get(row);
231218
}

app/src/cc/arduino/contributions/libraries/ui/LibraryInstaller.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ public void updateIndex() throws Exception {
100100
}
101101

102102
public void install(ContributedLibrary lib, ContributedLibrary replacedLib) throws Exception {
103-
if (lib.isInstalled())
103+
if (lib.isInstalled()) {
104104
throw new Exception(_("Library is already installed!"));
105+
}
105106

106107
final MultiStepProgress progress = new MultiStepProgress(3);
107108

app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCell.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public Component getTableCellEditorComponent(JTable table, Object value,
282282
Lists.newLinkedList(Lists.transform(uninstalledReleases, new Function<ContributedPlatform, ContributedPlatform>() {
283283
@Override
284284
public ContributedPlatform apply(ContributedPlatform input) {
285-
if (installed == null || VersionComparator.VERSION_COMPARATOR.greaterThan(installed.getVersion(), input.getVersion())) {
285+
if (installed == null || VersionComparator.VERSION_COMPARATOR.greaterThan(installed.getParsedVersion(), input.getParsedVersion())) {
286286
uninstalledPreviousReleases.add(input);
287287
} else {
288288
uninstalledNewerReleases.add(input);
@@ -357,7 +357,7 @@ private Component getUpdatedCellComponent(Object value, boolean isSelected, int
357357
desc += " " + format("by <b>{0}</b>", author);
358358
}
359359
if (installed != null) {
360-
desc += " " + format(_("version <b>{0}</b>"), VersionHelper.valueOf(installed.getVersion())) + " <strong><font color=\"#00979D\">INSTALLED</font></strong>";
360+
desc += " " + format(_("version <b>{0}</b>"), installed.getParsedVersion()) + " <strong><font color=\"#00979D\">INSTALLED</font></strong>";
361361
}
362362
desc += "<br />";
363363

app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ public static class ContributedPlatformReleases {
5454
public final ContributedPackage packager;
5555
public final String arch;
5656
public final List<ContributedPlatform> releases;
57-
public final List<Version> versions;
57+
public final List<String> versions;
5858
public ContributedPlatform selected = null;
5959

6060
public ContributedPlatformReleases(ContributedPlatform platform) {
6161
this.packager = platform.getParentPackage();
6262
this.arch = platform.getArchitecture();
6363
this.releases = new LinkedList<ContributedPlatform>();
64-
this.versions = new LinkedList<Version>();
64+
this.versions = new LinkedList<String>();
6565
add(platform);
6666
}
6767

@@ -73,7 +73,7 @@ public boolean shouldContain(ContributedPlatform platform) {
7373

7474
public void add(ContributedPlatform platform) {
7575
releases.add(platform);
76-
Version version = VersionHelper.valueOf(platform.getVersion());
76+
String version = platform.getParsedVersion();
7777
if (version != null) {
7878
versions.add(version);
7979
}
@@ -99,15 +99,6 @@ public ContributedPlatform getSelected() {
9999
return selected;
100100
}
101101

102-
public void selectVersion(String version) {
103-
for (ContributedPlatform plat : releases) {
104-
if (plat.getVersion().equals(version)) {
105-
selected = plat;
106-
return;
107-
}
108-
}
109-
}
110-
111102
public void select(ContributedPlatform value) {
112103
for (ContributedPlatform plat : releases) {
113104
if (plat == value) {
@@ -217,10 +208,6 @@ public boolean isCellEditable(int row, int col) {
217208
return col == DESCRIPTION_COL;
218209
}
219210

220-
public List<Version> getReleasesVersions(int row) {
221-
return contributions.get(row).versions;
222-
}
223-
224211
public ContributedPlatformReleases getReleases(int row) {
225212
return contributions.get(row);
226213
}

app/src/cc/arduino/contributions/ui/FilteredAbstractTableModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected static <T extends DownloadableContribution> T getLatestOf(List<T> cont
4747
Collections.sort(contribs, new Comparator<T>() {
4848
@Override
4949
public int compare(T contrib1, T contrib2) {
50-
return VersionComparator.VERSION_COMPARATOR.compare(contrib1.getVersion(), contrib2.getVersion());
50+
return VersionComparator.VERSION_COMPARATOR.compare(contrib1.getParsedVersion(), contrib2.getParsedVersion());
5151
}
5252
});
5353

arduino-core/src/cc/arduino/contributions/libraries/ContributedLibrary.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ public boolean supportsArchitecture(List<String> reqArchs) {
9898

9999
@Override
100100
public String toString() {
101-
return I18n.format(_("Version {0}"), getVersion());
101+
return I18n.format(_("Version {0}"), getParsedVersion());
102102
}
103103

104104
public String info() {
105105
String res = "";
106106
res += " ContributedLibrary : " + getName() + "\n";
107107
res += " author : " + getAuthor() + "\n";
108108
res += " maintainer : " + getMaintainer() + "\n";
109-
res += " version : " + getVersion() + "\n";
109+
res += " version : " + getParsedVersion() + "\n";
110110
res += " website : " + getUrl() + "\n";
111111
res += " category : " + getCategory() + "\n";
112112
res += " license : " + getLicense() + "\n";
@@ -138,8 +138,8 @@ public boolean equals(Object obj) {
138138
return false;
139139
}
140140

141-
String thisVersion = getVersion();
142-
String otherVersion = ((ContributedLibrary) obj).getVersion();
141+
String thisVersion = getParsedVersion();
142+
String otherVersion = ((ContributedLibrary) obj).getParsedVersion();
143143

144144
boolean versionEquals = thisVersion == null || otherVersion == null || thisVersion.equals(otherVersion);
145145

arduino-core/src/cc/arduino/contributions/libraries/ContributedLibraryComparator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class ContributedLibraryComparator implements Comparator<ContributedLibra
88

99
@Override
1010
public int compare(ContributedLibrary lib1, ContributedLibrary lib2) {
11-
return VersionComparator.VERSION_COMPARATOR.compare(lib1.getVersion(), lib2.getVersion());
11+
return VersionComparator.VERSION_COMPARATOR.compare(lib1.getParsedVersion(), lib2.getParsedVersion());
1212
}
1313

1414

arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public boolean apply(ContributedLibrary contributedLibrary) {
4949

5050
public ContributedLibrary find(String name, String version) {
5151
for (ContributedLibrary lib : find(name)) {
52-
if (lib.getVersion().equals(version)) {
52+
if (version.equals(lib.getParsedVersion())) {
5353
return lib;
5454
}
5555
}

arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private void scanLibrary(File folder, boolean isSketchbook) throws IOException {
157157

158158
// Check if we can find the same library in the index
159159
// and mark it as installed
160-
ContributedLibrary foundLib = index.find(lib.getName(), lib.getVersion());
160+
ContributedLibrary foundLib = index.find(lib.getName(), lib.getParsedVersion());
161161
if (foundLib != null) {
162162
foundLib.setInstalled(true);
163163
foundLib.setInstalledFolder(folder);

0 commit comments

Comments
 (0)