JAL-1628 method to hide insertions to current sequence selection
authorJim Procter <jprocter@dundee.ac.uk>
Sun, 18 Jan 2015 15:36:14 +0000 (15:36 +0000)
committerJim Procter <jprocter@dundee.ac.uk>
Sun, 18 Jan 2015 15:36:14 +0000 (15:36 +0000)
src/jalview/gui/PopupMenu.java
src/jalview/viewmodel/AlignmentViewport.java

index 41cb6b1..b300f5d 100644 (file)
@@ -29,6 +29,7 @@ import jalview.commands.EditCommand.Action;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.Annotation;
+import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.Sequence;
@@ -222,6 +223,8 @@ public class PopupMenu extends JPopupMenu
 
   JMenu groupLinksMenu;
 
+  JMenuItem hideInsertions = new JMenuItem();
+
   /**
    * Creates a new PopupMenu object.
    * 
@@ -1524,6 +1527,16 @@ public class PopupMenu extends JPopupMenu
         
       }
     });
+    hideInsertions.setText(MessageManager.getString("label.hide_insertions"));
+    hideInsertions.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        hideInsertions_actionPerformed(e);
+      }
+    });
     /*
      * annotationMenuItem.setText("By Annotation");
      * annotationMenuItem.addActionListener(new ActionListener() { public void
@@ -1533,7 +1546,11 @@ public class PopupMenu extends JPopupMenu
     groupMenu.add(sequenceSelDetails);
     add(groupMenu);
     add(sequenceMenu);
-    this.add(structureMenu);
+    add(structureMenu);
+    if (sequence!=null)
+    {
+      add(hideInsertions);
+    }
     // annotations configuration panel suppressed for now
     // groupMenu.add(chooseAnnotations);
 
@@ -1952,6 +1969,20 @@ protected void makeReferenceSeq_actionPerformed(ActionEvent actionEvent)
   refresh();
 }
 
+  protected void hideInsertions_actionPerformed(ActionEvent actionEvent)
+  {
+    if (sequence != null)
+    {
+      ColumnSelection cs = ap.av.getColumnSelection();
+      if (cs == null)
+      {
+        cs = new ColumnSelection();
+      }
+      cs.hideInsertionsFor(sequence);
+      ap.av.setColumnSelection(cs);
+    }
+    refresh();
+  }
   protected void sequenceSelectionDetails_actionPerformed()
   {
     createSequenceDetailsReport(ap.av.getSequenceSelection());
index 9510c2f..98b8d64 100644 (file)
@@ -649,9 +649,14 @@ public abstract class AlignmentViewport implements AlignViewportI
     return colSel;
   }
 
+  @Override
   public void setColumnSelection(ColumnSelection colSel)
   {
     this.colSel = colSel;
+    if (colSel != null)
+    {
+      updateHiddenColumns();
+    }
   }
 
   /**