JAL-2780 JAL-2781 programmatically select structures for retrieval via Structure...
authorJim Procter <jprocter@issues.jalview.org>
Mon, 5 Feb 2018 16:39:20 +0000 (16:39 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Mon, 5 Feb 2018 16:39:20 +0000 (16:39 +0000)
src/jalview/gui/StructureChooser.java

index 452677e..6e73724 100644 (file)
@@ -53,6 +53,7 @@ import java.util.Vector;
 import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
 import javax.swing.JLabel;
+import javax.swing.JTable;
 import javax.swing.table.AbstractTableModel;
 
 /**
@@ -727,6 +728,32 @@ public class StructureChooser extends GStructureChooser
 
   }
 
+  public void selectStructure(String...pdbids)
+  {
+    FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
+            .getSelectedItem());
+    String currentView = selectedFilterOpt.getView();
+    JTable restable = (currentView == VIEWS_FILTER) ? getResultTable()
+            : tbl_local_pdb;
+
+    if (currentView == VIEWS_FILTER)
+    {
+     
+      int pdbIdColIndex = restable.getColumn("PDB Id")
+              .getModelIndex();
+      for (int r = 0; r < restable.getRowCount(); r++)
+      {
+        for (int p=0;p<pdbids.length;p++)
+        {
+          if (String.valueOf(restable.getValueAt(r, pdbIdColIndex))
+                  .equalsIgnoreCase(pdbids[p]))
+        {
+            restable.setRowSelectionInterval(r, r);
+        }
+        }
+      }
+    }
+  }
   /**
    * Handles action event for btn_ok
    */