From: gmungoc Date: Tue, 17 Jan 2017 16:08:58 +0000 (+0000) Subject: Merge branch 'features/JAL-2295setChimeraAttributes' into spikes/mungo X-Git-Tag: Release_2_11_0~62^2~32 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8677e6e34e291edc58c1da2fc9c958473754143f;hp=9d943c5feee75910c47704215a4363f25fecb859;p=jalview.git Merge branch 'features/JAL-2295setChimeraAttributes' into spikes/mungo --- diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index e2e54aa..a30f6d3 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -64,9 +64,7 @@ import java.util.Vector; import javax.swing.JCheckBoxMenuItem; import javax.swing.JColorChooser; -import javax.swing.JInternalFrame; import javax.swing.JMenu; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSplitPane; import javax.swing.SwingUtilities; @@ -338,30 +336,6 @@ public class AppJmol extends StructureViewerBase openNewJmol(ap, pe, seqs); } - /** - * Returns a list of any Jmol viewers. The list is restricted to those linked - * to the given alignment panel if it is not null. - */ - @Override - protected List getViewersFor(AlignmentPanel apanel) - { - List result = new ArrayList(); - JInternalFrame[] frames = Desktop.instance.getAllFrames(); - - for (JInternalFrame frame : frames) - { - if (frame instanceof AppJmol) - { - if (apanel == null - || ((StructureViewerBase) frame).isLinkedWith(apanel)) - { - result.add((StructureViewerBase) frame); - } - } - } - return result; - } - void initJmol(String command) { jmb.setFinishedInit(false); diff --git a/src/jalview/gui/ChimeraViewFrame.java b/src/jalview/gui/ChimeraViewFrame.java index 4c38898..bc247ca 100644 --- a/src/jalview/gui/ChimeraViewFrame.java +++ b/src/jalview/gui/ChimeraViewFrame.java @@ -72,7 +72,6 @@ import javax.swing.JColorChooser; import javax.swing.JInternalFrame; import javax.swing.JMenu; import javax.swing.JMenuItem; -import javax.swing.JOptionPane; import javax.swing.event.InternalFrameAdapter; import javax.swing.event.InternalFrameEvent; import javax.swing.event.MenuEvent; @@ -435,28 +434,6 @@ public class ChimeraViewFrame extends StructureViewerBase setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); } - /** - * Returns a list of any Chimera viewers in the desktop. The list is - * restricted to those linked to the given alignment panel if it is not null. - */ - @Override - protected List getViewersFor(AlignmentPanel ap) - { - List result = new ArrayList(); - JInternalFrame[] frames = Desktop.instance.getAllFrames(); - - for (JInternalFrame frame : frames) - { - if (frame instanceof ChimeraViewFrame) - { - if (ap == null || ((StructureViewerBase) frame).isLinkedWith(ap)) - { - result.add((StructureViewerBase) frame); - } - } - } - return result; - } /** * Launch Chimera. If we have a chimera session file name, send Chimera the @@ -572,35 +549,47 @@ public class ChimeraViewFrame extends StructureViewerBase * option to close the associated Chimera window (process). They may wish to * keep it open until they have had an opportunity to save any work. * - * @param closeChimera + * @param forceCloseChimera * if true, close any linked Chimera process; if false, prompt first */ @Override - public void closeViewer(boolean closeChimera) + public void closeViewer(boolean forceCloseChimera) { - if (jmb != null && jmb.isChimeraRunning()) + if (jmb != null) { - if (!closeChimera) + if (jmb.isChimeraRunning()) { - String prompt = MessageManager.formatMessage( - "label.confirm_close_chimera", - new Object[] { jmb.getViewerTitle("Chimera", false) }); - prompt = JvSwingUtils.wrapTooltip(true, prompt); - int confirm = JvOptionPane.showConfirmDialog(this, prompt, - MessageManager.getString("label.close_viewer"), - JvOptionPane.YES_NO_CANCEL_OPTION); /* - * abort closure if user hits escape or Cancel + * force close, or prompt to close, Chimera */ - if (confirm == JvOptionPane.CANCEL_OPTION - || confirm == JvOptionPane.CLOSED_OPTION) + if (!forceCloseChimera) { - return; + String prompt = MessageManager.formatMessage( + "label.confirm_close_chimera", + new Object[] { jmb.getViewerTitle("Chimera", false) }); + prompt = JvSwingUtils.wrapTooltip(true, prompt); + int confirm = JvOptionPane.showConfirmDialog(this, prompt, + MessageManager.getString("label.close_viewer"), + JvOptionPane.YES_NO_CANCEL_OPTION); + /* + * abort closure if user hits escape or Cancel + */ + if (confirm == JvOptionPane.CANCEL_OPTION + || confirm == JvOptionPane.CLOSED_OPTION) + { + return; + } + forceCloseChimera = confirm == JvOptionPane.YES_OPTION; } - closeChimera = confirm == JvOptionPane.YES_OPTION; } - jmb.closeViewer(closeChimera); + + /* + * close the viewer plus any side-effects e.g. remove mappings + * note we do this also if closing Chimera triggered this method + */ + jmb.closeViewer(forceCloseChimera); } + setAlignmentPanel(null); _aps.clear(); _alignwith.clear(); diff --git a/src/jalview/gui/StructureViewerBase.java b/src/jalview/gui/StructureViewerBase.java index 91d7130..19291ac 100644 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@ -26,6 +26,7 @@ import jalview.gui.StructureViewer.ViewerType; import jalview.gui.ViewSelectionMenu.ViewSetProvider; import jalview.io.DataSourceType; import jalview.jbgui.GStructureViewer; +import jalview.structure.StructureSelectionManager; import jalview.structures.models.AAStructureBindingModel; import jalview.util.MessageManager; @@ -39,8 +40,8 @@ import java.util.List; import java.util.Vector; import javax.swing.JCheckBoxMenuItem; +import javax.swing.JInternalFrame; import javax.swing.JMenuItem; -import javax.swing.JOptionPane; /** * Base class with common functionality for JMol, Chimera or other structure @@ -352,8 +353,29 @@ public abstract class StructureViewerBase extends GStructureViewer protected abstract boolean hasPdbId(String pdbId); - protected abstract List getViewersFor( - AlignmentPanel alp); + /** + * Returns a list of any structure viewers of the same type. The list is + * restricted to those linked to the given alignment panel if it is not null. + */ + protected List getViewersFor(AlignmentPanel alp){ + + List result = new ArrayList(); + JInternalFrame[] frames = Desktop.instance.getAllFrames(); + + for (JInternalFrame frame : frames) + { + if (this.getClass().isAssignableFrom(frame.getClass())) + { + if (alp == null + || ((StructureViewerBase) frame).isLinkedWith(alp)) + { + result.add((StructureViewerBase) frame); + } + } + } + return result; + + } /** * Check for any existing views involving this alignment and give user the @@ -473,8 +495,8 @@ public abstract class StructureViewerBase extends GStructureViewer final AlignmentPanel apanel, String pdbId) { boolean finished = false; - String alreadyMapped = apanel.getStructureSelectionManager() - .alreadyMappedToFile(pdbId); + StructureSelectionManager ssm = apanel.getStructureSelectionManager(); + String alreadyMapped = ssm.alreadyMappedToFile(pdbId); if (alreadyMapped != null) { diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index 7519538..fb8e3f8 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -299,7 +299,7 @@ public class StructureSelectionManager { for (StructureMapping sm : mappings) { - if (sm.getPdbId().equals(pdbid)) + if (sm.getPdbId().equalsIgnoreCase(pdbid)) { return sm.pdbfile; }