JAL-1710, JAL-1711 Bug fix for exception thrown when a request containing a colon...
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 24 Apr 2015 15:05:24 +0000 (16:05 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 24 Apr 2015 15:05:24 +0000 (16:05 +0100)
src/jalview/gui/PDBSearchPanel.java

index 2d46714..5a8407a 100644 (file)
@@ -74,11 +74,17 @@ public class PDBSearchPanel extends GPDBSearchPanel
       wantedFields = PDBDocFieldPreferences
               .getSearchSummaryFields();
 
+      String searchTerm = txt_search.getText();
+      if (searchTerm.contains(":"))
+      {
+        searchTerm = searchTerm.split(":")[0];
+      }
+
       PDBRestRequest request = new PDBRestRequest();
       request.setAllowEmptySeq(allowEmptySequence);
       request.setResponseSize(100);
       request.setFieldToSearchBy(searchTarget + ":");
-      request.setSearchTerm(txt_search.getText());
+      request.setSearchTerm(searchTerm);
       request.setWantedFields(wantedFields);
 
       PDBRestClient pdbRestCleint = new PDBRestClient();
@@ -131,7 +137,17 @@ public class PDBSearchPanel extends GPDBSearchPanel
     {
       String pdbIdStr = tbl_summary.getValueAt(summaryRow, pdbIdCol)
               .toString();
-      selectedIds.append(";").append(pdbIdStr);
+
+      String searchTerm = txt_search.getText();
+      if (searchTerm.contains(":"))
+      {
+        selectedIds.append(";").append(pdbIdStr).append(":")
+                .append(searchTerm.split(":")[1].toUpperCase());
+      }
+      else
+      {
+        selectedIds.append(";").append(pdbIdStr);
+      }
     }
 
     String ids = selectedIds.deleteCharAt(0).toString();