added singleton access method to retrieve the latest shared instance of the jalview...
[jalview.git] / src / jalview / gui / SequenceFetcher.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer
3  * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18  */
19 package jalview.gui;
20
21 import java.io.*;
22 import java.util.*;
23
24 import java.awt.*;
25 import java.awt.event.*;
26
27 import javax.swing.*;
28
29 import MCview.*;
30 import jalview.datamodel.*;
31 import jalview.datamodel.xdb.embl.*;
32 import java.io.File;
33 import jalview.io.*;
34 import jalview.ws.DBRefFetcher;
35 import jalview.ws.ebi.EBIFetchClient;
36 import jalview.ws.seqfetcher.ASequenceFetcher;
37 import jalview.ws.seqfetcher.DbSourceProxy;
38
39 import java.awt.Rectangle;
40 import java.awt.BorderLayout;
41 import java.awt.Dimension;
42
43 public class SequenceFetcher extends JPanel implements Runnable
44 {
45   // ASequenceFetcher sfetch;
46   JInternalFrame frame;
47
48   IProgressIndicator guiWindow;
49
50   AlignFrame alignFrame;
51
52   StringBuffer result;
53
54   final String noDbSelected = "-- Select Database --";
55
56   Hashtable sources = new Hashtable();
57
58   private static jalview.ws.SequenceFetcher sfetch = null;
59
60   private static String dasRegistry = null;
61   /**
62    * Blocking method that initialises and returns the shared instance of the SequenceFetcher client 
63    * @param guiWindow - where the initialisation delay message should be shown
64    * @return the singleton instance of the sequence fetcher client
65    */
66   public static jalview.ws.SequenceFetcher getSequenceFetcherSingleton(final IProgressIndicator guiWindow) {
67     if (sfetch == null
68             || dasRegistry != DasSourceBrowser.getDasRegistryURL())
69     {
70       /**
71        * give a visual indication that sequence fetcher construction is
72        * occuring
73        */
74       if (guiWindow != null)
75       {
76         guiWindow.setProgressBar(
77                 "Initialising Sequence Database Fetchers", Thread.currentThread()
78                         .hashCode());
79       }
80       dasRegistry = DasSourceBrowser.getDasRegistryURL();
81       jalview.ws.SequenceFetcher sf = new jalview.ws.SequenceFetcher();
82       if (guiWindow != null)
83       {
84         guiWindow.setProgressBar(
85                 "Initialising Sequence Database Fetchers", Thread.currentThread().hashCode());
86       }
87       sfetch = sf;
88
89     }
90     return sfetch;
91   }
92   public SequenceFetcher(IProgressIndicator guiIndic)
93   {
94     final IProgressIndicator guiWindow = guiIndic;
95     final SequenceFetcher us = this;
96     // launch initialiser thread
97     Thread sf = new Thread(new Runnable()
98     {
99
100       public void run()
101       {
102         if (getSequenceFetcherSingleton(guiWindow)!=null)
103         {
104           us.initGui(guiWindow);
105         } else {
106           javax.swing.SwingUtilities.invokeLater(new Runnable()
107           {
108             public void run()
109             {
110               JOptionPane.showInternalMessageDialog(Desktop.desktop, 
111                       "Could not create the sequence fetcher client. Check error logs for details.",
112                       "Couldn't create SequenceFetcher", JOptionPane.ERROR_MESSAGE);
113             }
114           });
115           
116           // raise warning dialog
117         }
118       }
119     });
120     sf.start();
121   }
122
123   /**
124    * called by thread spawned by constructor
125    * 
126    * @param guiWindow
127    */
128   private void initGui(IProgressIndicator guiWindow)
129   {
130     this.guiWindow = guiWindow;
131     if (guiWindow instanceof AlignFrame)
132     {
133       alignFrame = (AlignFrame) guiWindow;
134     }
135
136     database.addItem(noDbSelected);
137     /*
138      * Dynamically generated database list will need a translation function from
139      * internal source to externally distinct names. UNIPROT and UP_NAME are
140      * identical DB sources, and should be collapsed.
141      */
142
143     String dbs[] = sfetch.getOrderedSupportedSources();
144     for (int i = 0; i < dbs.length; i++)
145     {
146       if (!sources.containsValue(dbs[i]))
147       {
148         String name = sfetch.getSourceProxy(dbs[i]).getDbName();
149         // duplicate source names are thrown away, here.
150         if (!sources.containsKey(name))
151         {
152           database.addItem(name);
153         }
154         // overwrite with latest version of the retriever for this source
155         sources.put(name, dbs[i]);
156       }
157     }
158     try
159     {
160       jbInit();
161     } catch (Exception ex)
162     {
163       ex.printStackTrace();
164     }
165
166     frame = new JInternalFrame();
167     frame.setContentPane(this);
168     if (new jalview.util.Platform().isAMac())
169     {
170       Desktop.addInternalFrame(frame, getFrameTitle(), 400, 180);
171     }
172     else
173     {
174       Desktop.addInternalFrame(frame, getFrameTitle(), 400, 140);
175     }
176   }
177
178   private String getFrameTitle()
179   {
180     return ((alignFrame == null) ? "New " : "Additional ")
181             + "Sequence Fetcher";
182   }
183
184   private void jbInit() throws Exception
185   {
186     this.setLayout(borderLayout2);
187
188     database.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
189     dbeg.setFont(new java.awt.Font("Verdana", Font.BOLD, 11));
190     jLabel1.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
191     jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
192     jLabel1
193             .setText("Separate multiple accession ids with semi colon \";\"");
194     ok.setText("OK");
195     ok.addActionListener(new ActionListener()
196     {
197       public void actionPerformed(ActionEvent e)
198       {
199         ok_actionPerformed();
200       }
201     });
202     clear.setText("Clear");
203     clear.addActionListener(new ActionListener()
204     {
205       public void actionPerformed(ActionEvent e)
206       {
207         clear_actionPerformed();
208       }
209     });
210
211     example.setText("Example");
212     example.addActionListener(new ActionListener()
213     {
214       public void actionPerformed(ActionEvent e)
215       {
216         example_actionPerformed();
217       }
218     });
219     close.setText("Close");
220     close.addActionListener(new ActionListener()
221     {
222       public void actionPerformed(ActionEvent e)
223       {
224         close_actionPerformed(e);
225       }
226     });
227     textArea.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
228     textArea.setLineWrap(true);
229     textArea.addKeyListener(new KeyAdapter()
230     {
231       public void keyPressed(KeyEvent e)
232       {
233         if (e.getKeyCode() == KeyEvent.VK_ENTER)
234           ok_actionPerformed();
235       }
236     });
237     jPanel3.setLayout(borderLayout1);
238     borderLayout1.setVgap(5);
239     jPanel1.add(ok);
240     jPanel1.add(example);
241     jPanel1.add(clear);
242     jPanel1.add(close);
243     jPanel3.add(jPanel2, java.awt.BorderLayout.CENTER);
244     jPanel2.setLayout(borderLayout3);
245
246     database.addActionListener(new ActionListener()
247     {
248
249       public void actionPerformed(ActionEvent e)
250       {
251         DbSourceProxy db = null;
252         try
253         {
254           db = sfetch.getSourceProxy((String) sources.get(database
255                   .getSelectedItem()));
256           dbeg.setText("Example query: " + db.getTestQuery());
257         } catch (Exception ex)
258         {
259           dbeg.setText("");
260         }
261         jPanel2.repaint();
262       }
263     });
264     dbeg.setText("");
265     jPanel2.add(database, java.awt.BorderLayout.NORTH);
266     jPanel2.add(dbeg, java.awt.BorderLayout.CENTER);
267     jPanel2.add(jLabel1, java.awt.BorderLayout.SOUTH);
268     // jPanel2.setPreferredSize(new Dimension())
269     jPanel3.add(jScrollPane1, java.awt.BorderLayout.CENTER);
270     this.add(jPanel1, java.awt.BorderLayout.SOUTH);
271     this.add(jPanel3, java.awt.BorderLayout.CENTER);
272     this.add(jPanel2, java.awt.BorderLayout.NORTH);
273     jScrollPane1.getViewport().add(textArea);
274
275   }
276
277   protected void example_actionPerformed()
278   {
279     DbSourceProxy db = null;
280     try
281     {
282       db = sfetch.getSourceProxy((String) sources.get(database
283               .getSelectedItem()));
284       textArea.setText(db.getTestQuery());
285     } catch (Exception ex)
286     {
287     }
288     jPanel3.repaint();
289   }
290
291   protected void clear_actionPerformed()
292   {
293     textArea.setText("");
294     jPanel3.repaint();
295   }
296
297   JLabel dbeg = new JLabel();
298
299   JComboBox database = new JComboBox();
300
301   JLabel jLabel1 = new JLabel();
302
303   JButton ok = new JButton();
304
305   JButton clear = new JButton();
306
307   JButton example = new JButton();
308
309   JButton close = new JButton();
310
311   JPanel jPanel1 = new JPanel();
312
313   JTextArea textArea = new JTextArea();
314
315   JScrollPane jScrollPane1 = new JScrollPane();
316
317   JPanel jPanel2 = new JPanel();
318
319   JPanel jPanel3 = new JPanel();
320
321   JPanel jPanel4 = new JPanel();
322
323   BorderLayout borderLayout1 = new BorderLayout();
324
325   BorderLayout borderLayout2 = new BorderLayout();
326
327   BorderLayout borderLayout3 = new BorderLayout();
328
329   public void close_actionPerformed(ActionEvent e)
330   {
331     try
332     {
333       frame.setClosed(true);
334     } catch (Exception ex)
335     {
336     }
337   }
338
339   public void ok_actionPerformed()
340   {
341     database.setEnabled(false);
342     textArea.setEnabled(false);
343     ok.setEnabled(false);
344     close.setEnabled(false);
345
346     Thread worker = new Thread(this);
347     worker.start();
348   }
349
350   private void resetDialog()
351   {
352     database.setEnabled(true);
353     textArea.setEnabled(true);
354     ok.setEnabled(true);
355     close.setEnabled(true);
356   }
357
358   public void run()
359   {
360     String error = "";
361     if (database.getSelectedItem().equals(noDbSelected))
362     {
363       error += "Please select the source database\n";
364     }
365     com.stevesoft.pat.Regex empty = new com.stevesoft.pat.Regex("\\s+", "");
366     textArea.setText(empty.replaceAll(textArea.getText()));
367     if (textArea.getText().length() == 0)
368     {
369       error += "Please enter a (semi-colon separated list of) database id(s)";
370     }
371     if (error.length() > 0)
372     {
373       showErrorMessage(error);
374       resetDialog();
375       return;
376     }
377     AlignmentI aresult = null;
378     try
379     {
380       guiWindow.setProgressBar("Fetching Sequences from "
381               + database.getSelectedItem(), Thread.currentThread()
382               .hashCode());
383       aresult = sfetch.getSourceProxy(
384               (String) sources.get(database.getSelectedItem()))
385               .getSequenceRecords(textArea.getText());
386
387     } catch (Exception e)
388     {
389       showErrorMessage("Error retrieving " + textArea.getText() + " from "
390               + database.getSelectedItem());
391       // error +="Couldn't retrieve sequences from "+database.getSelectedItem();
392       System.err.println("Retrieval failed for source ='"
393               + database.getSelectedItem() + "' and query\n'"
394               + textArea.getText() + "'\n");
395       e.printStackTrace();
396     } catch (OutOfMemoryError e)
397     {
398       showErrorMessage("Out of Memory when retrieving "
399               + textArea.getText()
400               + " from "
401               + database.getSelectedItem()
402               + "\nPlease see the Jalview FAQ for instructions for increasing the memory available to Jalview.\n");
403       e.printStackTrace();
404     } catch (Error e)
405     {
406       showErrorMessage("Serious Error retrieving " + textArea.getText()
407               + " from " + database.getSelectedItem());
408       e.printStackTrace();
409     }
410     guiWindow.setProgressBar(null, Thread.currentThread().hashCode());
411     if (aresult != null)
412     {
413       parseResult(aresult, null, null);
414     }
415     resetDialog();
416   }
417
418   /*
419    * result = new StringBuffer(); if
420    * (database.getSelectedItem().equals("Uniprot")) {
421    * getUniprotFile(textArea.getText()); } else if
422    * (database.getSelectedItem().equals("EMBL") ||
423    * database.getSelectedItem().equals("EMBLCDS")) { String DBRefSource =
424    * database.getSelectedItem().equals("EMBLCDS") ?
425    * jalview.datamodel.DBRefSource.EMBLCDS : jalview.datamodel.DBRefSource.EMBL;
426    * 
427    * StringTokenizer st = new StringTokenizer(textArea.getText(), ";");
428    * SequenceI[] seqs = null; while(st.hasMoreTokens()) { EBIFetchClient dbFetch =
429    * new EBIFetchClient(); String qry =
430    * database.getSelectedItem().toString().toLowerCase( ) + ":" +
431    * st.nextToken(); File reply = dbFetch.fetchDataAsFile( qry, "emblxml",null);
432    * 
433    * jalview.datamodel.xdb.embl.EmblFile efile=null; if (reply != null &&
434    * reply.exists()) { efile =
435    * jalview.datamodel.xdb.embl.EmblFile.getEmblFile(reply); } if (efile!=null) {
436    * for (Iterator i=efile.getEntries().iterator(); i.hasNext(); ) { EmblEntry
437    * entry = (EmblEntry) i.next(); SequenceI[] seqparts =
438    * entry.getSequences(false,true, DBRefSource); if (seqparts!=null) {
439    * SequenceI[] newseqs = null; int si=0; if (seqs==null) { newseqs = new
440    * SequenceI[seqparts.length]; } else { newseqs = new
441    * SequenceI[seqs.length+seqparts.length];
442    * 
443    * for (;si<seqs.length; si++) { newseqs[si] = seqs[si]; seqs[si] = null; } }
444    * for (int j=0;j<seqparts.length; si++, j++) { newseqs[si] =
445    * seqparts[j].deriveSequence(); // place DBReferences on dataset and refer }
446    * seqs=newseqs;
447    *  } } } else { result.append("# no response for "+qry); } } if (seqs!=null &&
448    * seqs.length>0) { if (parseResult(new Alignment(seqs), null, null)!=null) {
449    * result.append("# Successfully parsed the "+database.getSelectedItem()+"
450    * Queries into an Alignment"); } } } else if
451    * (database.getSelectedItem().equals("PDB")) { StringTokenizer qset = new
452    * StringTokenizer(textArea.getText(), ";"); String query; SequenceI[] seqs =
453    * null; while (qset.hasMoreTokens() && ((query = qset.nextToken())!=null)) {
454    * SequenceI[] seqparts = getPDBFile(query.toUpperCase()); if (seqparts !=
455    * null) { if (seqs == null) { seqs = seqparts; } else { SequenceI[] newseqs =
456    * new SequenceI[seqs.length+seqparts.length]; int i=0; for (; i <
457    * seqs.length; i++) { newseqs[i] = seqs[i]; seqs[i] = null; } for (int j=0;j<seqparts.length;
458    * i++, j++) { newseqs[i] = seqparts[j]; } seqs=newseqs; } result.append("#
459    * Success for "+query.toUpperCase()+"\n"); } } if (seqs != null &&
460    * seqs.length > 0) { if (parseResult(new Alignment(seqs), null, null)!=null) {
461    * result.append( "# Successfully parsed the PDB File Queries into an
462    * Alignment"); } } } else if( database.getSelectedItem().equals("PFAM")) {
463    * try { result.append(new FastaFile(
464    * "http://www.sanger.ac.uk/cgi-bin/Pfam/getalignment.pl?format=fal&acc=" +
465    * textArea.getText().toUpperCase(), "URL").print() );
466    * 
467    * if(result.length()>0) { parseResult( result.toString(),
468    * textArea.getText().toUpperCase() ); }
469    *  } catch (java.io.IOException ex) { result = null; } }
470    * 
471    * if (result == null || result.length() == 0) { showErrorMessage("Error
472    * retrieving " + textArea.getText() + " from " + database.getSelectedItem()); }
473    * 
474    * resetDialog(); return; }
475    * 
476    * void getUniprotFile(String id) { EBIFetchClient ebi = new EBIFetchClient();
477    * File file = ebi.fetchDataAsFile("uniprot:" + id, "xml", null);
478    * 
479    * DBRefFetcher dbref = new DBRefFetcher(); Vector entries =
480    * dbref.getUniprotEntries(file);
481    * 
482    * if (entries != null) { //First, make the new sequences Enumeration en =
483    * entries.elements(); while (en.hasMoreElements()) { UniprotEntry entry =
484    * (UniprotEntry) en.nextElement();
485    * 
486    * StringBuffer name = new StringBuffer(">UniProt/Swiss-Prot"); Enumeration
487    * en2 = entry.getAccession().elements(); while (en2.hasMoreElements()) {
488    * name.append("|"); name.append(en2.nextElement()); } en2 =
489    * entry.getName().elements(); while (en2.hasMoreElements()) {
490    * name.append("|"); name.append(en2.nextElement()); }
491    * 
492    * if (entry.getProtein() != null) { name.append(" " +
493    * entry.getProtein().getName().elementAt(0)); }
494    * 
495    * result.append(name + "\n" + entry.getUniprotSequence().getContent() +
496    * "\n");
497    *  }
498    * 
499    * //Then read in the features and apply them to the dataset Alignment al =
500    * parseResult(result.toString(), null); for (int i = 0; i < entries.size();
501    * i++) { UniprotEntry entry = (UniprotEntry) entries.elementAt(i);
502    * Enumeration e = entry.getDbReference().elements(); Vector onlyPdbEntries =
503    * new Vector(); while (e.hasMoreElements()) { PDBEntry pdb = (PDBEntry)
504    * e.nextElement(); if (!pdb.getType().equals("PDB")) { continue; }
505    * 
506    * onlyPdbEntries.addElement(pdb); }
507    * 
508    * Enumeration en2 = entry.getAccession().elements(); while
509    * (en2.hasMoreElements()) {
510    * al.getSequenceAt(i).getDatasetSequence().addDBRef(new DBRefEntry(
511    * DBRefSource.UNIPROT, "0", en2.nextElement().toString())); }
512    * 
513    * 
514    * 
515    * 
516    * al.getSequenceAt(i).getDatasetSequence().setPDBId(onlyPdbEntries); if
517    * (entry.getFeature() != null) { e = entry.getFeature().elements(); while
518    * (e.hasMoreElements()) { SequenceFeature sf = (SequenceFeature)
519    * e.nextElement(); sf.setFeatureGroup("Uniprot");
520    * al.getSequenceAt(i).getDatasetSequence().addSequenceFeature( sf ); } } } } }
521    * 
522    * SequenceI[] getPDBFile(String id) { Vector result = new Vector(); String
523    * chain = null; if (id.indexOf(":") > -1) { chain =
524    * id.substring(id.indexOf(":") + 1); id = id.substring(0, id.indexOf(":")); }
525    * 
526    * EBIFetchClient ebi = new EBIFetchClient(); String file =
527    * ebi.fetchDataAsFile("pdb:" + id, "pdb", "raw"). getAbsolutePath(); if (file ==
528    * null) { return null; } try { PDBfile pdbfile = new PDBfile(file,
529    * jalview.io.AppletFormatAdapter.FILE); for (int i = 0; i <
530    * pdbfile.chains.size(); i++) { if (chain == null || ( (PDBChain)
531    * pdbfile.chains.elementAt(i)).id. toUpperCase().equals(chain)) { PDBChain
532    * pdbchain = (PDBChain) pdbfile.chains.elementAt(i); // Get the Chain's
533    * Sequence - who's dataset includes any special features added from the PDB
534    * file SequenceI sq = pdbchain.sequence; // Specially formatted name for the
535    * PDB chain sequences retrieved from the PDB
536    * sq.setName("PDB|"+id+"|"+sq.getName()); // Might need to add more metadata
537    * to the PDBEntry object // like below /* PDBEntry entry = new PDBEntry(); //
538    * Construct the PDBEntry entry.setId(id); if (entry.getProperty() == null)
539    * entry.setProperty(new Hashtable()); entry.getProperty().put("chains",
540    * pdbchain.id + "=" + sq.getStart() + "-" + sq.getEnd());
541    * sq.getDatasetSequence().addPDBId(entry);
542    *  // Add PDB DB Refs // We make a DBRefEtntry because we have obtained the
543    * PDB file from a verifiable source // JBPNote - PDB DBRefEntry should also
544    * carry the chain and mapping information DBRefEntry dbentry = new
545    * DBRefEntry(jalview.datamodel.DBRefSource.PDB, "0", id + pdbchain.id);
546    * sq.addDBRef(dbentry); // and add seuqence to the retrieved set
547    * result.addElement(sq.deriveSequence()); } }
548    * 
549    * if (result.size() < 1) { throw new Exception("WsDBFetch for PDB id resulted
550    * in zero result size"); } } catch (Exception ex) // Problem parsing PDB file {
551    * jalview.bin.Cache.log.warn("Exception when retrieving " +
552    * textArea.getText() + " from " + database.getSelectedItem(), ex); return
553    * null; }
554    * 
555    * 
556    * SequenceI[] results = new SequenceI[result.size()]; for (int i = 0, j =
557    * result.size(); i < j; i++) { results[i] = (SequenceI) result.elementAt(i);
558    * result.setElementAt(null,i); } return results; }
559    */
560   AlignmentI parseResult(String result, String title)
561   {
562     String format = new IdentifyFile().Identify(result, "Paste");
563     Alignment sequences = null;
564     if (FormatAdapter.isValidFormat(format))
565     {
566       sequences = null;
567       try
568       {
569         sequences = new FormatAdapter().readFile(result.toString(),
570                 "Paste", format);
571       } catch (Exception ex)
572       {
573       }
574
575       if (sequences != null)
576       {
577         return parseResult(sequences, title, format);
578       }
579     }
580     else
581     {
582       showErrorMessage("Error retrieving " + textArea.getText() + " from "
583               + database.getSelectedItem());
584     }
585
586     return null;
587   }
588
589   AlignmentI parseResult(AlignmentI al, String title,
590           String currentFileFormat)
591   {
592
593     if (al != null && al.getHeight() > 0)
594     {
595       if (alignFrame == null)
596       {
597         AlignFrame af = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
598                 AlignFrame.DEFAULT_HEIGHT);
599         if (currentFileFormat != null)
600         {
601           af.currentFileFormat = currentFileFormat; // WHAT IS THE DEFAULT
602                                                     // FORMAT FOR
603                                                     // NON-FormatAdapter Sourced
604                                                     // Alignments?
605         }
606
607         if (title == null)
608         {
609           title = "Retrieved from " + database.getSelectedItem();
610         }
611
612         Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH,
613                 AlignFrame.DEFAULT_HEIGHT);
614
615         af.statusBar.setText("Successfully pasted alignment file");
616
617         try
618         {
619           af.setMaximum(jalview.bin.Cache.getDefault("SHOW_FULLSCREEN",
620                   false));
621         } catch (Exception ex)
622         {
623         }
624       }
625       else
626       {
627         for (int i = 0; i < al.getHeight(); i++)
628         {
629           alignFrame.viewport.alignment.addSequence(al.getSequenceAt(i)); // this
630                                                                           // also
631                                                                           // creates
632                                                                           // dataset
633                                                                           // sequence
634                                                                           // entries
635         }
636         alignFrame.viewport.setEndSeq(alignFrame.viewport.alignment
637                 .getHeight());
638         alignFrame.viewport.alignment.getWidth();
639         alignFrame.viewport.firePropertyChange("alignment", null,
640                 alignFrame.viewport.getAlignment().getSequences());
641       }
642     }
643     return al;
644   }
645
646   void showErrorMessage(final String error)
647   {
648     resetDialog();
649     javax.swing.SwingUtilities.invokeLater(new Runnable()
650     {
651       public void run()
652       {
653         JOptionPane.showInternalMessageDialog(Desktop.desktop, error,
654                 "Error Retrieving Data", JOptionPane.WARNING_MESSAGE);
655       }
656     });
657   }
658 }