X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Ffts%2Fservice%2Funiprot%2FUniprotFTSPanel.java;h=df54dea5c841eda0f6e6a7886d18fb5c6a862a37;hb=6c9e086eeb3cdc0013fbb573d8e0a9be0cfc2057;hp=eba0f88b6af6317db8a0d03e0d76bdaf1ee51d0d;hpb=0ce95d9c8581b19c1d636f67f67dd670e41f1ca9;p=jalview.git diff --git a/src/jalview/fts/service/uniprot/UniprotFTSPanel.java b/src/jalview/fts/service/uniprot/UniprotFTSPanel.java index eba0f88..df54dea 100644 --- a/src/jalview/fts/service/uniprot/UniprotFTSPanel.java +++ b/src/jalview/fts/service/uniprot/UniprotFTSPanel.java @@ -40,25 +40,26 @@ public class UniprotFTSPanel extends GFTSPanel private static String defaultFTSFrameTitle = MessageManager .getString("label.uniprot_sequence_fetcher"); + private static Map tempUserPrefs = new HashMap<>(); - private static Map tempUserPrefs = new HashMap(); + private static final String UNIPROT_FTS_CACHE_KEY = "CACHE.UNIPROT_FTS"; - private static final String UNIPROT_FTS_CACHE_KEY = "UNIPROT_FTS_CACHE_KEY"; + private static final String UNIPROT_AUTOSEARCH = "FTS.UNIPROT.AUTOSEARCH"; - public UniprotFTSPanel(SequenceFetcher seqFetcher) + public UniprotFTSPanel(SequenceFetcher fetcher) { - super(); + super(fetcher); pageLimit = UniProtFTSRestClient.getInstance() .getDefaultResponsePageSize(); - this.seqFetcher = seqFetcher; - this.progressIndicator = (seqFetcher == null) ? null : seqFetcher - .getProgressIndicator(); - fireCache(); + this.seqFetcher = fetcher; + this.progressIndicator = (fetcher == null) ? null + : fetcher.getProgressIndicator(); } @Override public void searchAction(boolean isFreshSearch) { + mainFrame.requestFocusInWindow(); if (isFreshSearch) { offSet = 0; @@ -74,40 +75,37 @@ public class UniprotFTSPanel extends GFTSPanel { setSearchInProgress(true); long startTime = System.currentTimeMillis(); - + searchInput = getTypedText(); String searchTarget = ((FTSDataColumnI) cmb_searchTarget .getSelectedItem()).getAltCode(); - wantedFields = UniProtFTSRestClient.getInstance() .getAllDefaultDisplayedFTSDataColumns(); - String searchTerm = decodeSearchTerm(getTypedText(), - searchTarget); + String searchTerm = decodeSearchTerm(searchInput, searchTarget); FTSRestRequest request = new FTSRestRequest(); request.setFieldToSearchBy(searchTarget); request.setSearchTerm(searchTerm); request.setOffSet(offSet); request.setWantedFields(wantedFields); - FTSRestClientI uniProtRestCleint = UniProtFTSRestClient + FTSRestClientI uniProtRestClient = UniProtFTSRestClient .getInstance(); FTSRestResponse resultList; try { - resultList = uniProtRestCleint.executeRequest(request); + resultList = uniProtRestClient.executeRequest(request); } catch (Exception e) { - e.printStackTrace(); setErrorMessage(e.getMessage()); checkForErrors(); + setSearchInProgress(false); return; } if (resultList.getSearchSummary() != null && resultList.getSearchSummary().size() > 0) { - getResultTable().setModel( - FTSRestResponse.getTableModel(request, - resultList.getSearchSummary())); + getResultTable().setModel(FTSRestResponse.getTableModel(request, + resultList.getSearchSummary())); FTSRestResponse.configureTableColumn(getResultTable(), wantedFields, tempUserPrefs); getResultTable().setVisible(true); @@ -117,14 +115,12 @@ public class UniprotFTSPanel extends GFTSPanel totalResultSetCount = resultList.getNumberOfItemsFound(); resultSetCount = resultList.getSearchSummary() == null ? 0 : resultList.getSearchSummary().size(); - String result = (resultSetCount > 0) ? MessageManager - .getString("label.results") : MessageManager - .getString("label.result"); + 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 " @@ -132,8 +128,8 @@ public class UniprotFTSPanel extends GFTSPanel .format((Number) (offSet + resultSetCount)) + " of " + totalNumberformatter - .format((Number) totalResultSetCount) + " " - + " (" + (endTime - startTime) + " milli secs)"); + .format((Number) totalResultSetCount) + + " " + " (" + (endTime - startTime) + " milli secs)"); } else { @@ -145,7 +141,7 @@ public class UniprotFTSPanel extends GFTSPanel refreshPaginatorState(); updateSummaryTableSelections(); } - fireCache(); + txt_search.updateCache(); } }.start(); @@ -189,12 +185,12 @@ public class UniprotFTSPanel extends GFTSPanel { disableActionButtons(); StringBuilder selectedIds = new StringBuilder(); - HashSet selectedIdsSet = new HashSet(); + HashSet selectedIdsSet = new HashSet<>(); int primaryKeyColIndex = 0; try { - primaryKeyColIndex = getFTSRestClient().getPrimaryKeyColumIndex( - wantedFields, false); + primaryKeyColIndex = getFTSRestClient() + .getPrimaryKeyColumIndex(wantedFields, false); } catch (Exception e) { e.printStackTrace(); @@ -202,8 +198,8 @@ public class UniprotFTSPanel extends GFTSPanel int[] selectedRows = getResultTable().getSelectedRows(); for (int summaryRow : selectedRows) { - String idStr = getResultTable().getValueAt(summaryRow, - primaryKeyColIndex).toString(); + String idStr = getResultTable() + .getValueAt(summaryRow, primaryKeyColIndex).toString(); selectedIdsSet.add(idStr); } selectedIdsSet.addAll(paginatorCart); @@ -243,4 +239,10 @@ public class UniprotFTSPanel extends GFTSPanel { return UNIPROT_FTS_CACHE_KEY; } + + @Override + public String getAutosearchPreference() + { + return UNIPROT_AUTOSEARCH; + } }