Mercurial > hg > release > thermostat-0.7
changeset 42:89f821df2f1b
generate information to be shown in about dialog at build time
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Tue, 17 Jan 2012 13:07:36 -0500 |
parents | 37f452bb08c5 |
children | fb343e1da209 |
files | app-info.properties build.xml src/com/redhat/thermostat/client/ApplicationInfo.java src/com/redhat/thermostat/client/strings.properties src/com/redhat/thermostat/client/ui/AboutDialog.java src/com/redhat/thermostat/client/ui/IconResource.java |
diffstat | 6 files changed, 65 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app-info.properties Tue Jan 17 13:07:36 2012 -0500 @@ -0,0 +1,9 @@ +APP_NAME = Thermostat +APP_VERSION = 0.0.1 +APP_EMAIL = distro-pkg-dev@icedtea.classpath.org +APP_WEBSITE = icedtea.classpath.org/wiki/Thermostat +APP_DESCRIPTION = A monitoring and servicability tool for OpenJDK +APP_RELEASE_DATE = 2012-02-02 +APP_COPYRIGHT = Copyright 2012 Red Hat, Inc. +APP_LICENSE_SUMMARY = GPLv2+ with Classpath exceptions +
--- a/build.xml Tue Jan 17 12:59:16 2012 -0500 +++ b/build.xml Tue Jan 17 13:07:36 2012 -0500 @@ -11,6 +11,8 @@ <property name="dist.dir" location="dist" /> <property name="javadoc.dir" location="${dist.dir}/doc/javadoc" /> + <property name="app-info.file" value="app-info.properties" /> + <property name="test.src.dir" location="test" /> <property name="test.build.dir" location="${build.dir}/test" /> <property name="reports.dir" location="reports" /> @@ -23,12 +25,14 @@ <property name="agent.jar" location="${dist.dir}/lib/thermostat-agent.jar" /> <property name="client-gui.jar" location="${dist.dir}/lib/thermostat-client-gui.jar" /> + <property name="thermostat.path.prefix" value="com/redhat/thermostat/" /> <property name="agent-main-class" value="com.redhat.thermostat.agent.Main" /> <property name="client-gui-main-class" value="com.redhat.thermostat.client.Main" /> <property name="junit.out.xml.dir" location="${reports.dir}/junit/xml" /> <property name="junit.out.html.dir" location="${reports.dir}/junit/html" /> + <!-- allow users/packagers to override our default directories --> <property file="custom-libs.properties" /> <!-- default locations for libraries --> @@ -70,6 +74,9 @@ <fileset dir="${src.dir}"> <include name="com/redhat/thermostat/common/**/*.properties" /> </fileset> + <zipfileset fullpath="${thermostat.path.prefix}${app-info.file}" + dir="." + includes="${app-info.file}" /> </jar> </target>
--- a/src/com/redhat/thermostat/client/ApplicationInfo.java Tue Jan 17 12:59:16 2012 -0500 +++ b/src/com/redhat/thermostat/client/ApplicationInfo.java Tue Jan 17 13:07:36 2012 -0500 @@ -1,55 +1,78 @@ package com.redhat.thermostat.client; +import static com.redhat.thermostat.client.Translate._; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.util.Date; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.Icon; import com.redhat.thermostat.client.ui.IconResource; +import com.redhat.thermostat.common.utils.LoggingUtils; public class ApplicationInfo { - /* - * TODO All of these fields should be generated on build. - */ + private static final Logger logger = LoggingUtils.getLogger(ApplicationInfo.class); + + private static final String APP_INFO_ROOT = "com/redhat/thermostat/"; + + private Properties appInfo; + + public ApplicationInfo() { + appInfo = new Properties(); + ClassLoader cl = this.getClass().getClassLoader(); + InputStream res = cl.getResourceAsStream(APP_INFO_ROOT + "app-info.properties"); + if (res != null) { + try { + appInfo.load(res); + } catch (IOException e) { + logger.log(Level.WARNING, "error loading application information", e); + } + } + } public String getName() { - return "thermostat"; + return appInfo.getProperty("APP_NAME", _("MISSING_INFO")); } public String getVersion() { - return "0.0.1"; + return appInfo.getProperty("APP_VERSION", _("MISSING_INFO")); } public String getDescription() { - return "A monitoring and servicability tool for OpenJDK"; + return appInfo.getProperty("APP_DESCRIPTION", _("MISSING_INFO")); } public Icon getIcon() { + String path = appInfo.getProperty("APP_ICON"); + if (new File(path).exists()) { + return IconResource.fromPath(path).getIcon(); + } return IconResource.QUESTION.getIcon(); } public String getReleaseDate() { - return "2012-02-02"; - } - - public String getBuildDate() { - return new Date().toString(); + return appInfo.getProperty("APP_RELEASE_DATE", _("MISSING_INFO")); } public String getCopyright() { - return "(C) Copyright Red Hat, Inc"; + return appInfo.getProperty("APP_COPYRIGHT", _("MISSING_INFO")); } - public String getLicense() { - return "GPL2 + Classpath"; + public String getLicenseSummary() { + return appInfo.getProperty("APP_LICENSE_SUMMARY", _("MISSING_INFO")); } public String getEmail() { - return "an@example.com"; + return appInfo.getProperty("APP_EMAIL", _("MISSING_INFO")); } public String getWebsite() { - return "http://an.example.com"; + return appInfo.getProperty("APP_WEBSITE", _("MISSING_INFO")); } }
--- a/src/com/redhat/thermostat/client/strings.properties Tue Jan 17 12:59:16 2012 -0500 +++ b/src/com/redhat/thermostat/client/strings.properties Tue Jan 17 13:07:36 2012 -0500 @@ -1,3 +1,5 @@ +MISSING_INFO = Missing Information + CONNECTION_FAILED_TO_CONNECT_TITLE = Failed to connect to data collector CONNECTION_FAILED_TO_CONNECT_DESCRIPTION = Thermostat failed to connect to the data collector. @@ -116,4 +118,4 @@ VM_GC_COLLECTOR_OVER_GENERATION = Collector {0} running on {1} VM_GC_COLLECTOR_CHART_REAL_TIME_LABEL = Time -VM_GC_COLLECTOR_CHART_GC_TIME_LABEL = Total Time Spent on GC \ No newline at end of file +VM_GC_COLLECTOR_CHART_GC_TIME_LABEL = Total Time Spent on GC
--- a/src/com/redhat/thermostat/client/ui/AboutDialog.java Tue Jan 17 12:59:16 2012 -0500 +++ b/src/com/redhat/thermostat/client/ui/AboutDialog.java Tue Jan 17 13:07:36 2012 -0500 @@ -36,11 +36,10 @@ String name = appInfo.getName(); String description = appInfo.getDescription(); String version = appInfo.getVersion(); - Icon icon = appInfo.getIcon(); + Icon icon = IconResource.QUESTION.getIcon(); // TODO appInfo.getIcon(); String releaseDate = appInfo.getReleaseDate(); - String buildDate = appInfo.getBuildDate(); String copyright = appInfo.getCopyright(); - String license = appInfo.getLicense(); + String license = appInfo.getLicenseSummary(); String email = appInfo.getEmail(); String website = appInfo.getWebsite();
--- a/src/com/redhat/thermostat/client/ui/IconResource.java Tue Jan 17 12:59:16 2012 -0500 +++ b/src/com/redhat/thermostat/client/ui/IconResource.java Tue Jan 17 13:07:36 2012 -0500 @@ -32,6 +32,11 @@ this.path = descriptor; } + public static IconResource fromPath(String path) { + // TODO implement this + return null; + } + public Icon getIcon() { if (new File(path).exists()) { return new ImageIcon(path);