clean up this maze of pretty version handling

This commit is contained in:
Ben Fry
2016-11-03 10:36:52 -04:00
parent 1fe0dd5f75
commit 64e1bfef36
9 changed files with 52 additions and 39 deletions
+1 -1
View File
@@ -823,7 +823,7 @@ public class Base {
String entry = c.getTypeName() + "=" +
PApplet.urlEncode(String.format("name=%s\nurl=%s\nrevision=%d\nversion=%s",
c.getName(), c.getUrl(),
c.getVersion(), c.getPrettyVersion()));
c.getVersion(), c.getBenignVersion()));
entries.append(entry);
}
String joined =
@@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2013-15 The Processing Foundation
Copyright (c) 2013-16 The Processing Foundation
Copyright (c) 2011-12 Ben Fry and Casey Reas
This program is free software; you can redistribute it and/or modify
@@ -49,9 +49,9 @@ public class AvailableContribution extends Contribution {
imports = parseImports(params);
name = params.get("name");
authors = params.get("authors");
if (authors == null) {
authors = params.get("authorList");
}
// if (authors == null) {
// authors = params.get("authorList");
// }
url = params.get("url");
sentence = params.get("sentence");
paragraph = params.get("paragraph");
@@ -62,6 +62,9 @@ public class AvailableContribution extends Contribution {
}
prettyVersion = params.get("prettyVersion");
if (prettyVersion != null && prettyVersion.length() == 0) {
prettyVersion = null;
}
String lastUpdatedStr = params.get("lastUpdated");
if (lastUpdatedStr != null) {
@@ -231,9 +234,6 @@ public class AvailableContribution extends Contribution {
* manager. However, it also ensures that valid fields in the properties file
* aren't overwritten, since the properties file may be more recent than the
* contributions.txt file.
*
* @param propFile
* @return
*/
public boolean writePropertiesFile(File propFile) {
try {
@@ -256,9 +256,9 @@ public class AvailableContribution extends Contribution {
StringList importsList = parseImports(properties);
String authors = properties.get(AUTHORS_PROPERTY);
if (authors == null) {
authors = properties.get("authorList"); // before 3.0a11
}
// if (authors == null) {
// authors = properties.get("authorList"); // before 3.0a11
// }
if (authors == null || authors.isEmpty()) {
authors = getAuthorList();
}
@@ -283,13 +283,14 @@ public class AvailableContribution extends Contribution {
version = Integer.parseInt(properties.get("version"));
} catch (NumberFormatException e) {
version = getVersion();
System.err.println("The version number for “" + name + "” is not set properly.");
System.err.println("The version number for “" + name + "” is not a number.");
System.err.println("Please contact the author to fix it according to the guidelines.");
}
String prettyVersion = properties.get("prettyVersion");
if (prettyVersion == null || prettyVersion.isEmpty())
prettyVersion = getPrettyVersion();
if (prettyVersion != null && prettyVersion.isEmpty()) {
prettyVersion = null;
}
String compatibleContribsList = null;
if (getType() == ContributionType.EXAMPLES) {
@@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2013-15 The Processing Foundation
Copyright (c) 2013-16 The Processing Foundation
Copyright (c) 2011-12 Ben Fry and Casey Reas
This program is free software; you can redistribute it and/or modify
@@ -164,6 +164,12 @@ abstract public class Contribution {
}
// returns prettyVersion, or "" if null
public String getBenignVersion() {
return (prettyVersion != null) ? prettyVersion : "";
}
// 1402805757
public long getLastUpdated() {
return lastUpdated;
@@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2013-15 The Processing Foundation
Copyright (c) 2013-16 The Processing Foundation
Copyright (c) 2011-12 Ben Fry and Casey Reas
This program is free software; you can redistribute it and/or modify
@@ -500,7 +500,7 @@ public class ContributionListing {
}
protected String getLatestVersion(Contribution contribution) {
protected String getLatestPrettyVersion(Contribution contribution) {
Contribution newestContrib = getAvailableContribution(contribution);
if (newestContrib == null) {
return null;
@@ -509,7 +509,6 @@ public class ContributionListing {
}
protected boolean hasDownloadedLatestList() {
return listDownloaded;
}
@@ -460,9 +460,9 @@ class DetailPanel extends JPanel {
}
desc.append("</font> ");
String version = contrib.getPrettyVersion();
if (version != null) {
desc.append(version);
String prettyVersion = contrib.getPrettyVersion();
if (prettyVersion != null) {
desc.append(prettyVersion);
}
desc.append(" <br/>");
@@ -493,8 +493,9 @@ class DetailPanel extends JPanel {
if (lastUpdatedUTC != 0) {
DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.MEDIUM);
Date lastUpdatedDate = new Date(lastUpdatedUTC);
if (version != null && !version.isEmpty())
if (prettyVersion != null) {
desc.append(", ");
}
desc.append("Last Updated on " + dateFormatter.format(lastUpdatedDate));
}
@@ -510,7 +511,7 @@ class DetailPanel extends JPanel {
// versionText.append("To finish an update, reinstall this contribution after restarting.");
;
} else {
String latestVersion = contribListing.getLatestVersion(contrib);
String latestVersion = contribListing.getLatestPrettyVersion(contrib);
if (latestVersion != null) {
versionText.append("New version (" + latestVersion + ") available.");
} else {
@@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2013-15 The Processing Foundation
Copyright (c) 2013-16 The Processing Foundation
Copyright (c) 2011-12 Ben Fry and Casey Reas
This program is free software; you can redistribute it and/or modify
@@ -72,9 +72,9 @@ public abstract class LocalContribution extends Contribution {
}
// changing to 'authors' in 3.0a11
authors = properties.get(AUTHORS_PROPERTY);
if (authors == null) {
authors = properties.get("authorList");
}
// if (authors == null) {
// authors = properties.get("authorList");
// }
url = properties.get("url");
sentence = properties.get("sentence");
paragraph = properties.get("paragraph");
@@ -86,10 +86,9 @@ public abstract class LocalContribution extends Contribution {
System.err.println("Please contact the library author to fix it according to the guidelines.");
}
// Use the version number if they've left the prettyVersion field blank
prettyVersion = properties.get("prettyVersion");
if (prettyVersion == null || prettyVersion.length() == 0) {
prettyVersion = Integer.toString(version);
if (prettyVersion != null && prettyVersion.length() == 0) {
prettyVersion = null;
}
try {
@@ -249,13 +249,13 @@ class StatusPanel extends JPanel {
!panel.updateInProgress);
String latestVersion =
contributionListing.getLatestVersion(panel.getContrib());
contributionListing.getLatestPrettyVersion(panel.getContrib());
String currentVersion = panel.getContrib().getPrettyVersion();
installButton.setEnabled(!panel.getContrib().isInstalled()
&& contributionListing.hasDownloadedLatestList()
&& panel.getContrib().isCompatible(Base.getRevision())
&& !panel.installInProgress);
installButton.setEnabled(!panel.getContrib().isInstalled() &&
contributionListing.hasDownloadedLatestList() &&
panel.getContrib().isCompatible(Base.getRevision()) &&
!panel.installInProgress);
if (panel.getContrib().isCompatible(Base.getRevision())) {
if (installButton.isEnabled()) {
@@ -285,9 +285,12 @@ class StatusPanel extends JPanel {
latestVersion = "Update";
}
// why was this here? [fry 161103]
/*
if (currentVersion == null) {
currentVersion = "";
}
*/
if (updateButton.isEnabled()) {
updateButton.setText(latestVersion);
@@ -295,8 +298,7 @@ class StatusPanel extends JPanel {
updateButton.setText("Update");
}
removeButton.setEnabled(panel.getContrib().isInstalled()
&& !panel.removeInProgress);
removeButton.setEnabled(panel.getContrib().isInstalled() && !panel.removeInProgress);
progressPanel.add(panel.installProgressBar);
progressPanel.setVisible(false);
updateLabel.setVisible(true);
@@ -209,8 +209,8 @@ public class UpdateListPanel extends ListPanel {
icon,
"<html>" + fontFace + entry.getName() + "</font></html>",
name,
entry.getPrettyVersion(),
contributionTab.contribListing.getLatestVersion(entry)
entry.getBenignVersion(),
contributionTab.contribListing.getLatestPrettyVersion(entry)
});
}
UpdateContributionTab tab = (UpdateContributionTab) contributionTab;
+5
View File
@@ -1,6 +1,11 @@
0255 (3.2.3 or 3.3)
X if prettyVersion is blank (or null?), just use version (Firmata)
// Use the version number if they've left the prettyVersion field blank
if (prettyVersion == null || prettyVersion.length() == 0) {
prettyVersion = Integer.toString(version);
}
contribs
_ 'version' should be x.y or x.y.z, not some extra long string