Merge branch 'jims/bug/JAL-4298_java_console_causing_hang_at_startup' into develop
[jalview.git] / src / jalview / bin / Cache.java
index 1abb171..483b1fc 100755 (executable)
@@ -54,6 +54,8 @@ import javax.swing.LookAndFeel;
 import javax.swing.UIManager;
 
 import jalview.analytics.Plausible;
+import jalview.bin.argparser.Arg;
+import jalview.bin.argparser.ArgParser;
 import jalview.datamodel.PDBEntry;
 import jalview.gui.Preferences;
 import jalview.gui.UserDefinedColours;
@@ -1663,27 +1665,36 @@ public class Cache
     }
     if (file == null || !file.exists())
     {
+      if (file != null)
+      {
+        jalview.bin.Console
+                .errPrintln("Could not load bootstrap preferences file '"
+                        + file.getPath() + "'");
+      }
       String channelPrefsFilename = ChannelProperties
               .getProperty("preferences.filename");
       String propertiesFilename = System.getProperty("user.home")
               + File.separatorChar + channelPrefsFilename;
+      jalview.bin.Console.errPrintln(
+              "Using default properties file '" + propertiesFilename + "'");
       file = new File(propertiesFilename);
     }
     if (file == null || !file.exists())
+
     {
       String releasePrefsFilename = fallbackPropertiesFile;
       String releasePropertiesFilename = System.getProperty("user.home")
               + File.separatorChar + releasePrefsFilename;
+      jalview.bin.Console.errPrintln("Falling back to properties file '"
+              + releasePropertiesFilename + "'");
       file = new File(releasePropertiesFilename);
     }
 
-    if (filename == null)
-      return null;
     if (!file.exists())
     {
       jalview.bin.Console
               .errPrintln("Could not load bootstrap preferences file '"
-                      + filename + "'");
+                      + file.getPath() + "'");
       return null;
     }
 
@@ -1723,4 +1734,10 @@ public class Cache
   {
     return key == null ? null : sessionProperties.get(key);
   }
+
+  public static boolean getArgCacheDefault(Arg a, String pref, boolean def)
+  {
+    ArgParser ap = Jalview.getInstance().getArgParser();
+    return ap.isSet(a) ? ap.getBoolean(a) : getDefault(pref, def);
+  }
 }