Modified AnnotationColumnChooser to maintain state of previous selection when current... features/JAL-1553_select-columns-by-annotation
authorCharles Ofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 14 Jan 2015 11:21:57 +0000 (11:21 +0000)
committerCharles Ofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 14 Jan 2015 11:21:57 +0000 (11:21 +0000)
src/jalview/gui/AnnotationColumnChooser.java

index 4abf49d..87e2d78 100644 (file)
@@ -1,5 +1,6 @@
 package jalview.gui;
 
+import jalview.datamodel.ColumnSelection;
 import jalview.schemes.AnnotationColourGradient;
 import jalview.util.MessageManager;
 
@@ -21,6 +22,8 @@ import net.miginfocom.swing.MigLayout;
 public class AnnotationColumnChooser extends AnnotationRowFilter
 {
 
+  private ColumnSelection oldColumnSelection;
+
   private JComboBox<String> annotations;
 
   JButton ok = new JButton();
@@ -51,7 +54,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter
     {
       return;
     }
-
+    setOldColumnSelection(av.getColumnSelection());
     adjusting = true;
 
     setAnnotations(new JComboBox<String>(
@@ -196,6 +199,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter
   public void reset()
   {
     av.getColumnSelection().clear();
+    av.setColumnSelection(this.getOldColumnSelection());
   }
 
   public void valueChanged(boolean updateAllAnnotation)
@@ -288,4 +292,18 @@ public class AnnotationColumnChooser extends AnnotationRowFilter
     ap.alignmentChanged();
     ap.paintAlignment(true);
   }
+
+  public ColumnSelection getOldColumnSelection()
+  {
+    return oldColumnSelection;
+  }
+
+  public void setOldColumnSelection(ColumnSelection currentColumnSelection)
+  {
+    if (currentColumnSelection != null)
+    {
+      this.oldColumnSelection = new ColumnSelection();
+      this.oldColumnSelection.setElementsFrom(currentColumnSelection);
+    }
+  }
 }