JAL-3199 sort annotations after adding from annotation file
[jalview.git] / src / jalview / gui / AlignFrame.java
index e3c42a7..63c0890 100644 (file)
@@ -146,8 +146,6 @@ import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 import javax.swing.JScrollPane;
 import javax.swing.SwingUtilities;
-import javax.swing.event.MenuEvent;
-import javax.swing.event.MenuListener;
 
 /**
  * DOCUMENT ME!
@@ -481,34 +479,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       }
     });
 
-    /*
-     * ensure By Label/Sequence are not selected if annotations
-     * have been reordered manually to CUSTOM order
-     */
-    annotationsMenu.addMenuListener(new MenuListener()
-    {
-      @Override
-      public void menuSelected(MenuEvent e)
-      {
-        SequenceAnnotationOrder sortAnnotationsBy = viewport
-                .getSortAnnotationsBy();
-        sortAnnByLabel.setSelected(
-                sortAnnotationsBy == SequenceAnnotationOrder.LABEL_AND_SEQUENCE);
-        sortAnnBySequence.setSelected(
-                sortAnnotationsBy == SequenceAnnotationOrder.SEQUENCE_AND_LABEL);
-      }
-
-      @Override
-      public void menuDeselected(MenuEvent e)
-      {
-      }
-
-      @Override
-      public void menuCanceled(MenuEvent e)
-      {
-      }
-    });
-
     alignPanel.sortAnnotations();
   }
 
@@ -4721,7 +4691,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       }
       if (isAnnotation)
       {
-
+        alignPanel.sortAnnotations();
         alignPanel.adjustAnnotationHeight();
         viewport.updateSequenceIdColours();
         buildSortByAnnotationScoresMenu();
@@ -5442,7 +5412,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    * Sorts annotations and repaints the alignment
    */
   @Override
-  protected void sortAnnotations()
+  public void sortAnnotations()
   {
     alignPanel.sortAnnotations();
     alignPanel.paintAlignment(false, false);
@@ -5673,13 +5643,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
   }
 
+  /**
+   * Sets the flag for whether auto-calculated annotations should be shown above
+   * other annotations. If the given value is the same as the current setting,
+   * simply returns false. Otherwise updates the setting, and returns true. If
+   * annotation sort order is currently set to 'Custom', this is changed to
+   * 'None', because 'Custom' ordering ignores all sort options.
+   */
   @Override
-  protected boolean setShowAutoCalculatedAbove(
-          boolean showAutoCalculatedAbove)
+  public boolean setShowAutoCalculatedAbove(boolean b)
   {
-    if (viewport.isShowAutocalculatedAbove() != showAutoCalculatedAbove)
+    if (viewport.isShowAutocalculatedAbove() != b)
     {
-      viewport.setShowAutocalculatedAbove(showAutoCalculatedAbove);
+      viewport.setShowAutocalculatedAbove(b);
 
       /*
        * change CUSTOM annotation ordering to NONE