Merge branch 'develop' into update_212_Dec_merge_with_21125_chamges
[jalview.git] / src / jalview / gui / ChimeraViewFrame.java
index 34410f1..62e7b38 100644 (file)
@@ -39,7 +39,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;
@@ -75,10 +75,11 @@ public class ChimeraViewFrame extends StructureViewerBase
 
   private int myHeight = 150;
 
-  private JMenuItem writeFeatures=null;
+  private JMenuItem writeFeatures = null;
 
-  private JMenu fetchAttributes=null;
-/**
+  private JMenu fetchAttributes = null;
+
+  /**
    * Initialise menu options.
    */
   @Override
@@ -91,8 +92,8 @@ public class ChimeraViewFrame extends StructureViewerBase
 
     writeFeatures = new JMenuItem(
             MessageManager.getString("label.create_viewer_attributes"));
-    writeFeatures.setToolTipText(MessageManager
-            .getString("label.create_viewer_attributes_tip"));
+    writeFeatures.setToolTipText(
+            MessageManager.getString("label.create_viewer_attributes_tip"));
     writeFeatures.addActionListener(new ActionListener()
     {
       @Override
@@ -103,10 +104,10 @@ public class ChimeraViewFrame extends StructureViewerBase
     });
     viewerActionMenu.add(writeFeatures);
 
-    fetchAttributes = new JMenu(
-            MessageManager.getString("label.fetch_chimera_attributes"));
-    fetchAttributes.setToolTipText(
-            MessageManager.getString("label.fetch_chimera_attributes_tip"));
+    fetchAttributes = new JMenu(MessageManager.formatMessage(
+            "label.fetch_viewer_attributes", getViewerName()));
+    fetchAttributes.setToolTipText(MessageManager.formatMessage(
+            "label.fetch_viewer_attributes_tip", getViewerName()));
     fetchAttributes.addMouseListener(new MouseAdapter()
     {
 
@@ -126,8 +127,9 @@ public class ChimeraViewFrame extends StructureViewerBase
     // add these back in after menu is refreshed
     viewerActionMenu.add(writeFeatures);
     viewerActionMenu.add(fetchAttributes);
-    
+
   };
+
   /**
    * Query the structure viewer for its residue attribute names and add them as
    * items off the attributes menu
@@ -166,8 +168,8 @@ public class ChimeraViewFrame extends StructureViewerBase
   {
     // todo pull up?
     int count = jmb.sendFeaturesToViewer(getAlignmentPanel());
-    statusBar.setText(
-            MessageManager.formatMessage("label.attributes_set", count));
+    statusBar.setText(MessageManager.formatMessage("label.attributes_set",
+            count, getViewerName()));
   }
 
   /**
@@ -293,8 +295,7 @@ public class ChimeraViewFrame extends StructureViewerBase
    * @param ap
    */
   public ChimeraViewFrame(PDBEntry[] pe, boolean alignAdded,
-          SequenceI[][] seqs,
-          AlignmentPanel ap)
+          SequenceI[][] seqs, AlignmentPanel ap)
   {
     this();
     setAlignAddedStructures(alignAdded);
@@ -333,6 +334,7 @@ public class ChimeraViewFrame extends StructureViewerBase
                       getViewerName()),
               MessageManager.getString("label.error_loading_file"),
               JvOptionPane.ERROR_MESSAGE);
+      jmb.closeViewer(true);
       this.dispose();
       return;
     }
@@ -443,9 +445,15 @@ public class ChimeraViewFrame extends StructureViewerBase
           initChimera();
         } catch (Exception ex)
         {
-          Cache.log.error("Couldn't open Chimera viewer!", ex);
+          Console.error("Couldn't open Chimera viewer!", ex);
         }
       }
+      if (!jmb.isViewerRunning())
+      {
+        // nothing to do
+        // TODO: ensure we tidy up JAL-3619
+        return;
+      }
       int num = -1;
       for (PDBEntry pe : filePDB)
       {
@@ -488,12 +496,12 @@ public class ChimeraViewFrame extends StructureViewerBase
                     oomerror);
           } catch (Exception ex)
           {
-            Cache.log.error(
+            Console.error(
                     "Couldn't open " + pe.getFile() + " in Chimera viewer!",
                     ex);
           } finally
           {
-            Cache.log.debug("File locations are " + files);
+            Console.debug("File locations are " + files);
           }
         }
       }