JAL-3626 from JAL-3253-applet Cache applicationProperties made private
[jalview.git] / src / jalview / bin / Cache.java
index c532b7a..2c8986c 100755 (executable)
@@ -266,7 +266,7 @@ public class Cache
   public static Logger log;
 
   /** Jalview Properties */
-  public static Properties applicationProperties = new Properties()
+  private static Properties applicationProperties = new Properties()
   {
     // override results in properties output in alphabetical order
     @Override
@@ -333,6 +333,20 @@ public class Cache
    */
   public static void loadProperties(String propsFile)
   {
+    /* for JalviewJS should be 
+    
+    getInstance().
+    
+   */
+    loadPropertiesImpl(propsFile);
+    
+  }
+
+  private /* JalviewJS should not be static */
+  static //
+  void loadPropertiesImpl(String propsFile)
+  {
+    
     propertiesFile = propsFile;
     if (propsFile == null && !propsAreReadOnly)
     {
@@ -620,12 +634,17 @@ public class Cache
    */
   public static String getProperty(String key)
   {
-    String prop = applicationProperties.getProperty(key);
-    if (prop == null && Platform.isJS())
-    {
-      prop = applicationProperties.getProperty(Platform.getUniqueAppletID()
-              + "_" + JS_PROPERTY_PREFIX + key);
-    }
+    String prop =     /* for JalviewJS should be 
+    
+    getInstance().
+    
+   */
+            applicationProperties.getProperty(key);
+//    if (prop == null && Platform.isJS())
+//    {
+//      prop = applicationProperties.getProperty(Platform.getUniqueAppletID()
+//              + "_" + JS_PROPERTY_PREFIX + key);
+//    }
     return prop;
   }
 
@@ -704,14 +723,53 @@ public class Cache
   }
 
   /**
-   * remove the specified property from the jalview properties file
+   * Removes the specified property from the jalview properties file
    * 
-   * @param string
+   * @param key
+   */
+  public static void removeProperty(String key)
+  {
+    /* for JalviewJS should be 
+    
+    getInstance().
+    
+   */
+    removePropertyImpl(key, true);
+  }
+
+  /**
+   * Removes the named property for the running application, without saving the
+   * properties file
+   * 
+   * BH noting that ColourMenuHelper calls this. If the intent is to save, 
+   * then simply chanet that call to removeProperty(key).
+   * 
+   * @param key
+   */
+  public static void removePropertyNoSave(String key)
+  {
+    /* for JalviewJS should be 
+    
+    getInstance().
+    
+   */
+    removePropertyImpl(key, false);
+  }
+
+  /**
+   * Removes the named property, and optionally saves the current properties to
+   * file
+   * 
+   * @param key
+   * @param andSave
    */
-  public static void removeProperty(String string)
+  private /* JalviewJS should not be static */
+  static //
+  void removePropertyImpl(String key, boolean andSave)
   {
-    applicationProperties.remove(string);
-    saveProperties();
+    applicationProperties.remove(key);
+    if (andSave)
+      saveProperties();
   }
 
   /**
@@ -1102,6 +1160,11 @@ public class Cache
     {
       if (coloursFound.toString().length() > 1)
       {
+        /* for JalviewJS should be 
+        
+        getInstance().
+        
+       */
         setProperty(UserDefinedColours.USER_DEFINED_COLOURS,
                 coloursFound.toString());
       }
@@ -1177,7 +1240,7 @@ public class Cache
   
   /**
    * 
-   * For AppletParams
+   * For AppletParams and Preferences ok_actionPerformed and startupFileTextfield_mouseClicked
    * 
    * Sets a property value for the running application, without saving it to the
    * properties file