/*
- * Jalview - A Sequence Alignment Editor and Viewer
- * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
- *
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
+ * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
private static jalview.ws.SequenceFetcher sfetch = null;
private static String dasRegistry = null;
+ /**
+ * Blocking method that initialises and returns the shared instance of the SequenceFetcher client
+ * @param guiWindow - where the initialisation delay message should be shown
+ * @return the singleton instance of the sequence fetcher client
+ */
+ public static jalview.ws.SequenceFetcher getSequenceFetcherSingleton(final IProgressIndicator guiWindow) {
+ if (sfetch == null
+ || dasRegistry != DasSourceBrowser.getDasRegistryURL())
+ {
+ /**
+ * give a visual indication that sequence fetcher construction is
+ * occuring
+ */
+ if (guiWindow != null)
+ {
+ guiWindow.setProgressBar(
+ "Initialising Sequence Database Fetchers", Thread.currentThread()
+ .hashCode());
+ }
+ dasRegistry = DasSourceBrowser.getDasRegistryURL();
+ jalview.ws.SequenceFetcher sf = new jalview.ws.SequenceFetcher();
+ if (guiWindow != null)
+ {
+ guiWindow.setProgressBar(
+ "Initialising Sequence Database Fetchers", Thread.currentThread().hashCode());
+ }
+ sfetch = sf;
+ }
+ return sfetch;
+ }
public SequenceFetcher(IProgressIndicator guiIndic)
{
final IProgressIndicator guiWindow = guiIndic;
public void run()
{
- if (sfetch == null
- || dasRegistry != DasSourceBrowser.getDasRegistryURL())
+ if (getSequenceFetcherSingleton(guiWindow)!=null)
{
- /**
- * give a visual indication that sequence fetcher construction is
- * occuring
- */
- if (guiWindow != null)
- {
- guiWindow.setProgressBar(
- "Initialising Sequence Database Fetchers", this
- .hashCode());
- }
- dasRegistry = DasSourceBrowser.getDasRegistryURL();
- jalview.ws.SequenceFetcher sf = new jalview.ws.SequenceFetcher();
- if (guiWindow != null)
+ us.initGui(guiWindow);
+ } else {
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
{
- guiWindow.setProgressBar(
- "Initialising Sequence Database Fetchers", this
- .hashCode());
- }
- sfetch = sf;
-
+ public void run()
+ {
+ JOptionPane.showInternalMessageDialog(Desktop.desktop,
+ "Could not create the sequence fetcher client. Check error logs for details.",
+ "Couldn't create SequenceFetcher", JOptionPane.ERROR_MESSAGE);
+ }
+ });
+
+ // raise warning dialog
}
- us.initGui(guiWindow);
}
});
sf.start();
frame.setContentPane(this);
if (new jalview.util.Platform().isAMac())
{
- Desktop.addInternalFrame(frame, getFrameTitle(), 400, 140);
+ Desktop.addInternalFrame(frame, getFrameTitle(), 400, 180);
}
else
{
- Desktop.addInternalFrame(frame, getFrameTitle(), 400, 125);
+ Desktop.addInternalFrame(frame, getFrameTitle(), 400, 140);
}
}
e.printStackTrace();
} catch (OutOfMemoryError e)
{
+ // resets dialog box - so we don't use OOMwarning here.
showErrorMessage("Out of Memory when retrieving "
+ textArea.getText()
+ " from "
+ " from " + database.getSelectedItem());
e.printStackTrace();
}
- guiWindow.setProgressBar(null, Thread.currentThread().hashCode());
if (aresult != null)
{
parseResult(aresult, null, null);
}
+ // only remove visual delay after we finished parsing.
+ guiWindow.setProgressBar(null, Thread.currentThread().hashCode());
resetDialog();
}