/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
import jalview.io.IdentifyFile;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
+import jalview.jbgui.GStructureViewer;
import jalview.structure.StructureSelectionManager;
import jalview.util.ImageMaker;
import jalview.util.MessageManager;
*/
private BlogReader jvnews = null;
+ private File projectFile;
+
/**
* @param listener
* @see jalview.gui.JalviewChangeSupport#addJalviewPropertyChangeListener(java.beans.PropertyChangeListener)
{
final Desktop me = this;
final java.io.File choice = chooser.getSelectedFile();
+ setProjectFile(choice);
+
+ // TODO or move inside the new Thread?
+ saveChimeraSessions(choice.getAbsolutePath());
+
new Thread(new Runnable()
{
public void run()
// TODO prevent user from messing with the Desktop whilst we're saving
try
{
- new Jalview2XML().SaveState(choice);
+ new Jalview2XML().saveState(choice);
} catch (OutOfMemoryError oom)
{
new OOMWarning("Whilst saving current state to "
}
/**
+ * Request any open, linked Chimera sessions to save their state.
+ *
+ * @param jalviewProjectFilename
+ * the filename of the Jalview project; Chimera session files should
+ * be given distinct, but obviously related, names.
+ */
+ public void saveChimeraSessions(String jalviewProjectFilename)
+ {
+ int i = 0;
+ for (JInternalFrame frame : getAllFrames())
+ {
+ if (frame instanceof ChimeraViewFrame)
+ {
+ /*
+ * Construct a filename for the Chimera session by append _chimera<n>.py
+ * to the Jalview project file name.
+ */
+ String chimeraPath = jalviewProjectFilename + "_chimera_" + i
+ + ".py";
+ ((ChimeraViewFrame) frame).saveSession(chimeraPath);
+ i++;
+ }
+ }
+ }
+
+ private void setProjectFile(File choice)
+ {
+ this.projectFile = choice;
+ }
+
+ public File getProjectFile()
+ {
+ return this.projectFile;
+ }
+
+ /**
* DOCUMENT ME!
*
* @param e
if (value == JalviewFileChooser.APPROVE_OPTION)
{
- final String choice = chooser.getSelectedFile().getAbsolutePath();
- jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser
- .getSelectedFile().getParent());
+ final File selectedFile = chooser.getSelectedFile();
+ setProjectFile(selectedFile);
+ final String choice = selectedFile.getAbsolutePath();
+ jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedFile.getParent());
new Thread(new Runnable()
{
public void run()
choice.hashCode());
try
{
- new Jalview2XML().LoadJalviewAlign(choice);
+ new Jalview2XML().loadJalviewAlign(choice);
} catch (OutOfMemoryError oom)
{
new OOMWarning("Whilst loading project from " + choice, oom);
return afs;
}
- public AppJmol[] getJmols()
+ public GStructureViewer[] getJmols()
{
JInternalFrame[] frames = Desktop.desktop.getAllFrames();
{
if (frames[i] instanceof AppJmol)
{
- AppJmol af = (AppJmol) frames[i];
+ GStructureViewer af = (GStructureViewer) frames[i];
avp.addElement(af);
}
}
{
return null;
}
- AppJmol afs[] = new AppJmol[avp.size()];
+ GStructureViewer afs[] = new GStructureViewer[avp.size()];
for (int i = 0, j = avp.size(); i < j; i++)
{
- afs[i] = (AppJmol) avp.elementAt(i);
+ afs[i] = (GStructureViewer) avp.elementAt(i);
}
avp.clear();
return afs;