X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPymolViewer.java;h=52c253d34a8117b1950fe4260c2e8dcfd170e8e4;hb=ca160187a050f6d4e50158cd5b51f75c83a7179e;hp=efbd1553b20a5bb0dd49051e34590ef45334b2ec;hpb=a1984b1c8c273ed33c7ce9283039f4027dcae2de;p=jalview.git
diff --git a/src/jalview/gui/PymolViewer.java b/src/jalview/gui/PymolViewer.java
index efbd155..52c253d 100644
--- a/src/jalview/gui/PymolViewer.java
+++ b/src/jalview/gui/PymolViewer.java
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview 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 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview 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 Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.gui;
import java.awt.event.ActionEvent;
@@ -14,7 +34,7 @@ import javax.swing.event.InternalFrameEvent;
import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureRenderer;
-import jalview.bin.Cache;
+import jalview.bin.Console;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.datamodel.StructureViewerModel;
@@ -50,9 +70,7 @@ public class PymolViewer extends StructureViewerBase
AlignmentPanel ap)
{
this();
- openNewPymol(ap, new PDBEntry[] { pdb },
- new SequenceI[][]
- { seqs });
+ openNewPymol(ap, new PDBEntry[] { pdb }, new SequenceI[][] { seqs });
}
public PymolViewer(PDBEntry[] pe, boolean alignAdded, SequenceI[][] seqs,
@@ -161,11 +179,12 @@ public class PymolViewer extends StructureViewerBase
public void run()
{
// todo pull up much of this
-
+
StringBuilder errormsgs = new StringBuilder(128);
List filePDB = new ArrayList<>();
List filePDBpos = new ArrayList<>();
- String[] curfiles = binding.getStructureFiles(); // files currently in viewer
+ String[] curfiles = binding.getStructureFiles(); // files currently in
+ // viewer
for (int pi = 0; pi < binding.getPdbCount(); pi++)
{
String file = null;
@@ -186,8 +205,7 @@ public class PymolViewer extends StructureViewerBase
/*
* got file already
*/
- file = new File(thePdbEntry.getFile()).getAbsoluteFile()
- .getPath();
+ file = new File(thePdbEntry.getFile()).getAbsoluteFile().getPath();
// todo - skip if already loaded in PyMOL
}
if (file != null)
@@ -196,7 +214,7 @@ public class PymolViewer extends StructureViewerBase
filePDBpos.add(Integer.valueOf(pi));
}
}
-
+
if (!filePDB.isEmpty())
{
/*
@@ -210,9 +228,19 @@ public class PymolViewer extends StructureViewerBase
initPymol();
} catch (Exception ex)
{
- Cache.error("Couldn't open PyMOL viewer!", ex);
+ Console.error("Couldn't open PyMOL viewer!", ex);
+ // if we couldn't open Pymol, no point continuing
+ return;
}
}
+ if (!binding.isViewerRunning())
+ {
+ // nothing to do
+ // TODO: ensure we tidy up JAL-3619
+
+ return;
+ }
+
int num = -1;
for (PDBEntry pe : filePDB)
{
@@ -242,16 +270,23 @@ public class PymolViewer extends StructureViewerBase
stopProgressBar("", startTime);
}
- StructureFile pdb = binding.getSsm().setMapping(
- binding.getSequence()[pos], binding.getChains()[pos],
- pe.getFile(), protocol,
- getProgressIndicator());
+ StructureFile pdb = null;
+ if (pe.hasStructureFile())
+ {
+ pdb = pe.getStructureFile();
+ Console.debug("(Re)Using StructureFile " + pdb.getId());
+ }
+ else
+ {
+ pdb = binding.getSsm().setMapping(binding.getSequence()[pos],
+ binding.getChains()[pos], pe.getFile(), protocol,
+ getProgressIndicator());
+ }
binding.stashFoundChains(pdb, pe.getFile());
} catch (Exception ex)
{
- Cache.error(
- "Couldn't open " + pe.getFile() + " in Chimera viewer!",
- ex);
+ Console.error("Couldn't open " + pe.getFile() + " in "
+ + getViewerName() + "!", ex);
} finally
{
// Cache.debug("File locations are " + files);
@@ -314,6 +349,7 @@ public class PymolViewer extends StructureViewerBase
getViewerName()),
MessageManager.getString("label.error_loading_file"),
JvOptionPane.ERROR_MESSAGE);
+ binding.closeViewer(true);
this.dispose();
return;
}
@@ -323,8 +359,7 @@ public class PymolViewer extends StructureViewerBase
boolean opened = binding.openSession(pymolSessionFile);
if (!opened)
{
- Cache.error(
- "An error occurred opening PyMOL session file "
+ Console.error("An error occurred opening PyMOL session file "
+ pymolSessionFile);
}
}
@@ -348,7 +383,9 @@ public class PymolViewer extends StructureViewerBase
{
return "PyMOL";
}
+
JMenuItem writeFeatures = null;
+
@Override
protected void initMenus()
{
@@ -359,8 +396,8 @@ public class PymolViewer extends StructureViewerBase
writeFeatures = new JMenuItem(
MessageManager.getString("label.create_viewer_attributes"));
- writeFeatures.setToolTipText(MessageManager
- .getString("label.create_viewer_attributes_tip"));
+ writeFeatures.setToolTipText(
+ MessageManager.getString("label.create_viewer_attributes_tip"));
writeFeatures.addActionListener(new ActionListener()
{
@Override
@@ -371,7 +408,7 @@ public class PymolViewer extends StructureViewerBase
});
viewerActionMenu.add(writeFeatures);
}
-
+
@Override
protected void buildActionMenu()
{
@@ -382,8 +419,8 @@ public class PymolViewer extends StructureViewerBase
protected void sendFeaturesToPymol()
{
int count = binding.sendFeaturesToViewer(getAlignmentPanel());
- statusBar.setText(
- MessageManager.formatMessage("label.attributes_set", count, getViewerName()));
+ statusBar.setText(MessageManager.formatMessage("label.attributes_set",
+ count, getViewerName()));
}
}