Merge branch 'develop' into Release_2_9_0b1_Branch
[jalview.git] / src / jalview / appletgui / AlignFrame.java
index e01c4c9..3040170 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,
@@ -302,6 +304,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     alignPanel.annotationSpaceFillerHolder.addKeyListener(this);
     alignPanel.alabels.addKeyListener(this);
 
+    setAnnotationsVisibility();
+
     if (addToDisplay)
     {
       addToDisplay(embedded);
@@ -913,7 +917,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   /**
    * Set the visibility state of sequence-related and/or alignment-related
-   * annotations depending on checkbox selections. Repaint after calling.
+   * annotations depending on checkbox selections, and repaint.
    * 
    * @param visible
    */
@@ -2059,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);
     }
@@ -3357,8 +3377,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
             MessageManager.getString("label.sort_annotations_by_label"));
     showAutoFirst = new CheckboxMenuItem(
             MessageManager.getString("label.show_first"));
+    showAutoFirst.setState(false); // pending applet parameter
+    setShowAutoCalculatedAbove(showAutoFirst.getState());
     showAutoLast = new CheckboxMenuItem(
             MessageManager.getString("label.show_last"));
+    showAutoLast.setState(!showAutoFirst.getState());
     showAlignmentAnnotations.addItemListener(this);
     showSequenceAnnotations.addItemListener(this);
     sortAnnBySequence.addItemListener(this);