Merge branch 'test_paolo_JAL-1065' into Tcoffee_JAL-1065
[jalview.git] / src / jalview / gui / Jalview2XML.java
index cb29ab5..b1b1f55 100644 (file)
@@ -38,6 +38,7 @@ import jalview.datamodel.SequenceI;
 import jalview.schemabinding.version2.*;
 import jalview.schemes.*;
 import jalview.structure.StructureSelectionManager;
+import jalview.util.Platform;
 import jalview.util.jarInputStreamProvider;
 
 /**
@@ -612,7 +613,8 @@ public class Jalview2XML
 
                 for (int smap = 0; smap < jmol.jmb.sequence[peid].length; smap++)
                 {
-                  if (jal.findIndex(jmol.jmb.sequence[peid][smap]) > -1)
+//                  if (jal.findIndex(jmol.jmb.sequence[peid][smap]) > -1)
+                  if (jds==jmol.jmb.sequence[peid][smap])
                   {
                     StructureState state = new StructureState();
                     state.setVisible(true);
@@ -1822,9 +1824,9 @@ public class Jalview2XML
         }
         ;
         out.close();
-
-        alreadyLoadedPDB.put(pdbId, outFile.getAbsolutePath());
-        return outFile.getAbsolutePath();
+        String t=outFile.getAbsolutePath();
+        alreadyLoadedPDB.put(pdbId, t);
+        return t;
       }
       else
       {
@@ -2626,12 +2628,13 @@ public class Jalview2XML
               }
               if (ids[p].getFile() != null)
               {
+                File mapkey=new File(ids[p].getFile());
                 Object[] seqstrmaps = (Object[]) ((Hashtable) jmoldat[2])
-                        .get(ids[p].getFile());
+                        .get(mapkey);
                 if (seqstrmaps == null)
                 {
                   ((Hashtable) jmoldat[2]).put(
-                          new File(ids[p].getFile()).toString(),
+                          mapkey,
                           seqstrmaps = new Object[]
                           { pdbFile, ids[p].getId(), new Vector(),
                               new Vector() });
@@ -2664,7 +2667,7 @@ public class Jalview2XML
           Object[] svattrib = entry.getValue();
           int[] geom = (int[]) svattrib[0];
           String state = (String) svattrib[1];
-          Hashtable<String, Object[]> oldFiles = (Hashtable<String, Object[]>) svattrib[2];
+          Hashtable<File, Object[]> oldFiles = (Hashtable<File, Object[]>) svattrib[2];
           final boolean useinJmolsuperpos = ((boolean[]) svattrib[3])[0], usetoColourbyseq = ((boolean[]) svattrib[3])[1], jmolColouring = ((boolean[]) svattrib[3])[2];
           int x = geom[0], y = geom[1], width = geom[2], height = geom[3];
           // collate the pdbfile -> sequence mappings from this view
@@ -2728,6 +2731,8 @@ public class Jalview2XML
               {
                 newFileLoc = new StringBuffer();
               }
+              do {
+                // look for next filename in load statement
               newFileLoc.append(state.substring(cp,
                       ncp = (state.indexOf("\"", ncp + 1) + 1)));
               String oldfilenam = state.substring(ncp,
@@ -2735,9 +2740,8 @@ public class Jalview2XML
               // recover the new mapping data for this old filename
               // have to normalize filename - since Jmol and jalview do filename
               // translation differently.
-              Object[] filedat = oldFiles.get(new File(oldfilenam)
-                      .toString());
-              newFileLoc.append(((String) filedat[0]));
+              Object[] filedat = oldFiles.get(new File(oldfilenam));
+              newFileLoc.append(Platform.escapeString((String) filedat[0]));
               pdbfilenames.addElement((String) filedat[0]);
               pdbids.addElement((String) filedat[1]);
               seqmaps.addElement((SequenceI[]) ((Vector<SequenceI>) filedat[2])
@@ -2745,6 +2749,7 @@ public class Jalview2XML
               newFileLoc.append("\"");
               cp = ecp + 1; // advance beyond last \" and set cursor so we can
                             // look for next file statement.
+              } while ((ncp=state.indexOf("/*file*/",cp))>-1);
             }
             if (cp > 0)
             {
@@ -2757,7 +2762,7 @@ public class Jalview2XML
                       .print("Ignoring incomplete Jmol state for PDB ids: ");
               newFileLoc = new StringBuffer(state);
               newFileLoc.append("; load append ");
-              for (String id : oldFiles.keySet())
+              for (File id : oldFiles.keySet())
               {
                 // add this and any other pdb files that should be present in
                 // the viewer
@@ -2855,7 +2860,7 @@ public class Jalview2XML
 
             // add mapping for sequences in this view to an already open Jmol
             // instance
-            for (String id : oldFiles.keySet())
+            for (File id : oldFiles.keySet())
             {
               // add this and any other pdb files that should be present in the
               // viewer