JAL-1860 keyboard operation of pdb sequence fetcher and pdb structure chooser
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Thu, 24 Sep 2015 14:42:20 +0000 (15:42 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Thu, 24 Sep 2015 14:42:20 +0000 (15:42 +0100)
src/jalview/gui/PDBSearchPanel.java
src/jalview/gui/StructureChooser.java
src/jalview/jbgui/GPDBSearchPanel.java
src/jalview/jbgui/GStructureChooser.java

index 4c89f12..cef9ddd 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
index 347c1b2..63a8654 100644 (file)
@@ -1,7 +1,6 @@
 /*
-
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
index 64095d0..7543b53 100644 (file)
@@ -170,6 +170,27 @@ public abstract class GPDBSearchPanel extends JPanel
         validateSelection();
       }
     });
+    tbl_summary.addKeyListener(new KeyAdapter()
+    {
+      @Override
+      public void keyPressed(KeyEvent evt)
+      {
+        validateSelection();
+        switch (evt.getKeyCode())
+        {
+        case KeyEvent.VK_ESCAPE: // escape key
+          btn_back_ActionPerformed();
+          break;
+        case KeyEvent.VK_ENTER: // enter key
+          btn_ok_ActionPerformed();
+          break;
+        case KeyEvent.VK_TAB: // tab key
+          btn_back.requestFocus();
+        default:
+          return;
+        }
+      }
+    });
 
     btn_back.setFont(new java.awt.Font("Verdana", 0, 12));
     btn_back.setText(MessageManager.getString("action.back"));
@@ -180,6 +201,17 @@ public abstract class GPDBSearchPanel extends JPanel
         btn_back_ActionPerformed();
       }
     });
+    btn_back.addKeyListener(new KeyAdapter()
+    {
+      @Override
+      public void keyPressed(KeyEvent evt)
+      {
+        if (evt.getKeyCode() == KeyEvent.VK_ENTER)
+        {
+          btn_back_ActionPerformed();
+        }
+      }
+    });
 
     btn_ok.setEnabled(false);
     btn_ok.setFont(new java.awt.Font("Verdana", 0, 12));
@@ -191,6 +223,18 @@ public abstract class GPDBSearchPanel extends JPanel
         btn_ok_ActionPerformed();
       }
     });
+    btn_ok.addKeyListener(new KeyAdapter()
+    {
+      @Override
+      public void keyPressed(KeyEvent evt)
+      {
+        if (evt.getKeyCode() == KeyEvent.VK_ENTER)
+        {
+          btn_ok_ActionPerformed();
+        }
+      }
+    });
+
     btn_cancel.setFont(new java.awt.Font("Verdana", 0, 12));
     btn_cancel.setText(MessageManager.getString("action.cancel"));
     btn_cancel.addActionListener(new java.awt.event.ActionListener()
@@ -200,6 +244,17 @@ public abstract class GPDBSearchPanel extends JPanel
         btn_cancel_ActionPerformed();
       }
     });
+    btn_cancel.addKeyListener(new KeyAdapter()
+    {
+      @Override
+      public void keyPressed(KeyEvent evt)
+      {
+        if (evt.getKeyCode() == KeyEvent.VK_ENTER)
+        {
+          btn_cancel_ActionPerformed();
+        }
+      }
+    });
 
     scrl_searchResult.setPreferredSize(new Dimension(500, 300));
     scrl_searchResult
index c4043c4..802cc0d 100644 (file)
@@ -37,6 +37,8 @@ import java.awt.FlowLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.util.Arrays;
@@ -209,21 +211,74 @@ public abstract class GStructureChooser extends JPanel implements
   {
     tbl_summary.setAutoCreateRowSorter(true);
     tbl_summary.getTableHeader().setReorderingAllowed(false);
+    tbl_summary.addMouseListener(new MouseAdapter()
+    {
+      public void mouseClicked(MouseEvent e)
+      {
+        validateSelections();
+      }
+
+      public void mouseReleased(MouseEvent e)
+      {
+        validateSelections();
+      }
+    });
+    tbl_summary.addKeyListener(new KeyAdapter()
+    {
+      @Override
+      public void keyPressed(KeyEvent evt)
+      {
+        validateSelections();
+        switch (evt.getKeyCode())
+        {
+        case KeyEvent.VK_ESCAPE: // escape key
+          mainFrame.dispose();
+          break;
+        case KeyEvent.VK_ENTER: // enter key
+          ok_ActionPerformed();
+          break;
+        case KeyEvent.VK_TAB: // tab key
+          btn_cancel.requestFocus();
+        default:
+          return;
+        }
+      }
+    });
     tbl_local_pdb.setAutoCreateRowSorter(true);
     tbl_local_pdb.getTableHeader().setReorderingAllowed(false);
     tbl_local_pdb.addMouseListener(new MouseAdapter()
     {
       public void mouseClicked(MouseEvent e)
       {
-        updateCurrentView();
+        validateSelections();
       }
 
       public void mouseReleased(MouseEvent e)
       {
-        updateCurrentView();
+        validateSelections();
+      }
+    });
+    tbl_local_pdb.addKeyListener(new KeyAdapter()
+    {
+      @Override
+      public void keyPressed(KeyEvent evt)
+      {
+        validateSelections();
+        switch (evt.getKeyCode())
+        {
+        case KeyEvent.VK_ESCAPE: // escape key
+          mainFrame.dispose();
+          break;
+        case KeyEvent.VK_ENTER: // enter key
+          ok_ActionPerformed();
+          break;
+        case KeyEvent.VK_TAB: // tab key
+          btn_cancel.requestFocus();
+        default:
+          return;
+        }
       }
     });
-
     btn_view.setFont(new java.awt.Font("Verdana", 0, 12));
     btn_view.setText(MessageManager.getString("action.view"));
     btn_view.addActionListener(new java.awt.event.ActionListener()
@@ -233,6 +288,18 @@ public abstract class GStructureChooser extends JPanel implements
         ok_ActionPerformed();
       }
     });
+    btn_view.addKeyListener(new KeyAdapter()
+    {
+      @Override
+      public void keyPressed(KeyEvent evt)
+      {
+        if (evt.getKeyCode() == KeyEvent.VK_ENTER)
+        {
+          ok_ActionPerformed();
+        }
+      }
+    });
+
     btn_cancel.setFont(new java.awt.Font("Verdana", 0, 12));
     btn_cancel.setText(MessageManager.getString("action.cancel"));
     btn_cancel.addActionListener(new java.awt.event.ActionListener()
@@ -242,6 +309,17 @@ public abstract class GStructureChooser extends JPanel implements
         mainFrame.dispose();
       }
     });
+    btn_cancel.addKeyListener(new KeyAdapter()
+    {
+      @Override
+      public void keyPressed(KeyEvent evt)
+      {
+        if (evt.getKeyCode() == KeyEvent.VK_ENTER)
+        {
+          mainFrame.dispose();
+        }
+      }
+    });
 
     btn_pdbFromFile.setFont(new java.awt.Font("Verdana", 0, 12));
     String btn_title = MessageManager.getString("label.select_pdb_file");
@@ -253,6 +331,17 @@ public abstract class GStructureChooser extends JPanel implements
         pdbFromFile_actionPerformed();
       }
     });
+    btn_pdbFromFile.addKeyListener(new KeyAdapter()
+    {
+      @Override
+      public void keyPressed(KeyEvent evt)
+      {
+        if (evt.getKeyCode() == KeyEvent.VK_ENTER)
+        {
+          pdbFromFile_actionPerformed();
+        }
+      }
+    });
 
     scrl_foundStructures.setPreferredSize(new Dimension(500, 300));
     scrl_foundStructures