From 28bfc1385cb1addc479bc04eb5a5b992e0c8f1bd Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 31 Aug 2012 11:52:27 +0100 Subject: [PATCH] JAL-1015 new menu items in desktop popup menu for creating annotation report for sequence and sequence selection. --- src/jalview/gui/PopupMenu.java | 56 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index c1bbc8d..4a3fb20 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -84,6 +84,9 @@ public class PopupMenu extends JPopupMenu JMenu sequenceMenu = new JMenu(); JMenuItem sequenceName = new JMenuItem(); + + JMenuItem sequenceDetails = new JMenuItem(); + JMenuItem sequenceSelDetails = new JMenuItem(); SequenceI sequence; @@ -895,6 +898,20 @@ public class PopupMenu extends JPopupMenu sequenceName_actionPerformed(); } }); + sequenceDetails.setText("Sequence Details ..."); + sequenceDetails.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + sequenceDetails_actionPerformed(); + }}); + sequenceSelDetails.setText("Sequence Details ..."); + sequenceSelDetails.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + sequenceSelectionDetails_actionPerformed(); + }}); PIDColour.setFocusPainted(false); unGroupMenuItem.setText("Remove Group"); unGroupMenuItem.addActionListener(new java.awt.event.ActionListener() @@ -1052,15 +1069,15 @@ public class PopupMenu extends JPopupMenu editSequence_actionPerformed(actionEvent); } }); + /* * annotationMenuItem.setText("By Annotation"); * annotationMenuItem.addActionListener(new ActionListener() { public void * actionPerformed(ActionEvent actionEvent) { * annotationMenuItem_actionPerformed(actionEvent); } }); */ - + groupMenu.add(sequenceSelDetails); add(groupMenu); - add(sequenceMenu); this.add(structureMenu); groupMenu.add(editMenu); @@ -1068,6 +1085,7 @@ public class PopupMenu extends JPopupMenu groupMenu.add(sequenceFeature); groupMenu.add(jMenu1); sequenceMenu.add(sequenceName); + sequenceMenu.add(sequenceDetails); colourMenu.add(textColour); colourMenu.add(noColourmenuItem); colourMenu.add(clustalColour); @@ -1262,6 +1280,40 @@ public class PopupMenu extends JPopupMenu }); } + protected void sequenceSelectionDetails_actionPerformed() + { + createSequenceDetailsReport(ap.av.getSequenceSelection()); + } + + protected void sequenceDetails_actionPerformed() + { + createSequenceDetailsReport(new SequenceI[]{sequence}); + } + public void createSequenceDetailsReport(SequenceI[] sequences) + { + CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer(); + StringBuffer contents = new StringBuffer(); + for (SequenceI seq:sequences) + { + contents.append("

Annotation for "+seq.getDisplayId(true)+"

"); + new SequenceAnnotationReport(null) + .createSequenceAnnotationReport( + contents, + seq, + true, + true,false, + (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax + : null); + contents.append("

"); + } + cap.setText("" + contents.toString() + ""); + + Desktop.instance.addInternalFrame(cap, + "Sequence Details for " + (sequences.length==1 ? sequences[0].getDisplayId(true) : "Selection") +, 500, 400); + + } + protected void showNonconserved_actionPerformed() { getGroup().setShowNonconserved(displayNonconserved.isSelected()); -- 1.7.10.2