JAL-1665 refactored Sequence.getSequenceFeatures
[jalview.git] / src / jalview / gui / PopupMenu.java
index 41cb6b1..1137990 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.
    * 
@@ -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());
@@ -1990,10 +2023,10 @@ protected void makeReferenceSeq_actionPerformed(ActionEvent actionEvent)
     }
     cap.setText("<html>" + contents.toString() + "</html>");
 
-    Desktop.instance.addInternalFrame(cap, MessageManager.formatMessage(
-            "label.sequece_details_for",
-            (sequences.length == 1 ? new String[]
-            { sequences[0].getDisplayId(true) } : new String[]
+    Desktop.addInternalFrame(cap, MessageManager.formatMessage(
+            "label.sequence_details_for",
+            (sequences.length == 1 ? new Object[]
+            { sequences[0].getDisplayId(true) } : new Object[]
             { MessageManager.getString("label.selection") })), 500, 400);
 
   }