@Override
public void txt_search_ActionPerformed()
{
- errorWarning.setLength(0);
- lbl_warning.setVisible(false);
- btn_ok.setEnabled(false);
- boolean allowEmptySequence = false;
- mainFrame.setTitle(MessageManager
- .getString("label.pdb_sequence_getcher"));
- tbl_summary.setModel(new DefaultTableModel());
- if (txt_search.getText().trim().length() > 0)
+ new Thread()
{
- long startTime = System.currentTimeMillis();
+ public void run()
+ {
+ lbl_loading.setVisible(false);
+ errorWarning.setLength(0);
+ lbl_warning.setVisible(false);
+ btn_ok.setEnabled(false);
+ boolean allowEmptySequence = false;
+ mainFrame.setTitle(MessageManager
+ .getString("label.pdb_sequence_getcher"));
+ tbl_summary.setModel(new DefaultTableModel());
+ if (txt_search.getText().trim().length() > 0)
+ {
+ lbl_loading.setVisible(true);
+ long startTime = System.currentTimeMillis();
- String searchTarget = ((PDBDocField) cmb_searchTarget
- .getSelectedItem()).getCode();
+ String searchTarget = ((PDBDocField) cmb_searchTarget
+ .getSelectedItem()).getCode();
- wantedFields = PDBDocFieldPreferences
- .getSearchSummaryFields();
+ wantedFields = PDBDocFieldPreferences.getSearchSummaryFields();
- String searchTerm = decodeSearchTerm(txt_search.getText(),
- searchTarget);
+ String searchTerm = decodeSearchTerm(txt_search.getText(),
+ searchTarget);
- PDBRestRequest request = new PDBRestRequest();
- request.setAllowEmptySeq(allowEmptySequence);
- request.setResponseSize(100);
- request.setFieldToSearchBy("(" + searchTarget + ":");
- request.setSearchTerm(searchTerm + ")");
- request.setWantedFields(wantedFields);
- // System.out.println(">>>>>>>>>>>>>> " + request.getQuery());
- PDBRestClient pdbRestCleint = new PDBRestClient();
- PDBRestResponse resultList;
- try
- {
- resultList = pdbRestCleint.executeRequest(request);
- } catch (Exception e)
- {
- // System.out.println(">>>>>>>>>>>>>>>" + e.getMessage());
- e.printStackTrace();
- errorWarning.append(e.getMessage());
- checkForErrors();
- return;
- }
+ PDBRestRequest request = new PDBRestRequest();
+ request.setAllowEmptySeq(allowEmptySequence);
+ request.setResponseSize(100);
+ request.setFieldToSearchBy("(" + searchTarget + ":");
+ request.setSearchTerm(searchTerm + ")");
+ request.setWantedFields(wantedFields);
+ // System.out.println(">>>>>>>>>>>>>> " + request.getQuery());
+ PDBRestClient pdbRestCleint = new PDBRestClient();
+ PDBRestResponse resultList;
+ try
+ {
+ resultList = pdbRestCleint.executeRequest(request);
+ } catch (Exception e)
+ {
+ // e.printStackTrace();
+ errorWarning.append(e.getMessage());
+ checkForErrors();
+ return;
+ }
- if (resultList.getSearchSummary() != null)
- {
- tbl_summary.setModel(PDBRestResponse.getTableModel(request,
- resultList.getSearchSummary()));
- }
+ if (resultList.getSearchSummary() != null)
+ {
+ tbl_summary.setModel(PDBRestResponse.getTableModel(request,
+ resultList.getSearchSummary()));
+ }
- long endTime = System.currentTimeMillis();
- int resultSetCount = resultList.getNumberOfItemsFound();
- String result = (resultSetCount > 1) ? MessageManager
- .getString("label.results") : MessageManager
- .getString("label.result");
- mainFrame.setTitle(frameTitle + " - " + resultSetCount + " " + result
- + " (" + (endTime - startTime) + " milli secs)");
- }
+ long endTime = System.currentTimeMillis();
+ int resultSetCount = resultList.getNumberOfItemsFound();
+ String result = (resultSetCount > 1) ? MessageManager
+ .getString("label.results") : MessageManager
+ .getString("label.result");
+ mainFrame.setTitle(frameTitle + " - " + resultSetCount + " "
+ + result + " (" + (endTime - startTime) + " milli secs)");
+ lbl_loading.setVisible(false);
+ }
+ }
+ }.start();
}
public static String decodeSearchTerm(String enteredText,
lbl_warning.setVisible(false);
if (errorWarning.length() > 0)
{
+ lbl_loading.setVisible(false);
lbl_warning.setToolTipText(JvSwingUtils.wrapTooltip(true,
errorWarning.toString()));
lbl_warning.setVisible(true);
protected ImageIcon warningImage = new ImageIcon(getClass().getResource(
"/images/warning.gif"));
+ protected ImageIcon loadingImage = new ImageIcon(getClass().getResource(
+ "/images/loading.gif"));
protected JLabel lbl_warning = new JLabel(warningImage);
+ protected JLabel lbl_loading = new JLabel(loadingImage);
+
private JTabbedPane tabbedPane = new JTabbedPane();
private PDBDocFieldPreferences pdbDocFieldPrefs = new PDBDocFieldPreferences(
{
lbl_warning.setVisible(false);
lbl_warning.setFont(new java.awt.Font("Verdana", 0, 12));
+ lbl_loading.setVisible(false);
+ lbl_loading.setFont(new java.awt.Font("Verdana", 0, 12));
tbl_summary.setAutoCreateRowSorter(true);
tbl_summary.getTableHeader().setReorderingAllowed(false);
pnl_results.add(tabbedPane);
pnl_inputs.add(cmb_searchTarget);
pnl_inputs.add(txt_search);
+ pnl_inputs.add(lbl_loading);
pnl_inputs.add(lbl_warning);
this.setLayout(mainLayout);
package jalview.ws.dbsources;
+import jalview.util.MessageManager;
import jalview.ws.uimodel.PDBRestRequest;
import jalview.ws.uimodel.PDBRestResponse;
import jalview.ws.uimodel.PDBRestResponse.PDBResponseSummary;
String exceptionMsg = e.getMessage();
if (exceptionMsg.contains("SocketException"))
{
- throw new Exception(
- "Jalview is unable to detect an internet connection");
// No internet connection
+ throw new Exception(
+ MessageManager
+ .getString("exception.unable_to_detect_internet_connection"));
}
else if (exceptionMsg.contains("UnknownHostException"))
{
- throw new Exception(
- "Jalview is unable to reach the host server \'www.ebi.ac.uk\'. "
- + "\nPlease ensure that you are connected to the internet and try again.");
// The server 'www.ebi.ac.uk' is unreachable
+ throw new Exception(
+ MessageManager
+ .getString("exception.pdb_server_unreachable"));
}
else
{
switch (code)
{
case 410:
- message = "PDB Rest Service no longer exists!";
+ message = MessageManager
+ .getString("exception.pdb_rest_service_no_longer_available");
break;
case 403:
case 404:
- message = "The requested resource could not be found";
+ message = MessageManager.getString("exception.resource_not_be_found");
break;
case 408:
case 409:
case 503:
case 504:
case 505:
- message = "There seems to be an error from the PDB Rest API server.";
+ message = MessageManager.getString("exception.pdb_server_error");
break;
default: