From: amwaterhouse Date: Wed, 31 Jan 2007 16:38:44 +0000 (+0000) Subject: edit annotation name/description X-Git-Tag: Release_2_3~401 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=db4c3105e27a3295551e827f3ae41531fad15889;p=jalview.git edit annotation name/description --- diff --git a/src/jalview/appletgui/AnnotationLabels.java b/src/jalview/appletgui/AnnotationLabels.java index 5ee1efe..0935500 100755 --- a/src/jalview/appletgui/AnnotationLabels.java +++ b/src/jalview/appletgui/AnnotationLabels.java @@ -34,7 +34,7 @@ public class AnnotationLabels AlignViewport av; boolean resizing = false; int oldY, mouseX; - static String ADDNEW = "Add new row"; + static String EDITNAME = "Edit label/description"; static String HIDE = "Hide this row"; static String DELETE = "Delete this row"; static String SHOWALL = "Show all hidden rows"; @@ -46,6 +46,11 @@ public class AnnotationLabels Tooltip tooltip; + Dialog editNameDialog; + Button okDialog = new Button("Accept"); + Button cancelDialog = new Button("Cancel"); + + public AnnotationLabels(AlignmentPanel ap) { this.ap = ap; @@ -53,6 +58,8 @@ public class AnnotationLabels setLayout(null); addMouseListener(this); addMouseMotionListener(this); + okDialog.addActionListener(this); + cancelDialog.addActionListener(this); } public AnnotationLabels(AlignViewport av) @@ -96,10 +103,59 @@ public class AnnotationLabels { AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + if(evt.getActionCommand().equals(EDITNAME)) + { + TextField id = new TextField(aa[selectedRow].label, 40); + TextField description = new TextField(aa[selectedRow].description, 40); + Panel panel = new Panel(new BorderLayout()); + Panel panel2 = new Panel(new BorderLayout()); + panel2.add(new Label(" Annotation Label "), BorderLayout.WEST); + panel2.add(id, BorderLayout.CENTER); + panel.add(panel2, BorderLayout.NORTH); + panel2 = new Panel(new BorderLayout()); + panel2.add(new Label("Annotation Description "), BorderLayout.WEST); + panel2.add(description, BorderLayout.CENTER); + panel.add(panel2, BorderLayout.CENTER); + + panel2 = new Panel(new FlowLayout()); + + panel2.add(okDialog); + panel2.add(cancelDialog); + + panel.add(panel2, BorderLayout.SOUTH); + + editNameDialog = new Dialog(ap.alignFrame, + "Edit Annotation Name / Description", + true); + + editNameDialog.add(panel, BorderLayout.NORTH); + + editNameDialog.setBounds(ap.alignFrame.getBounds().x + +(ap.alignFrame.getSize().width-500)/2 , + ap.alignFrame.getBounds().y + +(ap.alignFrame.getSize().height-120)/2, + 500, 130); + + editNameDialog.show(); + + if (editNameDialog != null) + { + aa[selectedRow].label=id.getText(); + aa[selectedRow].description=description.getText(); + repaint(); + } + + } if (evt.getActionCommand().equals(HIDE)) { aa[selectedRow].visible = false; } + else if (evt.getSource() == okDialog || evt.getSource() == cancelDialog) + { + editNameDialog.setVisible(false); + if (evt.getSource() == cancelDialog) + editNameDialog = null; + } else if (evt.getActionCommand().equals(SHOWALL)) { for (int i = 0; i < aa.length; i++) @@ -170,7 +226,11 @@ public class AnnotationLabels AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); PopupMenu pop = new PopupMenu("Annotations"); - MenuItem item = new MenuItem(HIDE); + + MenuItem item = new MenuItem(EDITNAME); + item.addActionListener(this); + pop.add(item); + item = new MenuItem(HIDE); item.addActionListener(this); pop.add(item); item = new MenuItem(SHOWALL);