JAL=1759 fix Jmol state command bug; remove debug output
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 30 Jun 2015 18:16:55 +0000 (19:16 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 30 Jun 2015 18:16:55 +0000 (19:16 +0100)
src/jalview/ext/jmol/JalviewJmolBinding.java
src/jalview/gui/Jalview2XML.java

index ed0b950..c7496df 100644 (file)
@@ -478,7 +478,6 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     jmolHistory(false);
     if (lastCommand == null || !lastCommand.equals(command))
     {
-      System.out.println(command);
       viewer.evalStringQuiet(command + "\n");
     }
     jmolHistory(true);
index 62c9cad..2434b00 100644 (file)
  */
 package jalview.gui;
 
-import java.awt.Rectangle;
-import java.io.BufferedReader;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.Vector;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-import java.util.jar.JarOutputStream;
-
-import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-
-import org.exolab.castor.xml.Marshaller;
-import org.exolab.castor.xml.Unmarshaller;
-
 import jalview.api.structures.JalviewStructureDisplayI;
 import jalview.bin.Cache;
 import jalview.datamodel.AlignedCodonFrame;
@@ -128,6 +89,45 @@ import jalview.ws.params.ArgumentI;
 import jalview.ws.params.AutoCalcSetting;
 import jalview.ws.params.WsParamSetI;
 
+import java.awt.Rectangle;
+import java.io.BufferedReader;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+
+import javax.swing.JInternalFrame;
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
+import org.exolab.castor.xml.Marshaller;
+import org.exolab.castor.xml.Unmarshaller;
+
 /**
  * Write out the current jalview desktop state as a Jalview XML stream.
  * 
@@ -3807,16 +3807,23 @@ public class Jalview2XML
       newFileLoc.append(";");
     }
 
-    if (newFileLoc.length() > 0)
+    if (newFileLoc.length() == 0)
+    {
+      return;
+    }
+    int histbug = newFileLoc.indexOf("history = ");
+    if (histbug > -1)
     {
-      int histbug = newFileLoc.indexOf("history = ");
+      /*
+       * change "history = [true|false];" to "history = [1|0];"
+       */
       histbug += 10;
       int diff = histbug == -1 ? -1 : newFileLoc.indexOf(";", histbug);
       String val = (diff == -1) ? null : newFileLoc
               .substring(histbug, diff);
       if (val != null && val.length() >= 4)
       {
-        if (val.contains("e"))
+        if (val.contains("e")) // eh? what can it be?
         {
           if (val.trim().equals("true"))
           {
@@ -3829,53 +3836,53 @@ public class Jalview2XML
           newFileLoc.replace(histbug, diff, val);
         }
       }
+    }
 
-      final String[] pdbf = pdbfilenames.toArray(new String[pdbfilenames
-              .size()]);
-      final String[] id = pdbids.toArray(new String[pdbids.size()]);
-      final SequenceI[][] sq = seqmaps
-              .toArray(new SequenceI[seqmaps.size()][]);
-      final String fileloc = newFileLoc.toString();
-      final String sviewid = viewerData.getKey();
-      final AlignFrame alf = af;
-      final Rectangle rect = new Rectangle(svattrib.getX(),
-              svattrib.getY(), svattrib.getWidth(), svattrib.getHeight());
-      try
+    final String[] pdbf = pdbfilenames.toArray(new String[pdbfilenames
+            .size()]);
+    final String[] id = pdbids.toArray(new String[pdbids.size()]);
+    final SequenceI[][] sq = seqmaps
+            .toArray(new SequenceI[seqmaps.size()][]);
+    final String fileloc = newFileLoc.toString();
+    final String sviewid = viewerData.getKey();
+    final AlignFrame alf = af;
+    final Rectangle rect = new Rectangle(svattrib.getX(), svattrib.getY(),
+            svattrib.getWidth(), svattrib.getHeight());
+    try
+    {
+      javax.swing.SwingUtilities.invokeAndWait(new Runnable()
       {
-        javax.swing.SwingUtilities.invokeAndWait(new Runnable()
+        @Override
+        public void run()
         {
-          @Override
-          public void run()
+          JalviewStructureDisplayI sview = null;
+          try
           {
-            JalviewStructureDisplayI sview = null;
-            try
-            {
-              sview = new StructureViewer(alf.alignPanel
-                      .getStructureSelectionManager()).createView(
-                      StructureViewer.ViewerType.JMOL, pdbf, id, sq,
-                      alf.alignPanel, svattrib, fileloc, rect, sviewid);
-              addNewStructureViewer(sview);
-            } catch (OutOfMemoryError ex)
+            sview = new StructureViewer(alf.alignPanel
+                    .getStructureSelectionManager()).createView(
+                    StructureViewer.ViewerType.JMOL, pdbf, id, sq,
+                    alf.alignPanel, svattrib, fileloc, rect, sviewid);
+            addNewStructureViewer(sview);
+          } catch (OutOfMemoryError ex)
+          {
+            new OOMWarning("restoring structure view for PDB id " + id,
+                    (OutOfMemoryError) ex.getCause());
+            if (sview != null && sview.isVisible())
             {
-              new OOMWarning("restoring structure view for PDB id " + id,
-                      (OutOfMemoryError) ex.getCause());
-              if (sview != null && sview.isVisible())
-              {
-                sview.closeViewer(false);
-                sview.setVisible(false);
-                sview.dispose();
-              }
+              sview.closeViewer(false);
+              sview.setVisible(false);
+              sview.dispose();
             }
           }
-        });
-      } catch (InvocationTargetException ex)
-      {
-        warn("Unexpected error when opening Jmol view.", ex);
+        }
+      });
+    } catch (InvocationTargetException ex)
+    {
+      warn("Unexpected error when opening Jmol view.", ex);
 
-      } catch (InterruptedException e)
-      {
-        // e.printStackTrace();
-      }
+    } catch (InterruptedException e)
+    {
+      // e.printStackTrace();
     }
   }