JAL-1608 menu entry text; enable/disable Create/Remove Group option
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 9 Feb 2017 13:43:21 +0000 (13:43 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 9 Feb 2017 13:43:21 +0000 (13:43 +0000)
resources/lang/Messages.properties
resources/lang/Messages_es.properties
src/jalview/appletgui/AlignFrame.java
src/jalview/gui/AlignFrame.java
src/jalview/jbgui/GAlignFrame.java

index 1ba0c79..56565ad 100644 (file)
@@ -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
index 7f769b3..a4180dc 100644 (file)
@@ -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
index 6a0b390..5adb71a 100644 (file)
@@ -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);
index b5fc817..468fcd3 100644 (file)
@@ -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<SequenceGroup> groups = viewport.getAlignment().getGroups();
+      createGroup.setEnabled(groups == null || !groups.contains(sg));
+      unGroup.setEnabled(groups != null && groups.contains(sg));
+    }
+  }
 }
 
 class PrintThread extends Thread
index b39f4a8..1302cdd 100755 (executable)
@@ -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).