JAL-1367 entry in sequence ID popup menu to set/unset sequence as representative
authorJim Procter <jprocter@compbio.dundee.ac.uk>
Fri, 30 Aug 2013 11:32:57 +0000 (12:32 +0100)
committerJim Procter <jprocter@compbio.dundee.ac.uk>
Fri, 30 Aug 2013 11:32:57 +0000 (12:32 +0100)
src/jalview/appletgui/APopupMenu.java
src/jalview/gui/PopupMenu.java

index 1bfc0b3..daf5457 100755 (executable)
@@ -18,7 +18,6 @@
 package jalview.appletgui;
 
 import java.util.*;
-
 import java.awt.*;
 import java.awt.event.*;
 
@@ -469,6 +468,10 @@ public class APopupMenu extends java.awt.PopupMenu implements
     {
       editName();
     }
+    else if (source == makeReferenceSeq)
+    {
+      makeReferenceSeq_actionPerformed();
+    }
     else if (source == sequenceDetails)
     {
       showSequenceDetails();
@@ -844,6 +847,7 @@ public class APopupMenu extends java.awt.PopupMenu implements
     toLower.addActionListener(this);
     editMenu.add(toggleCase);
     seqMenu.add(sequenceName);
+    seqMenu.add(makeReferenceSeq);
     // seqMenu.add(sequenceDetails);
 
     if (!ap.av.applet.useXtrnalSviewer)
@@ -863,6 +867,7 @@ public class APopupMenu extends java.awt.PopupMenu implements
     repGroup.addActionListener(this);
     revealAll.addActionListener(this);
     revealSeq.addActionListener(this);
+    makeReferenceSeq.addActionListener(this);
   }
 
   void refresh()
@@ -1046,6 +1051,28 @@ public class APopupMenu extends java.awt.PopupMenu implements
     getGroup().setDisplayText(showText.getState());
     refresh();
   }
+  public void makeReferenceSeq_actionPerformed()
+  {
+    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(seq);
+    }
+    else
+    {
+      if (ap.av.getAlignment().getSeqrep() == seq)
+      {
+        ap.av.getAlignment().setSeqrep(null);
+      }
+      else
+      {
+        ap.av.getAlignment().setSeqrep(seq);
+      }
+    }
+    refresh();
+  }
 
   public void showNonconserved_itemStateChanged()
   {
index 1a367c5..ebcbd13 100644 (file)
@@ -18,7 +18,6 @@
 package jalview.gui;
 
 import java.util.*;
-
 import java.awt.*;
 import java.awt.event.*;
 
@@ -87,6 +86,8 @@ public class PopupMenu extends JPopupMenu
   JMenuItem sequenceDetails = new JMenuItem();
 
   JMenuItem sequenceSelDetails = new JMenuItem();
+  
+  JMenuItem makeReferenceSeq = new JMenuItem();
 
   SequenceI sequence;
 
@@ -222,6 +223,12 @@ public class PopupMenu extends JPopupMenu
     if (seq != null)
     {
       sequenceMenu.setText(sequence.getName());
+      if (seq == ap.av.getAlignment().getSeqrep())
+      {
+        makeReferenceSeq.setText("Unmark representative");
+      } else {
+        makeReferenceSeq.setText("Mark as representative");
+      }
 
       if (seq.getDatasetSequence().getPDBId() != null
               && seq.getDatasetSequence().getPDBId().size() > 0)
@@ -266,7 +273,6 @@ public class PopupMenu extends JPopupMenu
         }
         // structureMenu.remove(colStructureMenu);
       }
-
       if (ap.av.getAlignment().isNucleotide() == true)
       {
         AlignmentAnnotation[] aa = ap.av.getAlignment()
@@ -319,7 +325,6 @@ public class PopupMenu extends JPopupMenu
             }
           }
         }
-
       }
 
       menuItem = new JMenuItem("Hide Sequences");
@@ -1083,7 +1088,17 @@ public class PopupMenu extends JPopupMenu
         editSequence_actionPerformed(actionEvent);
       }
     });
-
+    makeReferenceSeq.setText("Mark as representative");
+    makeReferenceSeq.addActionListener(new ActionListener()
+    {
+      
+      @Override
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        makeReferenceSeq_actionPerformed(actionEvent);
+        
+      }
+    });
     /*
      * annotationMenuItem.setText("By Annotation");
      * annotationMenuItem.addActionListener(new ActionListener() { public void
@@ -1100,6 +1115,7 @@ public class PopupMenu extends JPopupMenu
     groupMenu.add(jMenu1);
     sequenceMenu.add(sequenceName);
     sequenceMenu.add(sequenceDetails);
+    sequenceMenu.add(makeReferenceSeq);
     colourMenu.add(textColour);
     colourMenu.add(noColourmenuItem);
     colourMenu.add(clustalColour);
@@ -1295,6 +1311,29 @@ public class PopupMenu extends JPopupMenu
             });
   }
 
+  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
+    {
+      if (ap.av.getAlignment().getSeqrep() == sequence)
+      {
+        ap.av.getAlignment().setSeqrep(null);
+      }
+      else
+      {
+        ap.av.getAlignment().setSeqrep(sequence);
+      }
+    }
+    refresh();
+  }
+
   protected void sequenceSelectionDetails_actionPerformed()
   {
     createSequenceDetailsReport(ap.av.getSequenceSelection());