mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 10:00:42 +01:00
Merge pull request #2651 from joelmoniz/modeVersionNum
Contribution Version Number, Latest Contribution Version available and Last Date on which contribution was updated now show (Resolves #2498 and #2561)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
@@ -54,6 +54,13 @@ class AvailableContribution extends Contribution {
|
||||
version = PApplet.parseInt(versionStr, 0);
|
||||
}
|
||||
prettyVersion = params.get("prettyVersion");
|
||||
String lastUpdatedStr = params.get("lastUpdated");
|
||||
if (lastUpdatedStr != null)
|
||||
try {
|
||||
lastUpdated = Long.parseLong(lastUpdatedStr);
|
||||
} catch (NumberFormatException e) {
|
||||
lastUpdated = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -236,15 +243,28 @@ class AvailableContribution extends Contribution {
|
||||
} catch (NumberFormatException e) {
|
||||
version = getVersion();
|
||||
System.err.println("The version number for the “" + name
|
||||
+ "” library is not set properly.");
|
||||
+ "” contribution is not set properly.");
|
||||
System.err
|
||||
.println("Please contact the library author to fix it according to the guidelines.");
|
||||
.println("Please contact the author to fix it according to the guidelines.");
|
||||
}
|
||||
|
||||
String prettyVersion = properties.get("prettyVersion");
|
||||
if (prettyVersion == null || prettyVersion.isEmpty())
|
||||
prettyVersion = getPrettyVersion();
|
||||
|
||||
long lastUpdated;
|
||||
try {
|
||||
lastUpdated = Long.parseLong(properties.get("lastUpdated"));
|
||||
}
|
||||
catch (NumberFormatException nfe) {
|
||||
lastUpdated = getLastUpdated();
|
||||
// Better comment these out till all contribs have a lastUpdated
|
||||
// System.err.println("The last updated date for the “" + name
|
||||
// + "” contribution is not set properly.");
|
||||
// System.err
|
||||
// .println("Please contact the author to fix it according to the guidelines.");
|
||||
}
|
||||
|
||||
if (propFile.delete() && propFile.createNewFile() && propFile.setWritable(true)) {
|
||||
PrintWriter writer = PApplet.createWriter(propFile);
|
||||
|
||||
@@ -256,6 +276,7 @@ class AvailableContribution extends Contribution {
|
||||
writer.println("paragraph=" + paragraph);
|
||||
writer.println("version=" + version);
|
||||
writer.println("prettyVersion=" + prettyVersion);
|
||||
writer.println("lastUpdated=" + lastUpdated);
|
||||
|
||||
writer.flush();
|
||||
writer.close();
|
||||
|
||||
@@ -43,6 +43,7 @@ abstract public class Contribution {
|
||||
protected String paragraph; // <paragraph length description for site>
|
||||
protected int version; // 102
|
||||
protected String prettyVersion; // "1.0.2"
|
||||
protected long lastUpdated; // 1402805757
|
||||
|
||||
|
||||
// "Sound"
|
||||
@@ -120,6 +121,11 @@ abstract public class Contribution {
|
||||
public String getPrettyVersion() {
|
||||
return prettyVersion;
|
||||
}
|
||||
|
||||
// 1402805757
|
||||
public long getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
|
||||
|
||||
abstract public ContributionType getType();
|
||||
|
||||
@@ -407,6 +407,24 @@ public class ContributionListing {
|
||||
}
|
||||
|
||||
|
||||
String getLatestVersion(Contribution contribution) {
|
||||
Contribution newestContrib = getAvailableContribution(contribution);
|
||||
String latestVersion = newestContrib.getPrettyVersion();
|
||||
if (latestVersion != null && !latestVersion.isEmpty()) {
|
||||
if (latestVersion.toLowerCase().startsWith("build")) // For Python mode
|
||||
return ("v" + latestVersion.substring(5, latestVersion.indexOf(','))
|
||||
.trim());
|
||||
else if (latestVersion.toLowerCase().startsWith("v")) // For ketai library
|
||||
return latestVersion;
|
||||
else
|
||||
return ("v" + latestVersion);
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
boolean hasDownloadedLatestList() {
|
||||
return hasDownloadedLatestList;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.Date;
|
||||
import java.text.DateFormat;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
@@ -359,6 +361,29 @@ class ContributionPanel extends JPanel {
|
||||
}
|
||||
description.append(sentence);
|
||||
}
|
||||
|
||||
String version = contrib.getPrettyVersion();
|
||||
|
||||
if (version != null && !version.isEmpty()) {
|
||||
description.append("<br/>");
|
||||
if (version.toLowerCase().startsWith("build")) // For Python mode
|
||||
description.append("v"
|
||||
+ version.substring(5, version.indexOf(',')).trim());
|
||||
else if (version.toLowerCase().startsWith("v")) // For ketai library
|
||||
description.append(version);
|
||||
else
|
||||
description.append("v" + version);
|
||||
}
|
||||
|
||||
long lastUpdatedUTC = contrib.getLastUpdated();
|
||||
if (lastUpdatedUTC != 0) {
|
||||
DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.MEDIUM);
|
||||
Date lastUpdatedDate = new Date(lastUpdatedUTC);
|
||||
if (version != null && !version.isEmpty())
|
||||
description.append(", ");
|
||||
description.append("Last Updated on " + dateFormatter.format(lastUpdatedDate));
|
||||
}
|
||||
|
||||
description.append("</body></html>");
|
||||
//descriptionText.setText(description.toString());
|
||||
descriptionBlock.setText(description.toString());
|
||||
@@ -371,7 +396,11 @@ class ContributionPanel extends JPanel {
|
||||
// Already marked for deletion, see requiresRestart() notes below.
|
||||
versionText.append("To finish an update, reinstall this contribution after restarting.");
|
||||
} else {
|
||||
versionText.append("New version available!");
|
||||
String latestVersion = contribListing.getLatestVersion(contrib);
|
||||
if (latestVersion != null)
|
||||
versionText.append("New version (" + latestVersion + ") available!");
|
||||
else
|
||||
versionText.append("New version available!");
|
||||
if (contrib.getType().requiresRestart()) {
|
||||
// If a contribution can't be reinstalled in-place, the user may need
|
||||
// to remove the current version, restart Processing, then install.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
@@ -74,6 +74,15 @@ public abstract class LocalContribution extends Contribution {
|
||||
System.err.println("Please contact the library author to fix it according to the guidelines.");
|
||||
}
|
||||
prettyVersion = properties.get("prettyVersion");
|
||||
try {
|
||||
lastUpdated = Long.parseLong(properties.get("lastUpdated"));
|
||||
} catch (NumberFormatException e) {
|
||||
lastUpdated = 0;
|
||||
|
||||
// Better comment these out till all contribs have a lastUpdated
|
||||
// System.err.println("The last updated timestamp for the “" + name + "” library is not set properly.");
|
||||
// System.err.println("Please contact the library author to fix it according to the guidelines.");
|
||||
}
|
||||
|
||||
} else {
|
||||
Base.log("No properties file at " + propertiesFile.getAbsolutePath());
|
||||
|
||||
Reference in New Issue
Block a user