MouseMotionListener, ActionListener
{
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";
if (evt.getActionCommand().equals(ADDNEW))
{
- String label = JOptionPane.showInputDialog(this,
- "Label for annotation");
-
- if (label == null)
- {
- label = "";
- }
-
- AlignmentAnnotation newAnnotation = new AlignmentAnnotation(label,
- "New description",
+ AlignmentAnnotation newAnnotation = new AlignmentAnnotation(null,
+ null,
new Annotation[ap.av.alignment.getWidth()]);
+ if(!editLabelDescription(newAnnotation))
+ return;
+
ap.av.alignment.addAnnotation(newAnnotation);
ap.av.alignment.setAnnotationIndex(newAnnotation, 0);
if (aa != null)
dif = aa[aa.length - 1].height;
}
+ else if(evt.getActionCommand().equals(EDITNAME))
+ {
+ editLabelDescription(aa[selectedRow]);
+ repaint();
+ }
else if (evt.getActionCommand().equals(HIDE))
{
aa[selectedRow].visible = false;
new AnnotationExporter().exportAnnotations(
ap,
new AlignmentAnnotation[]
- {aa[selectedRow]}
+ {aa[selectedRow]},
+ null
);
}
else if (evt.getActionCommand().equals(COPYCONS_SEQ))
ap.repaint();
}
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param e DOCUMENT ME!
+ */
+ boolean editLabelDescription(AlignmentAnnotation annotation)
+ {
+ EditNameDialog dialog = new EditNameDialog(annotation.label,
+ annotation.description,
+ " Annotation Name ",
+ "Annotation Description ",
+ "Edit Annotation Name/Description");
+
+ if (!dialog.accept)
+ {
+ return false;
+ }
+
+ annotation.label = dialog.getName();
+
+ String text = dialog.getDescription();
+ if(text.length()==0)
+ text = null;
+ annotation.description = text;
+
+ return true;
+ }
+
/**
* DOCUMENT ME!
*
getSelectedRow(evt.getY() - scrollOffset);
- if(selectedRow>-1)
+ if(selectedRow>-1
+ && ap.av.alignment.getAlignmentAnnotation().length>selectedRow)
{
- setToolTipText(ap.av.alignment.
- getAlignmentAnnotation()[selectedRow].description);
+ String desc = ap.av.alignment.
+ getAlignmentAnnotation()[selectedRow].description;
+
+ if (desc != null && !desc.equals("New description"))
+ setToolTipText(ap.av.alignment.
+ getAlignmentAnnotation()[selectedRow].description);
}
repaint();
JMenuItem item = new JMenuItem(ADDNEW);
item.addActionListener(this);
pop.add(item);
+ item = new JMenuItem(EDITNAME);
+ item.addActionListener(this);
+ pop.add(item);
item = new JMenuItem(HIDE);
item.addActionListener(this);
pop.add(item);
item.addActionListener(this);
pop.add(item);
// annotation object should be typed
- if (aa[selectedRow].label.equals("Consensus"))
+ if (aa[selectedRow]==ap.av.consensus)
{
pop.addSeparator();
final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(