JInternalFrame frame;\r
AlignFrame alignFrame;\r
StringBuffer result;\r
+ final String noDbSelected = "-- Select Database --";\r
public SequenceFetcher(AlignFrame af)\r
{\r
alignFrame = af;\r
- database.addItem("-- Select Database --");\r
+ database.addItem(noDbSelected);\r
database.addItem("Uniprot");\r
database.addItem("EMBL");\r
database.addItem("EMBLCDS");\r
worker.start();\r
}\r
\r
+ private void resetDialog() {\r
+ database.setEnabled(true);\r
+ textfield.setEnabled(true);\r
+ ok.setEnabled(true);\r
+ cancel.setEnabled(true);\r
+ frame.setTitle("Sequence Fetcher (WSDBfetch@EBI)");\r
+ }\r
+\r
public void run()\r
{\r
+ String error = "";\r
+ if (database.getSelectedItem().equals(noDbSelected))\r
+ error += "Please select the source database\n";\r
+ com.stevesoft.pat.Regex empty=new com.stevesoft.pat.Regex("\\s+","");\r
+ textfield.setText(empty.replaceAll(textfield.getText()));\r
+ if (textfield.getText().length()==0)\r
+ error+="Please enter a (semi-colon separated list of) database id(s)";\r
+ if (error.length()>0) {\r
+ showErrorMessage(error);\r
+ resetDialog();\r
+ return;\r
+ }\r
+\r
result = new StringBuffer();\r
if (database.getSelectedItem().equals("Uniprot"))\r
{\r
else if (database.getSelectedItem().equals("PDB"))\r
{\r
result = getPDBFile(textfield.getText().toUpperCase());\r
- parseResult(result.toString());\r
+ if (result!=null)\r
+ parseResult(result.toString());\r
}\r
\r
\r
if (result == null || result.length() == 0)\r
showErrorMessage("Error retrieving " + textfield.getText()\r
+ " from " + database.getSelectedItem());\r
-\r
-\r
- database.setEnabled(true);\r
- textfield.setEnabled(true);\r
- ok.setEnabled(true);\r
- cancel.setEnabled(true);\r
- frame.setTitle("Sequence Fetcher (WSDBfetch@EBI)");\r
+ else\r
+ textfield.setText("");\r
+ resetDialog();\r
}\r
\r
void getUniprotFile(String id)\r
\r
EBIFetchClient ebi = new EBIFetchClient();\r
String[] reply = ebi.fetchData("pdb:" + id, "pdb", "raw");\r
+ if (reply==null)\r
+ return null;\r
try\r
{\r
PDBfile pdbfile = new PDBfile(reply);\r
}\r
catch (Exception ex) // Problem parsing PDB file\r
{\r
- showErrorMessage("Error retrieving " + textfield.getText() + " from " +\r
- database.getSelectedItem());\r
+ jalview.bin.Cache.log.warn("Exception when retrieving " + textfield.getText() + " from " +\r
+ database.getSelectedItem(), ex);\r
return null;\r
}\r
\r