From ede54837349adde8f7265c6d8fa58d14165ee215 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 9 Feb 2017 13:43:21 +0000 Subject: [PATCH] JAL-1608 menu entry text; enable/disable Create/Remove Group option --- resources/lang/Messages.properties | 1 - resources/lang/Messages_es.properties | 1 - src/jalview/appletgui/AlignFrame.java | 12 ++++++++++++ src/jalview/gui/AlignFrame.java | 17 +++++++++++++++++ src/jalview/jbgui/GAlignFrame.java | 34 ++++++++++++++++++++++++++++++--- 5 files changed, 60 insertions(+), 5 deletions(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 1ba0c79..56565ad 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -68,7 +68,6 @@ action.show_gaps = Show Gaps action.show_hidden_markers = Show Hidden Markers action.find = Find action.undefine_groups = Undefine Groups -action.create_groups = Create Groups action.make_groups_selection = Make Groups For Selection action.copy = Copy action.cut = Cut diff --git a/resources/lang/Messages_es.properties b/resources/lang/Messages_es.properties index 7f769b3..a4180dc 100644 --- a/resources/lang/Messages_es.properties +++ b/resources/lang/Messages_es.properties @@ -66,7 +66,6 @@ action.show_gaps = Mostrar huecos action.show_hidden_markers = Mostrar marcadores ocultos action.find = Buscar action.undefine_groups = Grupos sin definir -action.create_groups = Crear grupos action.make_groups_selection = Hacer grupos para seleccionar action.copy = Copiar action.cut = Cortar diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 6a0b390..5adb71a 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -89,6 +89,7 @@ import java.awt.Label; import java.awt.Menu; import java.awt.MenuBar; import java.awt.MenuItem; +import java.awt.MenuShortcut; import java.awt.Panel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -1068,6 +1069,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { delete_actionPerformed(); } + else if (source == createGroup) + { + createGroup_actionPerformed(); + } + else if (source == unGroup) + { + unGroup_actionPerformed(); + } else if (source == grpsFromSelection) { makeGrpsFromSelection_actionPerformed(); @@ -3329,7 +3338,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, .getString("action.make_groups_selection")); grpsFromSelection.addActionListener(this); createGroup.setLabel(MessageManager.getString("action.create_group")); + createGroup.addActionListener(this); unGroup.setLabel(MessageManager.getString("action.remove_group")); + unGroup.addActionListener(this); + annotationColumnSelection.setLabel(MessageManager .getString("action.select_by_annotation")); annotationColumnSelection.addActionListener(this); diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index b5fc817..468fcd3 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -5699,6 +5699,23 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, ColourMenuHelper.setColourSelected(colourMenu, schemeName); } + + /** + * Disable inapplicable items in the Select menu when it is clicked + */ + @Override + protected void configureSelectMenu() + { + createGroup.setEnabled(false); + unGroup.setEnabled(false); + SequenceGroup sg = viewport.getSelectionGroup(); + if (sg != null) + { + List groups = viewport.getAlignment().getGroups(); + createGroup.setEnabled(groups == null || !groups.contains(sg)); + unGroup.setEnabled(groups != null && groups.contains(sg)); + } + } } class PrintThread extends Thread diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index b39f4a8..1302cdd 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -203,6 +203,10 @@ public class GAlignFrame extends JInternalFrame private SplitContainerI splitFrame; + protected JMenuItem createGroup; + + protected JMenuItem unGroup; + public GAlignFrame() { try @@ -974,8 +978,8 @@ public class GAlignFrame extends JInternalFrame } }); - JMenuItem createGroup = new JMenuItem( - MessageManager.getString("action.create_groups")); + createGroup = new JMenuItem( + MessageManager.getString("action.create_group")); keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G, Toolkit .getDefaultToolkit().getMenuShortcutKeyMask(), false); al = new ActionListener() @@ -988,7 +992,7 @@ public class GAlignFrame extends JInternalFrame }; addMenuActionAndAccelerator(keyStroke, createGroup, al); - JMenuItem unGroup = new JMenuItem( + unGroup = new JMenuItem( MessageManager.getString("action.remove_group")); keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G, Toolkit .getDefaultToolkit().getMenuShortcutKeyMask() @@ -1653,6 +1657,24 @@ public class GAlignFrame extends JInternalFrame formatMenu.setText(MessageManager.getString("action.format")); JMenu selectMenu = new JMenu(MessageManager.getString("action.select")); + selectMenu.addMenuListener(new MenuListener() + { + @Override + public void menuSelected(MenuEvent e) + { + configureSelectMenu(); + } + + @Override + public void menuDeselected(MenuEvent e) + { + } + + @Override + public void menuCanceled(MenuEvent e) + { + } + }); idRightAlign.setText(MessageManager .getString("label.right_align_sequence_id")); idRightAlign.addActionListener(new ActionListener() @@ -1904,6 +1926,12 @@ public class GAlignFrame extends JInternalFrame // selectMenu.add(listenToViewSelections); } + protected void configureSelectMenu() + { + // TODO Auto-generated method stub + + } + /** * Constructs the entries on the Colour menu (but does not add them to the * menu). -- 1.7.10.2