JAL-3130 incorporating feature/JAL-3063jaxbNoCastor and new script utils/jdeps_jlink_...
[jalview.git] / src / jalview / jbgui / GFinder.java
index 00b4fdc..1ea4ab5 100755 (executable)
@@ -33,6 +33,7 @@ import java.awt.Font;
 import java.awt.GridLayout;
 import java.awt.Insets;
 import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
 
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
@@ -58,7 +59,8 @@ public class GFinder extends JPanel
 
   protected JButton createFeatures = new JButton();
 
-  protected JvCacheableInputBox<String> searchBox = new JvCacheableInputBox<String>(getCacheKey());
+  protected JvCacheableInputBox<String> searchBox = new JvCacheableInputBox<String>(
+          getCacheKey());
 
   BorderLayout mainBorderLayout = new BorderLayout();
 
@@ -135,14 +137,22 @@ public class GFinder extends JPanel
     searchBox.setFont(new java.awt.Font("Verdana", Font.PLAIN, 12));
     ((JTextComponent) searchBox.getEditor().getEditorComponent())
             .addCaretListener(new CaretListener()
-    {
-      @Override
-      public void caretUpdate(CaretEvent e)
-      {
-        textfield_caretUpdate(e);
-      }
-    });
-
+            {
+              @Override
+              public void caretUpdate(CaretEvent e)
+              {
+                textfield_caretUpdate(e);
+              }
+            });
+    searchBox.getEditor().getEditorComponent()
+            .addKeyListener(new java.awt.event.KeyAdapter()
+            {
+              @Override
+              public void keyPressed(KeyEvent e)
+              {
+                textfield_keyPressed(e);
+              }
+            });
     mainBorderLayout.setHgap(5);
     mainBorderLayout.setVgap(5);
     jPanel4.setLayout(borderLayout2);
@@ -151,8 +161,8 @@ public class GFinder extends JPanel
     caseSensitive.setHorizontalAlignment(SwingConstants.LEFT);
     caseSensitive.setText(MessageManager.getString("label.match_case"));
 
-    searchDescription.setText(MessageManager
-            .getString("label.include_description"));
+    searchDescription
+            .setText(MessageManager.getString("label.include_description"));
 
     actionsPanel.add(findNext, null);
     actionsPanel.add(findAll, null);
@@ -176,6 +186,18 @@ public class GFinder extends JPanel
     jPanel4.add(optionsPanel, java.awt.BorderLayout.WEST);
   }
 
+  protected void textfield_keyPressed(KeyEvent e)
+  {
+    if (e.getKeyCode() == KeyEvent.VK_ENTER)
+    {
+      if (!searchBox.isPopupVisible())
+      {
+        e.consume();
+        findNext_actionPerformed(null);
+      }
+    }
+  }
+
   protected void findNext_actionPerformed(ActionEvent e)
   {
   }
@@ -184,7 +206,6 @@ public class GFinder extends JPanel
   {
   }
 
-
   public void createFeatures_actionPerformed()
   {
   }
@@ -210,8 +231,8 @@ public class GFinder extends JPanel
           if (al != null && al.getHeight() > 0)
           {
             str = jalview.analysis.AlignSeq.extractGaps(
-                    jalview.util.Comparison.GapChars, al.getSequenceAt(0)
-                            .getSequenceAsString());
+                    jalview.util.Comparison.GapChars,
+                    al.getSequenceAt(0).getSequenceAsString());
 
           }
         }
@@ -219,10 +240,6 @@ public class GFinder extends JPanel
     }
   }
 
-
-
-
-
   /**
    * Returns unique key used for storing Finder cache items in the cache data
    * structure
@@ -234,6 +251,4 @@ public class GFinder extends JPanel
     return FINDER_CACHE_KEY;
   }
 
-
-
 }