From: James Procter Date: Fri, 12 Jan 2024 14:04:12 +0000 (+0000) Subject: JAL-4366 provide options for updating (or not) the linked alignment or existing align... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9fef0746bf53cc0faff2bd45f1dbdb82398f4c62;p=jalview.git JAL-4366 provide options for updating (or not) the linked alignment or existing alignment when opening a split frame --- diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 3611bce..91dded1 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -22,6 +22,7 @@ package jalview.gui; import java.awt.Container; import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Rectangle; @@ -795,8 +796,13 @@ public class AlignViewport extends AlignmentViewport protected void openLinkedAlignment(AlignmentI al, String title) { String[] options = new String[] { MessageManager.getString("action.no"), - MessageManager.getString("label.split_window"), - MessageManager.getString("label.new_window"), }; + MessageManager.getString("label.split_window") + + "(update new alignment)", + MessageManager.getString("label.new_window"), + MessageManager.getString( + "label.split_window") + "(update this alignment)", + MessageManager.getString( + "label.split_window") + "(leave both unchanged)" }; final String question = JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.open_split_window?")); final AlignViewport us = this; @@ -810,18 +816,33 @@ public class AlignViewport extends AlignmentViewport .setResponseHandler(0, () -> { addDataToAlignment(al); }).setResponseHandler(1, () -> { - us.openLinkedAlignmentAs(al, title, true); + us.openLinkedAlignmentAs(al, title, true, 1); }).setResponseHandler(2, () -> { - us.openLinkedAlignmentAs(al, title, false); + us.openLinkedAlignmentAs(al, title, false, 1); + }).setResponseHandler(3, () -> { + us.openLinkedAlignmentAs(al, title, true, 2); + }).setResponseHandler(4, () -> { + us.openLinkedAlignmentAs(al, title, true, 0); }); + dialog.setLayout(new FlowLayout(FlowLayout.CENTER)); + dialog.setPreferredSize(new Dimension(350,300)); dialog.showDialog(question, MessageManager.getString("label.open_split_window"), JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null, options, options[0]); } - protected void openLinkedAlignmentAs(AlignmentI al, String title, - boolean newWindowOrSplitPane) + /** + * link given alignment to the alignment in this viewport and open + * @param al - alignment containing sequences to link to this alignment + * @param title + * @param newWindowOrSplitPane + * @param alignAs TODO + * @param alignAs - 0 - don't modify either alignment, 1 - align al according to us, 2- align us according to al + * @return alignFrame holding al + */ + protected AlignFrame openLinkedAlignmentAs(AlignmentI al, String title, + boolean newWindowOrSplitPane, int alignAs) { /* * Identify protein and dna alignments. Make a copy of this one if opening @@ -896,9 +917,15 @@ public class AlignViewport extends AlignmentViewport if (newWindowOrSplitPane) { - al.alignAs(thisAlignment); + if (alignAs==1) { + al.alignAs(thisAlignment); + } + if (alignAs==2) { + thisAlignment.alignAs(al); + } AlignmentI mapped = openSplitFrame(newAlignFrame, thisAlignment); } + return newAlignFrame; } /**