From: gmungoc Date: Wed, 26 Oct 2016 15:42:51 +0000 (+0100) Subject: JAL-2287 Cancel option on Close Chimera? dialog X-Git-Tag: Release_2_10_1^2~22^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e4114b3b614b3fd7a83e7706e4a6f0e8a3a7228e;p=jalview.git JAL-2287 Cancel option on Close Chimera? dialog --- diff --git a/src/jalview/gui/ChimeraViewFrame.java b/src/jalview/gui/ChimeraViewFrame.java index c30a418..bccbda8 100644 --- a/src/jalview/gui/ChimeraViewFrame.java +++ b/src/jalview/gui/ChimeraViewFrame.java @@ -196,7 +196,7 @@ public class ChimeraViewFrame extends StructureViewerBase public ChimeraViewFrame(PDBEntry pdbentry, SequenceI[] seq, String[] chains, final AlignmentPanel ap) { - super(); + this(); String pdbId = pdbentry.getId(); /* @@ -333,7 +333,7 @@ public class ChimeraViewFrame extends StructureViewerBase SequenceI[][] seqsArray, boolean colourByChimera, boolean colourBySequence, String newViewId) { - super(); + this(); setViewId(newViewId); this.chimeraSessionFile = chimeraSessionFile; openNewChimera(alignPanel, pdbArray, seqsArray); @@ -362,31 +362,22 @@ public class ChimeraViewFrame extends StructureViewerBase public ChimeraViewFrame(PDBEntry[] pe, SequenceI[][] seqs, AlignmentPanel ap) { - super(); + this(); openNewChimera(ap, pe, seqs); } - public ChimeraViewFrame(Map> toView, - AlignmentPanel alignPanel) + /** + * Default constructor + */ + public ChimeraViewFrame() { super(); /* - * Convert the map of sequences per pdb entry into the tied arrays expected - * by openNewChimera - * - * TODO pass the Map down to openNewChimera and its callees instead + * closeViewer will decide whether or not to close this frame + * depending on whether user chooses to Cancel or not */ - final Set pdbEntries = toView.keySet(); - PDBEntry[] pdbs = pdbEntries.toArray(new PDBEntry[pdbEntries.size()]); - SequenceI[][] seqsForPdbs = new SequenceI[pdbEntries.size()][]; - for (int i = 0; i < pdbs.length; i++) - { - final List seqsForPdb = toView.get(pdbs[i]); - seqsForPdbs[i] = seqsForPdb.toArray(new SequenceI[seqsForPdb.size()]); - } - - openNewChimera(alignPanel, pdbs, seqsForPdbs); + setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); } /** @@ -543,7 +534,11 @@ public class ChimeraViewFrame extends StructureViewerBase prompt = JvSwingUtils.wrapTooltip(true, prompt); int confirm = JOptionPane.showConfirmDialog(this, prompt, MessageManager.getString("label.close_viewer"), - JOptionPane.YES_NO_OPTION); + JOptionPane.YES_NO_CANCEL_OPTION); + if (confirm == JOptionPane.CANCEL_OPTION) + { + return; + } closeChimera = confirm == JOptionPane.YES_OPTION; } jmb.closeViewer(closeChimera); @@ -555,6 +550,7 @@ public class ChimeraViewFrame extends StructureViewerBase // TODO: check for memory leaks where instance isn't finalised because jmb // holds a reference to the window jmb = null; + dispose(); } /**