From 0b6159156c6c11a68d8873573c014012db66f966 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Mon, 9 Jun 2014 19:42:49 +0530 Subject: [PATCH 1/4] Version nos. display below tool/lib/mode --- .../processing/app/contrib/ContributionPanel.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index ca6f2da4e..ff5424e2a 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -359,6 +359,20 @@ class ContributionPanel extends JPanel { } description.append(sentence); } + + String version = contrib.getPrettyVersion(); + + if (version != null && !version.isEmpty()) { + description.append("
"); + 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); + } + description.append(""); //descriptionText.setText(description.toString()); descriptionBlock.setText(description.toString()); From 588d2462791702da68b6248389eaf95a57d243e2 Mon Sep 17 00:00:00 2001 From: Joel Moniz Date: Wed, 11 Jun 2014 23:42:22 +0530 Subject: [PATCH 2/4] Added version number in new version available msg --- .../app/contrib/ContributionListing.java | 18 ++++++++++++++++++ .../app/contrib/ContributionPanel.java | 6 +++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/contrib/ContributionListing.java b/app/src/processing/app/contrib/ContributionListing.java index 8d5ccf653..65c16048f 100644 --- a/app/src/processing/app/contrib/ContributionListing.java +++ b/app/src/processing/app/contrib/ContributionListing.java @@ -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; } diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index ff5424e2a..e4d46c7ac 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -385,7 +385,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. From 2aedcb765388459c9e43c77ee8db448159a86bcc Mon Sep 17 00:00:00 2001 From: Joel Moniz Date: Sat, 14 Jun 2014 15:32:04 +0530 Subject: [PATCH 3/4] "Last Updated" shows if "lastUpdated" field is present lastUpdate field is a Unix Timestamp in millisecs TODO: Add lastUpdated everywhere in contributions.txt, .properties file --- .../app/contrib/AvailableContribution.java | 12 ++++++++++-- app/src/processing/app/contrib/Contribution.java | 6 ++++++ .../processing/app/contrib/ContributionPanel.java | 11 +++++++++++ .../processing/app/contrib/LocalContribution.java | 9 ++++++++- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/app/src/processing/app/contrib/AvailableContribution.java b/app/src/processing/app/contrib/AvailableContribution.java index f2d3efe65..639cbe9db 100644 --- a/app/src/processing/app/contrib/AvailableContribution.java +++ b/app/src/processing/app/contrib/AvailableContribution.java @@ -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; + } } @@ -235,8 +242,8 @@ class AvailableContribution extends Contribution { version = Integer.parseInt(properties.get("version")); } catch (NumberFormatException e) { version = getVersion(); - System.err.println("The version number for the “" + name - + "” library is not set properly."); + System.err.println("The version number for the " + name + + " library is not set properly."); System.err .println("Please contact the library author to fix it according to the guidelines."); } @@ -256,6 +263,7 @@ class AvailableContribution extends Contribution { writer.println("paragraph=" + paragraph); writer.println("version=" + version); writer.println("prettyVersion=" + prettyVersion); + writer.println("lastUpdated=" + getLastUpdated()); writer.flush(); writer.close(); diff --git a/app/src/processing/app/contrib/Contribution.java b/app/src/processing/app/contrib/Contribution.java index 8367b98d3..9fc73c851 100644 --- a/app/src/processing/app/contrib/Contribution.java +++ b/app/src/processing/app/contrib/Contribution.java @@ -43,6 +43,7 @@ abstract public class Contribution { protected String paragraph; // 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(); diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index e4d46c7ac..37b4fb6b3 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -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; @@ -373,6 +375,15 @@ class ContributionPanel extends JPanel { 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(""); //descriptionText.setText(description.toString()); descriptionBlock.setText(description.toString()); diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index 03a6e0f31..7b485cde4 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -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,13 @@ 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; + 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()); From 84e248c23f2204e30c1cac43214601b033510e9c Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Sat, 26 Jul 2014 13:17:20 +0400 Subject: [PATCH 4/4] A few final changes to Last Updated --- .../app/contrib/AvailableContribution.java | 23 +++++++++++++++---- .../app/contrib/LocalContribution.java | 6 +++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/src/processing/app/contrib/AvailableContribution.java b/app/src/processing/app/contrib/AvailableContribution.java index 639cbe9db..44ed86888 100644 --- a/app/src/processing/app/contrib/AvailableContribution.java +++ b/app/src/processing/app/contrib/AvailableContribution.java @@ -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 @@ -242,16 +242,29 @@ class AvailableContribution extends Contribution { version = Integer.parseInt(properties.get("version")); } catch (NumberFormatException e) { version = getVersion(); - System.err.println("The version number for the " + name - + " library is not set properly."); + System.err.println("The version number for the “" + name + + "” 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); @@ -263,7 +276,7 @@ class AvailableContribution extends Contribution { writer.println("paragraph=" + paragraph); writer.println("version=" + version); writer.println("prettyVersion=" + prettyVersion); - writer.println("lastUpdated=" + getLastUpdated()); + writer.println("lastUpdated=" + lastUpdated); writer.flush(); writer.close(); diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index 7b485cde4..57ac2ffc9 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -78,8 +78,10 @@ public abstract class LocalContribution extends Contribution { lastUpdated = Long.parseLong(properties.get("lastUpdated")); } catch (NumberFormatException e) { lastUpdated = 0; - 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."); + + // 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 {