- /**
- * Fetch PDB data and save to a local file. Returns the full path to the file,
- * or null if fetch fails.
- *
- * @param processingEntry
- * @return
- * @throws Exception
- */
-
- private void stashFoundChains(StructureFile pdb, String file)
- {
- for (int i = 0; i < pdb.getChains().size(); i++)
- {
- String chid = new String(pdb.getId() + ":"
- + pdb.getChains().elementAt(i).id);
- jmb.getChainNames().add(chid);
- jmb.getChainFile().put(chid, file);
- }
- }
- private String fetchPdbFile(PDBEntry processingEntry) throws Exception
- {
- // FIXME: this is duplicated code with Jmol frame ?
- String filePath = null;
- Pdb pdbclient = new Pdb();
- AlignmentI pdbseq = null;
- String pdbid = processingEntry.getId();
- long handle = System.currentTimeMillis()
- + Thread.currentThread().hashCode();
-
- /*
- * Write 'fetching PDB' progress on AlignFrame as we are not yet visible
- */
- String msg = MessageManager.formatMessage("status.fetching_pdb",
- new Object[] { pdbid });
- getAlignmentPanel().alignFrame.setProgressBar(msg, handle);
- // long hdl = startProgressBar(MessageManager.formatMessage(
- // "status.fetching_pdb", new Object[]
- // { pdbid }));
- try
- {
- pdbseq = pdbclient.getSequenceRecords(pdbid);
- } catch (OutOfMemoryError oomerror)
- {
- new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
- } finally
- {
- msg = pdbid + " " + MessageManager.getString("label.state_completed");
- getAlignmentPanel().alignFrame.setProgressBar(msg, handle);
- // stopProgressBar(msg, hdl);
- }
- /*
- * If PDB data were saved and are not invalid (empty alignment), return the
- * file path.
- */
- if (pdbseq != null && pdbseq.getHeight() > 0)
- {
- // just use the file name from the first sequence's first PDBEntry
- filePath = new File(pdbseq.getSequenceAt(0).getAllPDBEntries()
- .elementAt(0).getFile()).getAbsolutePath();
- processingEntry.setFile(filePath);
- }
- return filePath;
- }
-
- /**
- * Convenience method to update the progress bar if there is one. Be sure to
- * call stopProgressBar with the returned handle to remove the message.
- *
- * @param msg
- * @param handle
- */
- public long startProgressBar(String msg)
- {
- // TODO would rather have startProgress/stopProgress as the
- // IProgressIndicator interface
- long tm = random.nextLong();
- if (progressBar != null)
- {
- progressBar.setProgressBar(msg, tm);
- }
- return tm;
- }
-
- /**
- * End the progress bar with the specified handle, leaving a message (if not
- * null) on the status bar
- *
- * @param msg
- * @param handle
- */
- public void stopProgressBar(String msg, long handle)
- {
- if (progressBar != null)
- {
- progressBar.setProgressBar(msg, handle);
- }
- }
-
- @Override
- public void eps_actionPerformed(ActionEvent e)
- {
- throw new Error(
- MessageManager
- .getString("error.eps_generation_not_implemented"));
- }
-
- @Override
- public void png_actionPerformed(ActionEvent e)
- {
- throw new Error(
- MessageManager
- .getString("error.png_generation_not_implemented"));
- }
-