minor formatting of tooltip
[jalview.git] / src / jalview / gui / Jalview2XML.java
index 198db44..9bf6a21 100755 (executable)
@@ -351,14 +351,14 @@ public class Jalview2XML
           pdb.setId(entry.getId());
           pdb.setType(entry.getType());
 
-          AppJMol jmol;
+          AppJmol jmol;
           //This must have been loaded, is it still visible?
           JInternalFrame[] frames = Desktop.desktop.getAllFrames();
           for (int f = frames.length - 1; f > -1; f--)
           {
-            if (frames[f] instanceof AppJMol)
+            if (frames[f] instanceof AppJmol)
             {
-              jmol = (AppJMol) frames[f];
+              jmol = (AppJmol) frames[f];
               if (!jmol.pdbentry.getId().equals(entry.getId()))
                 continue;
 
@@ -986,6 +986,8 @@ public class Jalview2XML
 
     Hashtable gatherToThisFrame = new Hashtable();
 
+    String errorMessage = null;
+
     try
     {
       //UNMARSHALLER SEEMS TO CLOSE JARINPUTSTREAM, MOST ANNOYING
@@ -1040,22 +1042,19 @@ public class Jalview2XML
       }
       while (jarentry != null);
     }
+    catch(java.io.FileNotFoundException ex)
+    {
+      ex.printStackTrace();
+      errorMessage = "Couldn't locate Jalview XML file : "+file;
+      System.err.println("Exception whilst loading jalview XML file : " +
+                         ex + "\n");
+    }
     catch (java.net.UnknownHostException ex)
     {
       ex.printStackTrace();
-      System.err.println("Couldn't locate Jalview XML file : " +
+      errorMessage = "Couldn't locate Jalview XML file : " +file;
+      System.err.println("Exception whilst loading jalview XML file : " +
                          ex + "\n");
-
-      javax.swing.SwingUtilities.invokeLater(new Runnable()
-      {
-        public void run()
-        {
-          JOptionPane.showInternalMessageDialog(Desktop.desktop,
-                                                "Couldn't locate " + file,
-                                                "URL not found",
-                                                JOptionPane.WARNING_MESSAGE);
-        }
-      });
     }
     catch (Exception ex)
     {
@@ -1071,17 +1070,6 @@ public class Jalview2XML
 
       System.err.println("Exception whilst loading jalview XML file : " +
                          ex + "\n");
-      javax.swing.SwingUtilities.invokeLater(new Runnable()
-      {
-        public void run()
-        {
-
-          JOptionPane.showInternalMessageDialog(Desktop.desktop,
-                                                "Error loading  " + file,
-                                                "Error loading Jalview file",
-                                                JOptionPane.WARNING_MESSAGE);
-        }
-      });
     }
 
     if (Desktop.instance != null)
@@ -1096,6 +1084,21 @@ public class Jalview2XML
           (AlignFrame) en.nextElement());
     }
 
+    if(errorMessage!=null)
+    {
+      final String finalErrorMessage = errorMessage;
+      javax.swing.SwingUtilities.invokeLater(new Runnable()
+      {
+        public void run()
+        {
+          JOptionPane.showInternalMessageDialog(Desktop.desktop,
+                                                finalErrorMessage,
+                                                "Error loading Jalview file",
+                                                JOptionPane.WARNING_MESSAGE);
+        }
+      });
+    }
+
     return af;
   }
 
@@ -1884,16 +1887,36 @@ public class Jalview2XML
               int width = ids[p].getStructureState(s).getWidth();
               int height = ids[p].getStructureState(s).getHeight();
 
-              java.awt.Component comp = Desktop.desktop.getComponentAt(x, y);
+              java.awt.Component comp = null;
+
+              JInternalFrame [] frames = Desktop.desktop.getAllFrames();
+              for(int f=0; f<frames.length; f++)
+              {
+                if(frames[f] instanceof AppJmol)
+                {
+                  if (frames[f].getX() == x && frames[f].getY() == y
+                      && frames[f].getHeight() == height
+                      && frames[f].getWidth() == width)
+                  {
+                    comp = frames[f];
+                    break;
+                  }
+                }
+              }
+
+
+              Desktop.desktop.getComponentAt(x, y);
 
               String pdbFile = loadPDBFile(file, ids[p].getId());
 
-              jalview.datamodel.SequenceI[] seq = new jalview.datamodel.SequenceI[]
+              jalview.datamodel.SequenceI[] seq = new jalview.datamodel.
+                  SequenceI[]
                   {
-                  al.getSequenceAt(i)};
+                   (jalview.datamodel.SequenceI)
+                  seqRefIds.get(JSEQ[i].getId()+"")};
+
 
-              if (comp == null ||
-                  (comp.getWidth() != width && comp.getHeight() != height))
+              if (comp == null)
               {
                 String state = ids[p].getStructureState(s).getContent();
 
@@ -1904,7 +1927,7 @@ public class Jalview2XML
                 newFileLoc.append(state.substring(
                     state.indexOf("\"", state.indexOf("load \"") + 6)));
 
-                new AppJMol(pdbFile,
+                new AppJmol(pdbFile,
                             ids[p].getId(),
                             seq,
                             af.alignPanel,
@@ -1918,7 +1941,7 @@ public class Jalview2XML
                     .setMapping(seq, null, pdbFile,
                                 jalview.io.AppletFormatAdapter.FILE);
 
-                ( (AppJMol) comp).addSequence(seq);
+                ( (AppJmol) comp).addSequence(seq);
               }
             }
           }