From: jprocter Date: Fri, 4 Jun 2010 15:40:32 +0000 (+0000) Subject: patches for JAL-554 and JAL-570 X-Git-Tag: Release_2_5_1~30 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=32f58e16773440070c4b7978df9d3727581c2c84;p=jalview.git patches for JAL-554 and JAL-570 focus is explicitly handed back to caller (JAL-566) --- diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index bd46613..bf2f152 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -73,6 +73,8 @@ public class AnnotationLabels extends JPanel implements MouseListener, Font font = new Font("Arial", Font.PLAIN, 11); + private boolean hasHiddenRows; + /** * Creates a new AnnotationLabels object. * @@ -130,15 +132,23 @@ public class AnnotationLabels extends JPanel implements MouseListener, repaint(); } + /** + * sets selectedRow to -2 if no annotation preset, -1 if no visible row is at + * y + * + * @param y + * coordinate position to search for a row + */ void getSelectedRow(int y) { int height = 0; AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); - + selectedRow = -2; if (aa != null) { for (int i = 0; i < aa.length; i++) { + selectedRow = -1; if (!aa[i].visible) { continue; @@ -153,8 +163,6 @@ public class AnnotationLabels extends JPanel implements MouseListener, break; } } - } else { - selectedRow = -1; } } @@ -252,7 +260,8 @@ public class AnnotationLabels extends JPanel implements MouseListener, { EditNameDialog dialog = new EditNameDialog(annotation.label, annotation.description, " Annotation Name ", - "Annotation Description ", "Edit Annotation Name/Description"); + "Annotation Description ", "Edit Annotation Name/Description", + ap.alignFrame); if (!dialog.accept) { @@ -300,6 +309,10 @@ public class AnnotationLabels extends JPanel implements MouseListener, // Swap these annotations AlignmentAnnotation startAA = ap.av.alignment .getAlignmentAnnotation()[start]; + if (end == -1) + { + end = ap.av.alignment.getAlignmentAnnotation().length - 1; + } AlignmentAnnotation endAA = ap.av.alignment.getAlignmentAnnotation()[end]; ap.av.alignment.getAlignmentAnnotation()[end] = startAA; @@ -431,7 +444,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); if (SwingUtilities.isLeftMouseButton(evt)) { - if (aa!=null && selectedRow < aa.length) + if (selectedRow > -1 && selectedRow < aa.length) { if (aa[selectedRow].groupRef != null) { @@ -480,17 +493,18 @@ public class AnnotationLabels extends JPanel implements MouseListener, JPopupMenu pop = new JPopupMenu("Annotations"); JMenuItem item = new JMenuItem(ADDNEW); item.addActionListener(this); - - if ((aa == null) || (aa.length == 0)) + pop.add(item); + if (selectedRow < 0) { - item = new JMenuItem(SHOWALL); - item.addActionListener(this); - pop.add(item); + if (hasHiddenRows) + { // let the user make everything visible again + item = new JMenuItem(SHOWALL); + item.addActionListener(this); + pop.add(item); + } pop.show(this, evt.getX(), evt.getY()); return; } - - pop.add(item); item = new JMenuItem(EDITNAME); item.addActionListener(this); pop.add(item); @@ -500,9 +514,12 @@ public class AnnotationLabels extends JPanel implements MouseListener, item = new JMenuItem(DELETE); item.addActionListener(this); pop.add(item); - item = new JMenuItem(SHOWALL); - item.addActionListener(this); - pop.add(item); + if (hasHiddenRows) + { + item = new JMenuItem(SHOWALL); + item.addActionListener(this); + pop.add(item); + } item = new JMenuItem(OUTPUT_TEXT); item.addActionListener(this); pop.add(item); @@ -752,12 +769,14 @@ public class AnnotationLabels extends JPanel implements MouseListener, if (aa != null) { + hasHiddenRows = false; for (int i = 0; i < aa.length; i++) { g.setColor(Color.black); if (!aa[i].visible) { + hasHiddenRows = true; continue; }