Edit seqs
authoramwaterhouse <Andrew Waterhouse>
Thu, 26 Apr 2007 11:51:26 +0000 (11:51 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 26 Apr 2007 11:51:26 +0000 (11:51 +0000)
src/jalview/gui/EditNameDialog.java
src/jalview/gui/PopupMenu.java

index b6cc5a5..a3d2d47 100644 (file)
@@ -63,10 +63,13 @@ public class EditNameDialog
     panel2.add(idlabel, BorderLayout.WEST);\r
     panel2.add(id, BorderLayout.CENTER);\r
     panel.add(panel2, BorderLayout.NORTH);\r
-    panel2 = new JPanel(new BorderLayout());\r
-    panel2.add(desclabel, BorderLayout.WEST);\r
-    panel2.add(description, BorderLayout.CENTER);\r
-    panel.add(panel2, BorderLayout.SOUTH);\r
+    if(desc!=null || label2!=null)\r
+    {\r
+      panel2 = new JPanel(new BorderLayout());\r
+      panel2.add(desclabel, BorderLayout.WEST);\r
+      panel2.add(description, BorderLayout.CENTER);\r
+      panel.add(panel2, BorderLayout.SOUTH);\r
+    }\r
 \r
     int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,\r
         panel, title,\r
index ef87c2f..1df8041 100755 (executable)
@@ -85,6 +85,7 @@ public class PopupMenu
   JMenu structureMenu = new JMenu();\r
   JMenu viewStructureMenu = new JMenu();\r
   JMenu colStructureMenu = new JMenu();\r
+  JMenuItem editSequence = new JMenuItem();\r
 \r
   /**\r
    * Creates a new PopupMenu object.\r
@@ -566,6 +567,14 @@ public class PopupMenu
     structureMenu.setText("Structure");\r
     viewStructureMenu.setText("View Structure");\r
     colStructureMenu.setText("Colour By Structure");\r
+    editSequence.setText("Edit Sequence...");\r
+    editSequence.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent actionEvent)\r
+      {\r
+        editSequence_actionPerformed(actionEvent);\r
+      }\r
+    });\r
 \r
     add(groupMenu);\r
 \r
@@ -616,6 +625,7 @@ public class PopupMenu
     colourMenu.add(conservationMenuItem);\r
     editMenu.add(copy);\r
     editMenu.add(cut);\r
+    editMenu.add(editSequence);\r
     editMenu.add(upperCase);\r
     editMenu.add(lowerCase);\r
     editMenu.add(toggle);\r
@@ -1403,4 +1413,39 @@ public class PopupMenu
     sequence.addAlignmentAnnotation(an);\r
 \r
     }\r
+\r
+  public void editSequence_actionPerformed(ActionEvent actionEvent)\r
+  {\r
+      SequenceGroup sg = ap.av.getSelectionGroup();\r
+\r
+      if(sg!=null)\r
+      {\r
+        if (sequence == null)\r
+          sequence = (Sequence) sg.getSequenceAt(0);\r
+\r
+        EditNameDialog dialog = new EditNameDialog(\r
+            sequence.getSequenceAsString(\r
+                sg.getStartRes(),\r
+                sg.getEndRes() + 1),\r
+            null,\r
+            "Edit Sequence ",\r
+            null,\r
+            "Edit Sequence");\r
+\r
+        if (dialog.accept)\r
+        {\r
+          EditCommand editCommand = new EditCommand(\r
+              "Edit Sequences", EditCommand.REPLACE,\r
+              dialog.getName(),\r
+              sg.getSequencesAsArray(ap.av.hiddenRepSequences),\r
+              sg.getStartRes(), sg.getEndRes() + 1, ap.av.alignment\r
+              );\r
+\r
+          ap.alignFrame.addHistoryItem(editCommand);\r
+\r
+          ap.av.firePropertyChange("alignment", null,\r
+                                   ap.av.getAlignment().getSequences());\r
+        }\r
+      }\r
+  }\r
 }\r