JAL-3619 fix up error messages and try to bail quietly if the viewer doesn’t open
[jalview.git] / src / jalview / gui / PymolViewer.java
index efbd155..2fd4957 100644 (file)
@@ -14,7 +14,7 @@ import javax.swing.event.InternalFrameEvent;
 
 import jalview.api.AlignmentViewPanel;
 import jalview.api.FeatureRenderer;
-import jalview.bin.Cache;
+import jalview.bin.Console;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
 import jalview.datamodel.StructureViewerModel;
@@ -210,9 +210,19 @@ public class PymolViewer extends StructureViewerBase
           initPymol();
         } catch (Exception ex)
         {
-          Cache.error("Couldn't open PyMOL viewer!", ex);
+          Console.error("Couldn't open PyMOL viewer!", ex);
+          // if we couldn't open Pymol, no point continuing
+          return;
         }
       }
+      if (!binding.isViewerRunning())
+      {
+        // nothing to do
+        // TODO: ensure we tidy up JAL-3619
+
+        return;
+      }
+
       int num = -1;
       for (PDBEntry pe : filePDB)
       {
@@ -249,8 +259,8 @@ public class PymolViewer extends StructureViewerBase
             binding.stashFoundChains(pdb, pe.getFile());
           } catch (Exception ex)
           {
-            Cache.error(
-                    "Couldn't open " + pe.getFile() + " in Chimera viewer!",
+            Console.error(
+                    "Couldn't open " + pe.getFile() + " in "+getViewerName()+"!",
                     ex);
           } finally
           {
@@ -314,6 +324,7 @@ public class PymolViewer extends StructureViewerBase
                       getViewerName()),
               MessageManager.getString("label.error_loading_file"),
               JvOptionPane.ERROR_MESSAGE);
+      binding.closeViewer(true);
       this.dispose();
       return;
     }
@@ -323,7 +334,7 @@ public class PymolViewer extends StructureViewerBase
       boolean opened = binding.openSession(pymolSessionFile);
       if (!opened)
       {
-        Cache.error(
+        Console.error(
                 "An error occurred opening PyMOL session file "
                 + pymolSessionFile);
       }