From: tcofoegbu Date: Thu, 24 Sep 2015 14:42:20 +0000 (+0100) Subject: JAL-1860 keyboard operation of pdb sequence fetcher and pdb structure chooser X-Git-Tag: Release_2_10_0~390 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=abcfb92b105fb0bac6648c863c4141d691635e2a;p=jalview.git JAL-1860 keyboard operation of pdb sequence fetcher and pdb structure chooser --- diff --git a/src/jalview/gui/PDBSearchPanel.java b/src/jalview/gui/PDBSearchPanel.java index 4c89f12..cef9ddd 100644 --- a/src/jalview/gui/PDBSearchPanel.java +++ b/src/jalview/gui/PDBSearchPanel.java @@ -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. * diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 347c1b2..63a8654 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -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. * diff --git a/src/jalview/jbgui/GPDBSearchPanel.java b/src/jalview/jbgui/GPDBSearchPanel.java index 64095d0..7543b53 100644 --- a/src/jalview/jbgui/GPDBSearchPanel.java +++ b/src/jalview/jbgui/GPDBSearchPanel.java @@ -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 diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java index c4043c4..802cc0d 100644 --- a/src/jalview/jbgui/GStructureChooser.java +++ b/src/jalview/jbgui/GStructureChooser.java @@ -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