From 9b6c54888a7c0948667944035b1c7f1cf9c35bcd Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 8 Oct 2013 14:51:01 +0100 Subject: [PATCH] JAL-1384 Create Group in selection popup menu JAL-1388 move Remove Group option to selection menu JAL-1388 Group editing menu is now context dependent (either 'Edit Group' or 'Edit New Group') --- src/jalview/appletgui/APopupMenu.java | 28 ++++++++++++++++++++++++---- src/jalview/gui/PopupMenu.java | 29 +++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index 70804f6..8302282 100755 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -69,6 +69,8 @@ public class APopupMenu extends java.awt.PopupMenu implements MenuItem unGroupMenuItem = new MenuItem(); + MenuItem createGroupMenuItem = new MenuItem(); + MenuItem nucleotideMenuItem = new MenuItem(); Menu colourMenu = new Menu(); @@ -166,7 +168,11 @@ public class APopupMenu extends java.awt.PopupMenu implements displayNonconserved.setState(sg.getShowNonconserved()); if (!ap.av.getAlignment().getGroups().contains(sg)) { - menu1.remove(unGroupMenuItem); + menu1.setLabel("Edit New Group"); + groupMenu.remove(unGroupMenuItem); + } else { + menu1.setLabel("Edit Group"); + groupMenu.remove(createGroupMenuItem); } } @@ -457,6 +463,11 @@ public class APopupMenu extends java.awt.PopupMenu implements unGroupMenuItem_actionPerformed(); } + else if (source == createGroupMenuItem) + { + createGroupMenuItem_actionPerformed(); + } + else if (source == sequenceName) { editName(); @@ -730,7 +741,6 @@ public class APopupMenu extends java.awt.PopupMenu implements private void jbInit() throws Exception { - groupMenu.setLabel("Group"); groupMenu.setLabel("Selection"); sequenceFeature.addActionListener(this); @@ -738,6 +748,9 @@ public class APopupMenu extends java.awt.PopupMenu implements unGroupMenuItem.setLabel("Remove Group"); unGroupMenuItem.addActionListener(this); + createGroupMenuItem.setLabel("Create Group"); + createGroupMenuItem.addActionListener(this); + nucleotideMenuItem.setLabel("Nucleotide"); nucleotideMenuItem.addActionListener(this); conservationMenuItem.addItemListener(this); @@ -770,10 +783,11 @@ public class APopupMenu extends java.awt.PopupMenu implements this.add(revealSeq); this.add(revealAll); // groupMenu.add(selSeqDetails); - groupMenu.add(editGroupName); groupMenu.add(editMenu); groupMenu.add(outputmenu); groupMenu.add(sequenceFeature); + groupMenu.add(createGroupMenuItem); + groupMenu.add(unGroupMenuItem); groupMenu.add(menu1); colourMenu.add(noColourmenuItem); @@ -843,7 +857,7 @@ public class APopupMenu extends java.awt.PopupMenu implements seqMenu.add(pdb); } seqMenu.add(repGroup); - menu1.add(unGroupMenuItem); + menu1.add(editGroupName); menu1.add(colourMenu); menu1.add(showBoxes); menu1.add(showText); @@ -1027,6 +1041,12 @@ public class APopupMenu extends java.awt.PopupMenu implements ap.paintAlignment(true); } + void createGroupMenuItem_actionPerformed() + { + getGroup(); // implicitly create group + refresh(); + } + public void showColourText_itemStateChanged() { getGroup().setColourText(showColourText.getState()); diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 1a367c5..29370ac 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -89,7 +89,7 @@ public class PopupMenu extends JPopupMenu JMenuItem sequenceSelDetails = new JMenuItem(); SequenceI sequence; - + JMenuItem createGroupMenuItem = new JMenuItem(); JMenuItem unGroupMenuItem = new JMenuItem(); JMenuItem outline = new JMenuItem(); @@ -392,9 +392,10 @@ public class PopupMenu extends JPopupMenu } SequenceGroup sg = ap.av.getSelectionGroup(); + boolean isDefinedGroup = (sg!=null) ? ap.av.getAlignment().getGroups().contains(sg) : false; if (sg != null && sg.getSize() > 0) - { + { groupName.setText("Name: " + sg.getName()); groupName.setText("Edit name and description of current group."); @@ -520,9 +521,15 @@ public class PopupMenu extends JPopupMenu editMenu.setVisible(false); } - if (!ap.av.getAlignment().getGroups().contains(sg)) + if (!isDefinedGroup) { + createGroupMenuItem.setVisible(true); unGroupMenuItem.setVisible(false); + jMenu1.setText("Edit New Group"); + } else { + createGroupMenuItem.setVisible(false); + unGroupMenuItem.setVisible(true); + jMenu1.setText("Edit Group"); } if (seq == null) @@ -935,6 +942,14 @@ public class PopupMenu extends JPopupMenu unGroupMenuItem_actionPerformed(); } }); + createGroupMenuItem.setText("Create Group"); + createGroupMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + createGroupMenuItem_actionPerformed(); + } + }); outline.setText("Border colour"); outline.addActionListener(new java.awt.event.ActionListener() @@ -1097,6 +1112,8 @@ public class PopupMenu extends JPopupMenu groupMenu.add(editMenu); groupMenu.add(outputMenu); groupMenu.add(sequenceFeature); + groupMenu.add(createGroupMenuItem); + groupMenu.add(unGroupMenuItem); groupMenu.add(jMenu1); sequenceMenu.add(sequenceName); sequenceMenu.add(sequenceDetails); @@ -1153,7 +1170,6 @@ public class PopupMenu extends JPopupMenu pdbMenu.add(enterPDB); pdbMenu.add(discoverPDB); jMenu1.add(groupName); - jMenu1.add(unGroupMenuItem); jMenu1.add(colourMenu); jMenu1.add(showBoxes); jMenu1.add(showText); @@ -1726,6 +1742,11 @@ public class PopupMenu extends JPopupMenu ap.av.setSelectionGroup(null); refresh(); } + void createGroupMenuItem_actionPerformed() + { + getGroup(); // implicitly creates group - note - should apply defaults / use standard alignment window logic for this + refresh(); + } /** * DOCUMENT ME! -- 1.7.10.2