From f7e7acaae61a4701849bf01d550d34e89f655cd8 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Fri, 18 Sep 2015 15:30:05 +0100 Subject: [PATCH] JAL-1774 JAL-1506 revised implementaion for clear highlighted column only when the cut/delete affects the entire sequence and updated the applet version to include a warning if the entire alignment is about to be deleted --- src/jalview/appletgui/AlignFrame.java | 22 ++++++++++++++++++++-- src/jalview/gui/AlignFrame.java | 32 ++++++++++++++++---------------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index c9183d5..2a2fc81 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -105,6 +105,8 @@ import java.util.Map; import java.util.StringTokenizer; import java.util.Vector; +import javax.swing.JOptionPane; + import org.jmol.viewer.Viewer; public class AlignFrame extends EmbmenuFrame implements ActionListener, @@ -2061,9 +2063,25 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, seqs.addElement(seq); } - // If the cut affects all sequences, remove highlighted columns - if (sg.getSize() == viewport.getAlignment().getHeight()) + /* + * If the cut affects all sequences, warn, remove highlighted columns + */if (sg.getSize() == viewport.getAlignment().getHeight()) { + boolean isEntireAlignWidth = (((sg.getEndRes() - sg.getStartRes()) + 1) == viewport + .getAlignment().getWidth()) ? true : false; + if (isEntireAlignWidth) + { + int confirm = JOptionPane.showConfirmDialog(this, + MessageManager.getString("warn.delete_all"), // $NON-NLS-1$ + MessageManager.getString("label.delete_all"), // $NON-NLS-1$ + JOptionPane.OK_CANCEL_OPTION); + + if (confirm == JOptionPane.CANCEL_OPTION + || confirm == JOptionPane.CLOSED_OPTION) + { + return; + } + } viewport.getColumnSelection().removeElements(sg.getStartRes(), sg.getEndRes() + 1); } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 8f9e49e..eda4a1c 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -2370,26 +2370,26 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * If the cut affects all sequences, warn, remove highlighted columns */ - - boolean isEntireAlignWidth = (((sg.getEndRes() - sg.getStartRes()) + 1) == viewport - .getAlignment().getWidth()) ? true : false; - if (sg.getSize() == viewport.getAlignment().getHeight() - && isEntireAlignWidth) + if (sg.getSize() == viewport.getAlignment().getHeight()) { - int confirm = JOptionPane.showConfirmDialog(this, - MessageManager.getString("warn.delete_all"), // $NON-NLS-1$ - MessageManager.getString("label.delete_all"), // $NON-NLS-1$ - JOptionPane.OK_CANCEL_OPTION); - - if (confirm == JOptionPane.CANCEL_OPTION - || confirm == JOptionPane.CLOSED_OPTION) + boolean isEntireAlignWidth = (((sg.getEndRes() - sg.getStartRes()) + 1) == viewport + .getAlignment().getWidth()) ? true : false; + if (isEntireAlignWidth) { - return; + int confirm = JOptionPane.showConfirmDialog(this, + MessageManager.getString("warn.delete_all"), // $NON-NLS-1$ + MessageManager.getString("label.delete_all"), // $NON-NLS-1$ + JOptionPane.OK_CANCEL_OPTION); + + if (confirm == JOptionPane.CANCEL_OPTION + || confirm == JOptionPane.CLOSED_OPTION) + { + return; + } } + viewport.getColumnSelection().removeElements(sg.getStartRes(), + sg.getEndRes() + 1); } - - viewport.getColumnSelection().removeElements(sg.getStartRes(), - sg.getEndRes() + 1); SequenceI[] cut = sg.getSequences() .toArray(new SequenceI[sg.getSize()]); -- 1.7.10.2