Merge branch 'develop' into features/JAL-845splitPaneMergeDevelop
[jalview.git] / src / jalview / gui / PopupMenu.java
index 41cb6b1..2ac0856 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
@@ -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.
    * 
@@ -1513,7 +1516,8 @@ public class PopupMenu extends JPopupMenu
         editSequence_actionPerformed(actionEvent);
       }
     });
-    makeReferenceSeq.setText("Mark as representative");
+    makeReferenceSeq.setText(MessageManager
+            .getString("label.mark_as_representative"));
     makeReferenceSeq.addActionListener(new ActionListener()
     {
       
@@ -1524,6 +1528,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 +1547,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);
 
@@ -1929,29 +1947,44 @@ public class PopupMenu extends JPopupMenu
     }
     refresh();
   }
-protected void makeReferenceSeq_actionPerformed(ActionEvent actionEvent)
-{
-  if (!ap.av.getAlignment().hasSeqrep())
-  {
-    // initialise the display flags so the user sees something happen
-    ap.av.setDisplayReferenceSeq(true);
-    ap.av.setColourByReferenceSeq(true);
-    ap.av.getAlignment().setSeqrep(sequence);
-  }
-  else
+
+  protected void makeReferenceSeq_actionPerformed(ActionEvent actionEvent)
   {
-    if (ap.av.getAlignment().getSeqrep() == sequence)
+    if (!ap.av.getAlignment().hasSeqrep())
     {
-      ap.av.getAlignment().setSeqrep(null);
+      // initialise the display flags so the user sees something happen
+      ap.av.setDisplayReferenceSeq(true);
+      ap.av.setColourByReferenceSeq(true);
+      ap.av.getAlignment().setSeqrep(sequence);
     }
     else
     {
-      ap.av.getAlignment().setSeqrep(sequence);
+      if (ap.av.getAlignment().getSeqrep() == sequence)
+      {
+        ap.av.getAlignment().setSeqrep(null);
+      }
+      else
+      {
+        ap.av.getAlignment().setSeqrep(sequence);
+      }
     }
+    refresh();
   }
-  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());
@@ -2157,14 +2190,14 @@ protected void makeReferenceSeq_actionPerformed(ActionEvent actionEvent)
       int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
               .getName());
 
-      sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
+      sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
 
       SliderPanel.showPIDSlider();
     }
     else
     // remove PIDColouring
     {
-      sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
+      sg.cs.setThreshold(0, ap.av.isIgnoreGapsConsensus());
     }
 
     refresh();
@@ -2515,15 +2548,7 @@ protected void makeReferenceSeq_actionPerformed(ActionEvent actionEvent)
     }
 
     int gsize = sg.getSize();
-    SequenceI[] hseqs;
-
-    hseqs = new SequenceI[gsize];
-
-    int index = 0;
-    for (int i = 0; i < gsize; i++)
-    {
-      hseqs[index++] = sg.getSequenceAt(i);
-    }
+    SequenceI[] hseqs = sg.getSequences().toArray(new SequenceI[gsize]);
 
     ap.av.hideSequence(hseqs);
     // refresh(); TODO: ? needed ?
@@ -2547,7 +2572,8 @@ protected void makeReferenceSeq_actionPerformed(ActionEvent actionEvent)
 
     if (sg != null)
     {
-      int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
+      List<int[]> startEnd = ap.av.getVisibleRegionBoundaries(
+              sg.getStartRes(),
               sg.getEndRes() + 1);
 
       String description;