JAL-2465 bugfix and rerefactor renamed getPdbFile() method to getStructureFile()
[jalview.git] / src / jalview / ext / jmol / JalviewJmolBinding.java
index 94df99a..0122802 100644 (file)
@@ -164,7 +164,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   public void closeViewer()
   {
     // remove listeners for all structures in viewer
-    getSsm().removeStructureViewerListener(this, this.getPdbFile());
+    getSsm().removeStructureViewerListener(this, this.getStructureFiles());
     viewer.dispose();
     lastCommand = null;
     viewer = null;
@@ -250,7 +250,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
      * get the distinct structure files modelled
      * (a file with multiple chains may map to multiple sequences)
      */
-    String[] files = getPdbFile();
+    String[] files = getStructureFiles();
     if (!waitForFileLoad(files))
     {
       return null;
@@ -577,7 +577,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
 
   private int getModelNum(String modelFileName)
   {
-    String[] mfn = getPdbFile();
+    String[] mfn = getStructureFiles();
     if (mfn == null)
     {
       return -1;
@@ -601,8 +601,8 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
 
   // ////////////////////////////////
   // /StructureListener
-  @Override
-  public synchronized String[] getPdbFile()
+  // @Override
+  public synchronized String[] getPdbFilex()
   {
     if (viewer == null)
     {
@@ -667,6 +667,32 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     return modelFileNames;
   }
 
+  @Override
+  public synchronized String[] getStructureFiles()
+  {
+    List<String> mset = new ArrayList<String>();
+    if (viewer == null)
+    {
+      return new String[0];
+    }
+
+    if (modelFileNames == null)
+    {
+      int modelCount = viewer.ms.mc;
+      String filePath = null;
+      for (int i = 0; i < modelCount; ++i)
+      {
+        filePath = viewer.ms.getModelFileName(i);
+        if (!mset.contains(filePath))
+        {
+          mset.add(filePath);
+        }
+      }
+      modelFileNames = mset.toArray(new String[mset.size()]);
+    }
+
+    return modelFileNames;
+  }
   /**
    * map from string to applet
    */
@@ -1035,7 +1061,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     chainNames = new ArrayList<String>();
     chainFile = new Hashtable<String, String>();
     boolean notifyLoaded = false;
-    String[] modelfilenames = getPdbFile();
+    String[] modelfilenames = getStructureFiles();
     // first check if we've lost any structures
     if (oldmodels != null && oldmodels.length > 0)
     {