X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FCache.java;h=6b1aef949e6dc1d90cc6b217fcd0487a9b9a3380;hb=b0cee3aaf7d8873910939f97b6acb217d518968d;hp=4be78302bbacc10b62ed83a86438be1a081c927d;hpb=65c671b0263c0c692a4a0a0905a4acc2fc6b1065;p=jalview.git diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 4be7830..6b1aef9 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -22,6 +22,7 @@ package jalview.bin; import jalview.datamodel.PDBEntry; import jalview.structure.StructureImportSettings; +import jalview.util.ColorUtils; import jalview.ws.dbsources.das.api.DasSourceRegistryI; import jalview.ws.dbsources.das.datamodel.DasSourceRegistry; import jalview.ws.sifts.SiftsSettings; @@ -38,6 +39,7 @@ import java.text.SimpleDateFormat; import java.util.Collections; import java.util.Date; import java.util.Enumeration; +import java.util.Locale; import java.util.Properties; import java.util.TreeSet; @@ -227,16 +229,25 @@ public class Cache private final static String DEFAULT_CACHE_THRESHOLD_IN_DAYS = "2"; private final static String DEFAULT_FAIL_SAFE_PID_THRESHOLD = "30"; - + /** * Allowed values are PDB or mmCIF */ - private final static String DEFAULT_STRUCTURE_FORMAT = PDBEntry.Type.MMCIF + private final static String PDB_DOWNLOAD_FORMAT = PDBEntry.Type.MMCIF .toString(); private final static String DEFAULT_PDB_FILE_PARSER = StructureImportSettings.StructureParser.JMOL_PARSER .toString(); + /* + * a date formatter using a fixed (rather than the user's) locale; + * this ensures that date properties can be written and re-read successfully + * even if the user changes their locale setting + */ + private static final DateFormat date_format = SimpleDateFormat + .getDateTimeInstance(SimpleDateFormat.MEDIUM, + SimpleDateFormat.MEDIUM, Locale.UK); + /** * Initialises the Jalview Application Log */ @@ -434,11 +445,12 @@ public class Cache .println("Jalview Version: " + codeVersion + codeInstallation); StructureImportSettings.setDefaultStructureFileFormat(jalview.bin.Cache - .getDefault( - "DEFAULT_STRUCTURE_FORMAT", DEFAULT_STRUCTURE_FORMAT)); + .getDefault("PDB_DOWNLOAD_FORMAT", PDB_DOWNLOAD_FORMAT)); StructureImportSettings - .setDefaultPDBFileParser(jalview.bin.Cache.getDefault( - "DEFAULT_PDB_FILE_PARSER", DEFAULT_PDB_FILE_PARSER)); + .setDefaultPDBFileParser(DEFAULT_PDB_FILE_PARSER); + // StructureImportSettings + // .setDefaultPDBFileParser(jalview.bin.Cache.getDefault( + // "DEFAULT_PDB_FILE_PARSER", DEFAULT_PDB_FILE_PARSER)); // jnlpVersion will be null if we're using InstallAnywhere // Dont do this check if running in headless mode if (jnlpVersion == null @@ -857,19 +869,11 @@ public class Cache { return defcolour; } - Color col = jalview.schemes.ColourSchemeProperty - .getAWTColorFromName(colprop); + Color col = ColorUtils.parseColourString(colprop); if (col == null) { - try - { - col = new jalview.schemes.UserColourScheme(colprop).findColour('A'); - } catch (Exception ex) - { - log.warn("Couldn't parse '" + colprop + "' as a colour for " - + property); - col = null; - } + log.warn("Couldn't parse '" + colprop + "' as a colour for " + + property); } return (col == null) ? defcolour : col; } @@ -885,30 +889,31 @@ public class Cache setProperty(property, jalview.util.Format.getHexString(colour)); } - public static final DateFormat date_format = SimpleDateFormat - .getDateTimeInstance(); - /** - * store a date in a jalview property + * Stores a formatted date in a jalview property, using a fixed locale. * - * @param string - * @param time + * @param propertyName + * @param date + * @return the formatted date string */ - public static void setDateProperty(String property, Date time) + public static String setDateProperty(String propertyName, Date date) { - setProperty(property, date_format.format(time)); + String formatted = date_format.format(date); + setProperty(propertyName, formatted); + return formatted; } /** - * read a date stored in a jalview property + * Reads a date stored in a Jalview property, parses it (using a fixed locale + * format) and returns as a Date, or null if parsing fails * - * @param property - * @return valid date as stored by setDateProperty, or null + * @param propertyName + * @return * */ - public static Date getDateProperty(String property) + public static Date getDateProperty(String propertyName) { - String val = getProperty(property); + String val = getProperty(propertyName); if (val != null) { try @@ -917,7 +922,7 @@ public class Cache } catch (Exception ex) { System.err.println("Invalid or corrupt date in property '" - + property + "' : value was '" + val + "'"); + + propertyName + "' : value was '" + val + "'"); } } return null;