JAL-3616 explicit configure external viewer config
authorJim Procter <j.procter@dundee.ac.uk>
Fri, 1 Oct 2021 16:32:20 +0000 (17:32 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Fri, 1 Oct 2021 16:32:20 +0000 (17:32 +0100)
src/jalview/gui/Preferences.java

index e3e3932..baed0df 100755 (executable)
@@ -446,11 +446,27 @@ public class Preferences extends GPreferences
       {
         if (validateViewerPath())
         {
-          Cache.setProperty(
-                  structViewer.getSelectedItem().equals(
-                          ViewerType.CHIMERAX.name()) ? CHIMERAX_PATH
-                                  : CHIMERA_PATH,
-                  structureViewerPath.getText());
+          String path = structureViewerPath.getText();
+          try {
+          ViewerType type = ViewerType.valueOf(viewerType);
+          switch (type)
+          {
+          case JMOL:
+            break;
+          case CHIMERA:
+            Cache.setProperty(CHIMERA_PATH, path);
+            break;
+          case CHIMERAX:
+            Cache.setProperty(CHIMERAX_PATH, path);
+            break;
+          case PYMOL:
+            Cache.setProperty(PYMOL_PATH, path);
+            break;
+          }
+        } catch (IllegalArgumentException x)
+        {
+          Cache.log.error("Failed to set path - unknown viewer type",x);
+        }
         }
       }
     });