private Properties channelProps = new Properties();
+ private static final Properties defaultProps;
+
private Map<String, Image> imageMap = new HashMap<String, Image>();
private static ChannelProperties instance;
private boolean initDone = false;
+ static
+ {
+ defaultProps = new Properties();
+ // these should be kept up to date, but in real life they should never
+ // actually be used anyway.
+ defaultProps.put("app_name", "Jalview");
+ defaultProps.put("banner", "/default_images/jalview_banner.png");
+ defaultProps.put("logo.16", "/default_images/jalview_logo-16.png");
+ defaultProps.put("logo.32", "/default_images/jalview_logo-32.png");
+ defaultProps.put("logo.38", "/default_images/jalview_logo-38.png");
+ defaultProps.put("logo.48", "/default_images/jalview_logo-48.png");
+ defaultProps.put("logo.64", "/default_images/jalview_logo-64.png");
+ defaultProps.put("logo.128", "/default_images/jalview_logo-128.png");
+ defaultProps.put("logo.256", "/default_images/jalview_logo-256.png");
+ defaultProps.put("logo.512", "/default_images/jalview_logo-512.png");
+ defaultProps.put("rotatable_logo.48",
+ "/default_images/rotatable_jalview_logo-38.png");
+ defaultProps.put("uod_banner", "/default_images/UoD_banner.png");
+ defaultProps.put("default_appbase",
+ "https://www.jalview.org/getdown/release/1.8");
+ }
+
private boolean init()
{
if (initDone)
if (channelPropsURL == null)
{
// fallback
- System.err.println(
- "Failed to find '" + CHANNEL_PROPERTIES_FILENAME + "' file");
+ System.err.println("Failed to find '" + CHANNEL_PROPERTIES_FILENAME
+ + "' filem using defaults");
+ channelProps = defaultProps;
return false;
}
else
return instance;
}
- public static String getProperty(String key)
- {
- return getProperty(key, null);
- }
-
private static Properties channelProps()
{
return getChannelProperties().channelProps;
return getChannelProperties().imageMap;
}
+ /*
+ * getProperty(key) will get property value from channel_properties for key.
+ * If no property for key is found, it will fall back to using the defaultProps defined for this class.
+ */
+ public static String getProperty(String key)
+ {
+ return getProperty(key, null, true);
+ }
+
+ /*
+ * getProperty(key, defaultVal) will get property value from channel_properties for key.
+ * If no property for key is found, it will return defaultVal and NOT fall back to the class defaultProps.
+ */
public static String getProperty(String key, String defaultVal)
{
+ return getProperty(key, defaultVal, false);
+ }
+
+ private static String getProperty(String key, String defaultVal,
+ boolean useClassDefaultProps)
+ {
if (channelProps() != null)
{
if (channelProps().containsKey(key))
{
- String val = channelProps().getProperty(key, "NOTFOUND");
- return channelProps().getProperty(key, defaultVal);
+ return channelProps().getProperty(key,
+ useClassDefaultProps ? defaultProps.getProperty(key)
+ : defaultVal);
}
else
{