Unique name for new group and treegroup
[jalview.git] / src / jalview / gui / PopupMenu.java
index 5213bad..9ed81ab 100755 (executable)
@@ -81,6 +81,8 @@ public class PopupMenu extends JPopupMenu
   JMenuItem discoverPDB = new JMenuItem();\r
   JMenu outputMenu = new JMenu();\r
   JMenuItem sequenceFeature = new JMenuItem();\r
+  JMenuItem textColour = new JMenuItem();\r
+  JMenu jMenu1 = new JMenu();\r
 \r
   /**\r
      * Creates a new PopupMenu object.\r
@@ -178,7 +180,7 @@ public class PopupMenu extends JPopupMenu
           add(menuItem);\r
 \r
           if(ap.av.getSelectionGroup() !=null\r
-             && ap.av.getSelectionGroup().getSize(false)>1)\r
+             && ap.av.getSelectionGroup().getSize()>1)\r
           {\r
             menuItem = new JMenuItem("Represent Group with " + seq.getName());\r
             menuItem.addActionListener(new java.awt.event.ActionListener()\r
@@ -510,23 +512,25 @@ public class PopupMenu extends JPopupMenu
         sequenceFeature_actionPerformed(e);\r
       }\r
     });\r
+    textColour.setText("Text Colour");\r
+    textColour.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        textColour_actionPerformed(e);\r
+      }\r
+    });\r
+    jMenu1.setText("Group");\r
     add(groupMenu);\r
 \r
     add(sequenceMenu);\r
     groupMenu.add(editMenu);\r
     groupMenu.add(outputMenu);\r
-    groupMenu.addSeparator();\r
     groupMenu.add(sequenceFeature);\r
-    groupMenu.addSeparator();\r
-    groupMenu.add(groupName);\r
-    groupMenu.add(unGroupMenuItem);\r
-    groupMenu.add(colourMenu);\r
-    groupMenu.add(showBoxes);\r
-    groupMenu.add(showText);\r
-    groupMenu.add(showColourText);\r
-    groupMenu.add(outline);\r
+    groupMenu.add(jMenu1);\r
     sequenceMenu.add(sequenceName);\r
     sequenceMenu.add(pdbMenu);\r
+    colourMenu.add(textColour);\r
     colourMenu.add(noColourmenuItem);\r
         colourMenu.add(clustalColour);\r
         colourMenu.add(BLOSUM62Colour);\r
@@ -573,6 +577,13 @@ public class PopupMenu extends JPopupMenu
     pdbMenu.add(pdbFromFile);\r
     pdbMenu.add(enterPDB);\r
     pdbMenu.add(discoverPDB);\r
+    jMenu1.add(groupName);\r
+    jMenu1.add(unGroupMenuItem);\r
+    jMenu1.add(colourMenu);\r
+    jMenu1.add(showBoxes);\r
+    jMenu1.add(showText);\r
+    jMenu1.add(showColourText);\r
+    jMenu1.add(outline);\r
     noColourmenuItem.setText("None");\r
         noColourmenuItem.addActionListener(new java.awt.event.ActionListener()\r
             {\r
@@ -707,7 +718,7 @@ public class PopupMenu extends JPopupMenu
     protected void clustalColour_actionPerformed(ActionEvent e)\r
     {\r
         SequenceGroup sg = getGroup();\r
-        sg.cs = new ClustalxColourScheme(sg.getSequences(true),\r
+        sg.cs = new ClustalxColourScheme(sg.getSequences(ap.av.hiddenRepSequences),\r
                 ap.av.alignment.getWidth());\r
         refresh();\r
     }\r
@@ -814,7 +825,7 @@ public class PopupMenu extends JPopupMenu
         if (abovePIDColour.isSelected())\r
         {\r
           sg.cs.setConsensus(AAFrequency.calculate(\r
-              sg.getSequences(true), sg.getStartRes(),\r
+              sg.getSequences(ap.av.hiddenRepSequences), sg.getStartRes(),\r
               sg.getEndRes() + 1));\r
 \r
             int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs,\r
@@ -861,7 +872,7 @@ public class PopupMenu extends JPopupMenu
     {\r
         SequenceGroup sg = getGroup();\r
         sg.cs = new PIDColourScheme();\r
-        sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(true),\r
+        sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av.hiddenRepSequences),\r
                                                  sg.getStartRes(),\r
                                                  sg.getEndRes() + 1));\r
         refresh();\r
@@ -878,7 +889,7 @@ public class PopupMenu extends JPopupMenu
 \r
         sg.cs = new Blosum62ColourScheme();\r
 \r
-        sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(true),\r
+        sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av.hiddenRepSequences),\r
                                                  sg.getStartRes(),\r
                                                  sg.getEndRes() + 1));\r
 \r
@@ -911,7 +922,7 @@ public class PopupMenu extends JPopupMenu
         {\r
             Conservation c = new Conservation("Group",\r
                     ResidueProperties.propHash, 3,\r
-                    sg.getSequences(true),\r
+                    sg.getSequences(ap.av.hiddenRepSequences),\r
                     sg.getStartRes(),\r
                     sg.getEndRes() + 1);\r
 \r
@@ -952,31 +963,6 @@ public class PopupMenu extends JPopupMenu
         groupName.setText(reply);\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param e DOCUMENT ME!\r
-     */\r
-    protected void analyze_actionPerformed(ActionEvent e)\r
-    {\r
-        CutAndPasteTransfer cap = new CutAndPasteTransfer();\r
-        JInternalFrame frame = new JInternalFrame();\r
-        frame.setContentPane(cap);\r
-        Desktop.addInternalFrame(frame, "Analyze this - ", 400, 300);\r
-\r
-        SequenceGroup sg = getGroup();\r
-        StringBuffer sb = new StringBuffer();\r
-\r
-        for (int i = 0; i < sg.getSize(false); i++)\r
-        {\r
-            Sequence tmp = (Sequence) sg.getSequences(false).elementAt(i);\r
-            sb.append(tmp.getSequence(sg.getStartRes(), sg.getEndRes() + 1));\r
-            sb.append("\n");\r
-        }\r
-\r
-        sb.append("Something amazing will happen soon");\r
-        cap.setText(sb.toString());\r
-    }\r
 \r
     /**\r
      * DOCUMENT ME!\r
@@ -1040,13 +1026,15 @@ public class PopupMenu extends JPopupMenu
             }\r
 \r
             s = s.replace(' ', '_');\r
-            sequence.getDatasetSequence().setName(s);\r
             sequence.setName(s);\r
             ap.repaint();\r
         }\r
 \r
-        sequence.getDatasetSequence().setDescription(description.getText());\r
         sequence.setDescription(description.getText());\r
+\r
+        ap.av.firePropertyChange("alignment", null,\r
+                                  ap.av.getAlignment().getSequences());\r
+\r
     }\r
 \r
     /**\r
@@ -1136,34 +1124,33 @@ public class PopupMenu extends JPopupMenu
     void hideSequences(boolean representGroup)\r
     {\r
       SequenceGroup sg = ap.av.getSelectionGroup();\r
-      if(sg==null || sg.getSize(false)<1)\r
+      if(sg==null || sg.getSize()<1)\r
       {\r
         ap.av.hideSequence(new SequenceI[]{sequence});\r
         return;\r
       }\r
 \r
-      int gsize = sg.getSize(false);\r
-      SequenceI [] hseqs;\r
+      ap.av.setSelectionGroup(null);\r
 \r
-      hseqs = new SequenceI[ representGroup ? gsize-1 : gsize ];\r
+      if (representGroup)\r
+      {\r
+        ap.av.hideRepSequences(sequence, sg);\r
 \r
-        int index = 0;\r
-        for(int i=0; i<gsize; i++)\r
-        {\r
-          if(representGroup && sg.getSequenceAt(i)!=sequence)\r
-          {\r
-            sequence.addHiddenSequence(sg.getSequenceAt(i));\r
-            hseqs[index++] = sg.getSequenceAt(i);\r
-          }\r
-          else if(!representGroup)\r
-          {\r
-            hseqs[index++] = sg.getSequenceAt(i);\r
-          }\r
-        }\r
+        return;\r
+      }\r
 \r
-        ap.av.hideSequence(hseqs);\r
+      int gsize = sg.getSize();\r
+      SequenceI[] hseqs;\r
 \r
-        ap.av.setSelectionGroup(null);\r
+      hseqs = new SequenceI[gsize];\r
+\r
+      int index = 0;\r
+      for (int i = 0; i < gsize; i++)\r
+      {\r
+        hseqs[index++] = sg.getSequenceAt(i);\r
+      }\r
+\r
+      ap.av.hideSequence(hseqs);\r
     }\r
 \r
   public void copy_actionPerformed(ActionEvent e)\r
@@ -1238,7 +1225,8 @@ public class PopupMenu extends JPopupMenu
       }\r
 \r
       ChangeCaseCommand caseCommand = new ChangeCaseCommand(\r
-          description, sg.getSequencesAsArray(true), startEnd, caseChange\r
+          description, sg.getSequencesAsArray(ap.av.hiddenRepSequences),\r
+          startEnd, caseChange\r
           );\r
 \r
       ap.alignFrame.addHistoryItem(caseCommand);\r
@@ -1253,6 +1241,7 @@ public class PopupMenu extends JPopupMenu
   public void outputText_actionPerformed(ActionEvent e)\r
   {\r
     CutAndPasteTransfer cap = new CutAndPasteTransfer();\r
+    cap.setForInput(null);\r
     Desktop.addInternalFrame(cap,\r
                              "Alignment output - " + e.getActionCommand(), 600,\r
                              500);\r
@@ -1346,7 +1335,7 @@ public class PopupMenu extends JPopupMenu
     if(sg==null)\r
       return;\r
 \r
-    int gSize= sg.getSize(false);\r
+    int gSize= sg.getSize();\r
     SequenceI [] seqs = new SequenceI[gSize];\r
     SequenceFeature [] features = new SequenceFeature[gSize];\r
 \r
@@ -1366,4 +1355,11 @@ public class PopupMenu extends JPopupMenu
       ap.highlightSearchResults(null);\r
     }\r
   }\r
+\r
+  public void textColour_actionPerformed(ActionEvent e)\r
+  {\r
+    SequenceGroup sg = getGroup();\r
+    if (sg != null)\r
+      new TextColourChooser().chooseColour(ap, sg);\r
+  }\r
 }\r