import java.awt.Container;
import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
+import java.util.List;
import java.util.Map;
import javax.swing.JComponent;
import org.jmol.api.JmolAppConsoleInterface;
-import org.jmol.java.BS;
import org.openscience.jmol.app.jmolpanel.console.AppConsole;
import jalview.api.AlignmentViewPanel;
import jalview.ext.jmol.JalviewJmolBinding;
import jalview.io.DataSourceType;
import jalview.structure.StructureSelectionManager;
+import jalview.util.Platform;
+import javajs.util.BS;
public class AppJmolBinding extends JalviewJmolBinding
{
@Override
public void refreshGUI()
{
+ if (getMappedStructureCount() == 0)
+ {
+ // too soon!
+ return;
+ }
// appJmolWindow.repaint();
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
JalviewStructureDisplayI theViewer = getViewer();
+ // invokes colourbySequence() via seqColour_ActionPerformed()
theViewer.updateTitleAndMenus();
((JComponent) theViewer).revalidate();
}
Container consolePanel, String buttonsToShow)
{
jmolViewer.setJmolCallbackListener(this);
- return new AppConsole(jmolViewer, consolePanel, buttonsToShow);
+ // BH comment: can't do this yet [for JS only, or generally?]
+ return Platform.isJS() ? null
+ : new AppConsole(jmolViewer, consolePanel, buttonsToShow);
}
@Override
return null;
}
- /**
- * Overrides the default method to save a session to file, in order to
- * guarantee it is done synchronously. Jmol command 'write STATE path' would
- * execute asynchronously, so instead we get the state and write it directly
- * here.
- */
- @Override
- protected void saveSession(File f)
+ @SuppressWarnings("unused")
+ public void cacheFiles(List<File> files)
{
- String state = jmolViewer.getStateInfo();
- if (state != null)
+ if (files == null)
{
- try
- {
- FileWriter fw = new FileWriter(f);
- fw.write(state);
- fw.close();
- } catch (IOException e)
- {
- Cache.log.error("Error writing Jmol state: " + e.toString());
- }
+ return;
}
- else
+ for (File f : files)
{
- Cache.log.error("Error requesting Jmol state to save");
+ Platform.cacheFileData(f);
}
}
}