JAL-1774 JAL-1506 revised implementaion for clear highlighted column only when the...
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 18 Sep 2015 14:30:05 +0000 (15:30 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 18 Sep 2015 14:30:05 +0000 (15:30 +0100)
src/jalview/appletgui/AlignFrame.java
src/jalview/gui/AlignFrame.java

index c9183d5..2a2fc81 100644 (file)
@@ -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);
     }
index 8f9e49e..eda4a1c 100644 (file)
@@ -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()]);