From: amwaterhouse Date: Thu, 26 Apr 2007 11:51:26 +0000 (+0000) Subject: Edit seqs X-Git-Tag: Release_2_3~164 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=be707dc4d1ea70abc29cbe3fd4489be7bb692117;p=jalview.git Edit seqs --- diff --git a/src/jalview/gui/EditNameDialog.java b/src/jalview/gui/EditNameDialog.java index b6cc5a5..a3d2d47 100644 --- a/src/jalview/gui/EditNameDialog.java +++ b/src/jalview/gui/EditNameDialog.java @@ -63,10 +63,13 @@ public class EditNameDialog panel2.add(idlabel, BorderLayout.WEST); panel2.add(id, BorderLayout.CENTER); panel.add(panel2, BorderLayout.NORTH); - panel2 = new JPanel(new BorderLayout()); - panel2.add(desclabel, BorderLayout.WEST); - panel2.add(description, BorderLayout.CENTER); - panel.add(panel2, BorderLayout.SOUTH); + if(desc!=null || label2!=null) + { + panel2 = new JPanel(new BorderLayout()); + panel2.add(desclabel, BorderLayout.WEST); + panel2.add(description, BorderLayout.CENTER); + panel.add(panel2, BorderLayout.SOUTH); + } int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop, panel, title, diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index ef87c2f..1df8041 100755 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -85,6 +85,7 @@ public class PopupMenu JMenu structureMenu = new JMenu(); JMenu viewStructureMenu = new JMenu(); JMenu colStructureMenu = new JMenu(); + JMenuItem editSequence = new JMenuItem(); /** * Creates a new PopupMenu object. @@ -566,6 +567,14 @@ public class PopupMenu structureMenu.setText("Structure"); viewStructureMenu.setText("View Structure"); colStructureMenu.setText("Colour By Structure"); + editSequence.setText("Edit Sequence..."); + editSequence.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent actionEvent) + { + editSequence_actionPerformed(actionEvent); + } + }); add(groupMenu); @@ -616,6 +625,7 @@ public class PopupMenu colourMenu.add(conservationMenuItem); editMenu.add(copy); editMenu.add(cut); + editMenu.add(editSequence); editMenu.add(upperCase); editMenu.add(lowerCase); editMenu.add(toggle); @@ -1403,4 +1413,39 @@ public class PopupMenu sequence.addAlignmentAnnotation(an); } + + public void editSequence_actionPerformed(ActionEvent actionEvent) + { + SequenceGroup sg = ap.av.getSelectionGroup(); + + if(sg!=null) + { + if (sequence == null) + sequence = (Sequence) sg.getSequenceAt(0); + + EditNameDialog dialog = new EditNameDialog( + sequence.getSequenceAsString( + sg.getStartRes(), + sg.getEndRes() + 1), + null, + "Edit Sequence ", + null, + "Edit Sequence"); + + if (dialog.accept) + { + EditCommand editCommand = new EditCommand( + "Edit Sequences", EditCommand.REPLACE, + dialog.getName(), + sg.getSequencesAsArray(ap.av.hiddenRepSequences), + sg.getStartRes(), sg.getEndRes() + 1, ap.av.alignment + ); + + ap.alignFrame.addHistoryItem(editCommand); + + ap.av.firePropertyChange("alignment", null, + ap.av.getAlignment().getSequences()); + } + } + } }