-
- JOptionPane.showInternalMessageDialog(Desktop.desktop,
- "The following pdb entries could not be retrieved from the PDB:\n"
- + errormsgs.toString()
- + "\nPlease try downloading them manually.",
- "Couldn't load file", JOptionPane.ERROR_MESSAGE);
-
- }
- long lastnotify = jmb.getLoadNotifiesHandled();
- if (files.length() > 0)
- {
- if (!addingStructures)
- {
-
- try
- {
- initJmol("load FILES " + files.toString());
- } catch (OutOfMemoryError oomerror)
- {
- new OOMWarning("When trying to open the Jmol viewer!", oomerror);
- Cache.log.debug("File locations are " + files);
- } catch (Exception ex)
- {
- Cache.log.error("Couldn't open Jmol viewer!", ex);
- }
- }
- else
- {
- StringBuffer cmd = new StringBuffer();
- cmd.append("loadingJalviewdata=true\nload APPEND ");
- cmd.append(files.toString());
- cmd.append("\nloadingJalviewdata=null");
- final String command = cmd.toString();
- cmd = null;
- lastnotify = jmb.getLoadNotifiesHandled();
-
- try
- {
- jmb.evalStateCommand(command);
- } catch (OutOfMemoryError oomerror)
- {
- new OOMWarning(
- "When trying to add structures to the Jmol viewer!",
- oomerror);
- Cache.log.debug("File locations are " + files);
- } catch (Exception ex)
- {
- Cache.log.error("Couldn't add files to Jmol viewer!", ex);
- }
- }
-
- // need to wait around until script has finished
- while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled()
- : (jmb.isFinishedInit() && jmb.getPdbFile().length!=jmb.pdbentry.length))
- {
- try
- {
- Cache.log.debug("Waiting around for jmb notify.");
- Thread.sleep(35);
- } catch (Exception e)
- {
- }
- }
- // refresh the sequence colours for the new structure(s)
- for (AlignmentPanel ap : _colourwith)
- {
- jmb.updateColours(ap);
- }
- // do superposition if asked to
- if (alignAddedStructures)
- {
- javax.swing.SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- alignStructs_withAllAlignPanels();
- // jmb.superposeStructures(ap.av.getAlignment(), -1, null);
- }
- });
- alignAddedStructures = false;
- }
- addingStructures = false;
-
- }
- _started = false;
- worker = null;
- }
-
- public void pdbFile_actionPerformed(ActionEvent actionEvent)
- {
- JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
-
- chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle("Save PDB File");
- chooser.setToolTipText("Save");
-
- int value = chooser.showSaveDialog(this);
-
- if (value == JalviewFileChooser.APPROVE_OPTION)
- {
- try
- {
- // TODO: cope with multiple PDB files in view
- BufferedReader in = new BufferedReader(new FileReader(
- jmb.getPdbFile()[0]));
- File outFile = chooser.getSelectedFile();
-
- PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
- String data;
- while ((data = in.readLine()) != null)
- {
- if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
- {
- out.println(data);
- }
- }
- out.close();
- } catch (Exception ex)
- {
- ex.printStackTrace();
- }