3253-omnibus save
[jalview.git] / src / jalview / structure / StructureSelectionManager.java
index 82d66f2..d6eec47 100644 (file)
@@ -43,6 +43,7 @@ import jalview.io.DataSourceType;
 import jalview.io.StructureFile;
 import jalview.util.MappingUtils;
 import jalview.util.MessageManager;
+import jalview.util.Platform;
 import jalview.ws.sifts.SiftsClient;
 import jalview.ws.sifts.SiftsException;
 import jalview.ws.sifts.SiftsSettings;
@@ -890,13 +891,14 @@ public class StructureSelectionManager implements ApplicationSingletonI
    * @param pdbResNum
    * @param chain
    * @param pdbfile
+   * @return
    */
-  public void mouseOverStructure(int pdbResNum, String chain,
+  public String mouseOverStructure(int pdbResNum, String chain,
           String pdbfile)
   {
     AtomSpec atomSpec = new AtomSpec(pdbfile, chain, pdbResNum, 0);
     List<AtomSpec> atoms = Collections.singletonList(atomSpec);
-    mouseOverStructure(atoms);
+    return mouseOverStructure(atoms);
   }
 
   /**
@@ -904,12 +906,12 @@ public class StructureSelectionManager implements ApplicationSingletonI
    * 
    * @param atoms
    */
-  public void mouseOverStructure(List<AtomSpec> atoms)
+  public String mouseOverStructure(List<AtomSpec> atoms)
   {
     if (listeners == null)
     {
       // old or prematurely sent event
-      return;
+      return null;
     }
     boolean hasSequenceListener = false;
     for (int i = 0; i < listeners.size(); i++)
@@ -921,18 +923,24 @@ public class StructureSelectionManager implements ApplicationSingletonI
     }
     if (!hasSequenceListener)
     {
-      return;
+      return null;
     }
 
     SearchResultsI results = findAlignmentPositionsForStructurePositions(
             atoms);
+    String result = null;
     for (Object li : listeners)
     {
       if (li instanceof SequenceListener)
       {
-        ((SequenceListener) li).highlightSequence(results);
+        String s = ((SequenceListener) li).highlightSequence(results);
+        if (s != null)
+        {
+          result = s;
+        }
       }
     }
+    return result;
   }
 
   /**
@@ -1202,7 +1210,8 @@ public class StructureSelectionManager implements ApplicationSingletonI
     StringBuilder sb = new StringBuilder(64);
     for (StructureMapping sm : mappings)
     {
-      if (sm.pdbfile.equals(pdbfile) && seqs.contains(sm.sequence))
+      if (Platform.pathEquals(sm.pdbfile, pdbfile)
+              && seqs.contains(sm.sequence))
       {
         sb.append(sm.mappingDetails);
         sb.append(NEWLINE);
@@ -1264,22 +1273,43 @@ public class StructureSelectionManager implements ApplicationSingletonI
   }
 
   /**
-   * Reset this object to its initial state by removing all registered
-   * listeners, codon mappings, PDB file mappings.
-   * 
-   * Called only by Desktop and testng.
-   * 
+   * Resets this object to its initial state by removing all registered
+   * listeners, codon mappings, PDB file mappings
    */
   public void resetAll()
   {
-    mappings.clear();
-    seqmappings.clear();
-    sel_listeners.clear();
-    listeners.clear();
-    commandListeners.clear();
-    view_listeners.clear();
-    pdbFileNameId.clear();
-    pdbIdFileName.clear();
+    if (mappings != null)
+    {
+      mappings.clear();
+    }
+    if (seqmappings != null)
+    {
+      seqmappings.clear();
+    }
+    if (sel_listeners != null)
+    {
+      sel_listeners.clear();
+    }
+    if (listeners != null)
+    {
+      listeners.clear();
+    }
+    if (commandListeners != null)
+    {
+      commandListeners.clear();
+    }
+    if (view_listeners != null)
+    {
+      view_listeners.clear();
+    }
+    if (pdbFileNameId != null)
+    {
+      pdbFileNameId.clear();
+    }
+    if (pdbIdFileName != null)
+    {
+      pdbIdFileName.clear();
+    }
   }
 
   public void addSelectionListener(SelectionListener selecter)