JAL-2446 merged to spike branch
[jalview.git] / src / jalview / fts / service / pdb / PDBFTSPanel.java
index dc2b403..b944b9b 100644 (file)
@@ -39,23 +39,24 @@ public class PDBFTSPanel extends GFTSPanel
   private static String defaultFTSFrameTitle = MessageManager
           .getString("label.pdb_sequence_fetcher");
 
-  private String ftsFrameTitle = defaultFTSFrameTitle;
 
   private static Map<String, Integer> tempUserPrefs = new HashMap<String, Integer>();
 
+  private static final String PDB_FTS_CACHE_KEY = "CACHE.PDB_FTS";
+
   public PDBFTSPanel(SequenceFetcher seqFetcher)
   {
     super();
     pageLimit = PDBFTSRestClient.getInstance().getDefaultResponsePageSize();
     this.seqFetcher = seqFetcher;
-    this.progressIdicator = (seqFetcher == null) ? null : seqFetcher
+    this.progressIndicator = (seqFetcher == null) ? null : seqFetcher
             .getProgressIndicator();
   }
 
-
   @Override
   public void searchAction(boolean isFreshSearch)
   {
+    mainFrame.requestFocusInWindow();
     if (isFreshSearch)
     {
       offSet = 0;
@@ -65,7 +66,6 @@ public class PDBFTSPanel extends GFTSPanel
       @Override
       public void run()
       {
-        ftsFrameTitle = defaultFTSFrameTitle;
         reset();
         boolean allowEmptySequence = false;
         if (getTypedText().length() > 0)
@@ -77,7 +77,7 @@ public class PDBFTSPanel extends GFTSPanel
                   .getSelectedItem()).getCode();
           wantedFields = PDBFTSRestClient.getInstance()
                   .getAllDefaultDisplayedFTSDataColumns();
-          String searchTerm = decodeSearchTerm(txt_search.getText(),
+          String searchTerm = decodeSearchTerm(getTypedText(),
                   searchTarget);
 
           FTSRestRequest request = new FTSRestRequest();
@@ -104,7 +104,7 @@ public class PDBFTSPanel extends GFTSPanel
           {
             getResultTable().setModel(
                     FTSRestResponse.getTableModel(request,
-                    resultList.getSearchSummary()));
+                            resultList.getSearchSummary()));
             FTSRestResponse.configureTableColumn(getResultTable(),
                     wantedFields, tempUserPrefs);
             getResultTable().setVisible(true);
@@ -117,10 +117,12 @@ public class PDBFTSPanel extends GFTSPanel
           String result = (resultSetCount > 0) ? MessageManager
                   .getString("label.results") : MessageManager
                   .getString("label.result");
-         
+
           if (isPaginationEnabled() && resultSetCount > 0)
           {
-            updateSearchFrameTitle(defaultFTSFrameTitle + " - " + result
+            updateSearchFrameTitle(defaultFTSFrameTitle
+                    + " - "
+                    + result
                     + " "
                     + totalNumberformatter.format((Number) (offSet + 1))
                     + " to "
@@ -128,8 +130,8 @@ public class PDBFTSPanel extends GFTSPanel
                             .format((Number) (offSet + resultSetCount))
                     + " of "
                     + totalNumberformatter
-                            .format((Number) totalResultSetCount)
-                    + " " + " (" + (endTime - startTime) + " milli secs)");
+                            .format((Number) totalResultSetCount) + " "
+                    + " (" + (endTime - startTime) + " milli secs)");
           }
           else
           {
@@ -137,11 +139,12 @@ public class PDBFTSPanel extends GFTSPanel
                     + resultSetCount + " " + result + " ("
                     + (endTime - startTime) + " milli secs)");
           }
-          
+
           setSearchInProgress(false);
           refreshPaginatorState();
           updateSummaryTableSelections();
         }
+        txt_search.updateCache();
       }
     }.start();
   }
@@ -193,19 +196,17 @@ public class PDBFTSPanel extends GFTSPanel
     try
     {
       primaryKeyColIndex = getFTSRestClient().getPrimaryKeyColumIndex(
-              wantedFields,
-              false);
+              wantedFields, false);
     } catch (Exception e)
     {
       e.printStackTrace();
     }
     int[] selectedRows = getResultTable().getSelectedRows();
-    String searchTerm = txt_search.getText();
+    String searchTerm = getTypedText();
     for (int summaryRow : selectedRows)
     {
       String idStr = getResultTable().getValueAt(summaryRow,
-              primaryKeyColIndex)
-              .toString();
+              primaryKeyColIndex).toString();
       selectedIdsSet.add(getPDBIdwithSpecifiedChain(idStr, searchTerm));
     }
 
@@ -227,7 +228,6 @@ public class PDBFTSPanel extends GFTSPanel
     delayAndEnableActionButtons();
   }
 
-
   public static String getPDBIdwithSpecifiedChain(String pdbId,
           String searchTerm)
   {
@@ -263,7 +263,7 @@ public class PDBFTSPanel extends GFTSPanel
   @Override
   public String getFTSFrameTitle()
   {
-    return ftsFrameTitle;
+    return defaultFTSFrameTitle;
   }
 
   @Override
@@ -278,4 +278,12 @@ public class PDBFTSPanel extends GFTSPanel
     return tempUserPrefs;
   }
 
+
+  @Override
+  public String getCacheKey()
+  {
+    return PDB_FTS_CACHE_KEY;
+  }
+
+
 }