Merge branch 'features/JAL-1605_html-svg-export' into develop
[jalview.git] / src / ext / edu / ucsf / rbvi / strucviz2 / StructureManager.java
index ec956d7..4797b37 100644 (file)
@@ -1,12 +1,14 @@
 package ext.edu.ucsf.rbvi.strucviz2;
 
+import jalview.bin.Cache;
+import jalview.gui.Preferences;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -32,10 +34,6 @@ public class StructureManager
   static final String[] defaultResidueKeys =
   { "FunctionalResidues", "ResidueList", "Residues" };
 
-  private final String chimeraPropertyName = "chimera";
-
-  private final String chimeraPathPropertyKey = "LastChimeraPath";
-
   public enum ModelType
   {
     PDB_MODEL, MODBASE_MODEL, SMILES
@@ -494,7 +492,9 @@ public class StructureManager
       // we do not care about the model anymore
       selSpec = selSpec.concat(nodeInfo.toSpec());
       if (i < chimSelectionList.size() - 1)
+      {
         selSpec.concat("|");
+      }
     }
     if (selSpec.length() > 0)
     {
@@ -665,7 +665,9 @@ public class StructureManager
     for (ChimeraStructuralObject cso : chimSelectionList)
     {
       if (cso != null)
+      {
         cso.setSelected(false);
+      }
     }
     chimSelectionList.clear();
   }
@@ -862,34 +864,35 @@ public class StructureManager
   StructureSettings defaultSettings = null;
 
   // TODO: [Optional] Change priority of Chimera paths
-  public List<String> getChimeraPaths()
+  public static List<String> getChimeraPaths()
   {
     List<String> pathList = new ArrayList<String>();
 
     // if no network is available and the settings have been modified by the
     // user, check for a
     // path to chimera
-    if (defaultSettings != null)
-    {
-      String defaultPath = defaultSettings.getChimeraPath();
-      if (defaultPath != null && !defaultPath.equals(""))
-      {
-        pathList.add(defaultPath);
-        return pathList;
-      }
-    }
-
-    // if no network settings, check if the last chimera path is saved in the
-    // session
-    // String lastPath = CytoUtils.getDefaultChimeraPath(registrar,
-    // chimeraPropertyName,
-    // chimeraPathPropertyKey);
-    // if (lastPath != null && !lastPath.equals("")) {
-    // pathList.add(lastPath);
+    //
+    // For Jalview, Preferences/Cache plays this role instead
+    // if (defaultSettings != null)
+    // {
+    // String defaultPath = defaultSettings.getChimeraPath();
+    // if (defaultPath != null && !defaultPath.equals(""))
+    // {
+    // pathList.add(defaultPath);
     // return pathList;
     // }
+    // }
+
+    /*
+     * Jalview addition: check if path set in user preferences.
+     */
+    String userPath = Cache.getDefault(Preferences.CHIMERA_PATH, null);
+    if (userPath != null)
+    {
+      pathList.add(0, userPath);
+    }
 
-    // if no user settings and no last path, get default system's settings
+    // Add default installation paths
     String os = System.getProperty("os.name");
     if (os.startsWith("Linux"))
     {