From: tcofoegbu Date: Fri, 18 Sep 2015 14:30:05 +0000 (+0100) Subject: JAL-1774 JAL-1506 revised implementaion for clear highlighted column only when the... X-Git-Tag: Release_2_10_0~396 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f7e7acaae61a4701849bf01d550d34e89f655cd8;p=jalview.git 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 --- 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()]);