From aa4c2cc89e5b9412f4b0211525b9aa76ea4a1920 Mon Sep 17 00:00:00 2001 From: jprocter Date: Thu, 4 Oct 2007 16:33:11 +0000 Subject: [PATCH] edit label/displayChar contains existing character(s) of sites to be edited --- src/jalview/gui/AnnotationPanel.java | 53 +++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 0fb84b0..149f432 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -182,10 +182,9 @@ public class AnnotationPanel } else if (evt.getActionCommand().equals(LABEL)) { - String label = JOptionPane.showInputDialog(this, "Enter Label ", - "Enter label", - JOptionPane.QUESTION_MESSAGE); - + String exMesg = collectAnnotVals(anot, av.getColumnSelection(), LABEL); + String label = JOptionPane.showInputDialog(this,"Enter label",exMesg); + if (label == null) { return; @@ -205,10 +204,10 @@ public class AnnotationPanel if (anot[index] == null) { - anot[index] = new Annotation(label, "", ' ', 0); + anot[index] = new Annotation(label, "", ' ', 0); // TODO: verify that null exceptions aren't raised elsewhere. + } else { + anot[index].displayCharacter = label; } - - anot[index].displayCharacter = label; } } else if (evt.getActionCommand().equals(COLOUR)) @@ -289,6 +288,46 @@ public class AnnotationPanel return; } + private String collectAnnotVals(Annotation[] anot, ColumnSelection columnSelection, + String label2) + { + String collatedInput=""; + String last=""; + for (int i = 0; i < columnSelection.size(); i++) + { + int index = columnSelection.columnAt(i); + // always check for current display state - just in case + if(!av.colSel.isVisible(index)) + continue; + String tlabel=null; + if (anot[index] != null) + { + if (label2.equals(HELIX) || label2.equals(SHEET) || label2.equals(LABEL)) + { + tlabel = anot[index].description; + if (tlabel == null) + { + if (label2.equals(HELIX) || label2.equals(SHEET)) + { + tlabel = ""+anot[index].secondaryStructure; + } else { + tlabel = ""+anot[index].displayCharacter; + } + } + } + if (tlabel!=null && !tlabel.equals(last)) + { + if (last.length()>0) + { + collatedInput+=" "; + } + collatedInput+=tlabel; + } + } + } + return collatedInput; + } + /** * DOCUMENT ME! * -- 1.7.10.2