"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
This commit is contained in:
Joel Moniz
2014-06-14 15:32:04 +05:30
committed by joelmoniz
parent 588d246279
commit 2aedcb7653
4 changed files with 35 additions and 3 deletions
@@ -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();
@@ -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();
@@ -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("</body></html>");
//descriptionText.setText(description.toString());
descriptionBlock.setText(description.toString());
@@ -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());