JAL-2591 simplifying hidden columns usage
[jalview.git] / src / jalview / gui / AnnotationColumnChooser.java
index a15f605..405b43b 100644 (file)
@@ -112,7 +112,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
     setOldHiddenColumns(av.getAlignment().getHiddenColumns());
     adjusting = true;
 
-    setAnnotations(new JComboBox<String>(getAnnotationItems(false)));
+    setAnnotations(new JComboBox<>(getAnnotationItems(false)));
     populateThresholdComboBox(threshold);
     AnnotationColumnChooser lastChooser = av
             .getAnnotationColumnSelectionState();
@@ -244,11 +244,9 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
         HiddenColumns oldHidden = av
                 .getAnnotationColumnSelectionState()
                 .getOldHiddenColumns();
-        if (oldHidden != null && oldHidden.getHiddenRegions() != null
-                && !oldHidden.getHiddenRegions().isEmpty())
+        if (oldHidden != null)
         {
-          for (Iterator<int[]> itr = oldHidden.getHiddenRegions()
-                  .iterator(); itr.hasNext();)
+          for (Iterator<int[]> itr = oldHidden.iterator(); itr.hasNext();)
           {
             int positions[] = itr.next();
             av.hideColumns(positions[0], positions[1]);
@@ -386,10 +384,13 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
       }
     }
 
+    // show hidden columns here, before changing the column selection in
+    // filterAnnotations, because showing hidden columns has the side effect of
+    // adding them to the selection
+    av.showAllHiddenColumns();
     av.getColumnSelection().filterAnnotations(
             getCurrentAnnotation().annotations, filterParams);
 
-    av.showAllHiddenColumns();
     if (getActionOption() == ACTION_OPTION_HIDE)
     {
       av.hideSelectedColumns();
@@ -724,7 +725,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
 
     private static final String FILTER_BY_ANN_CACHE_KEY = "CACHE.SELECT_FILTER_BY_ANNOT";
 
-    public JvCacheableInputBox<String> searchBox = new JvCacheableInputBox<String>(
+    public JvCacheableInputBox<String> searchBox = new JvCacheableInputBox<>(
             FILTER_BY_ANN_CACHE_KEY);
 
     public SearchPanel(AnnotationColumnChooser aColChooser)