JAL-2071 improvement to reduce webservice requests to Free Text Search (FTS) services...
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 26 Apr 2016 09:21:56 +0000 (10:21 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 26 Apr 2016 09:21:56 +0000 (10:21 +0100)
lib/groovy-all-1.8.2.jar [new file with mode: 0755]
lib/groovy-all-2.4.6.jar [deleted file]
src/jalview/fts/core/GFTSPanel.java
utils/InstallAnywhere/Jalview.iap_xml

diff --git a/lib/groovy-all-1.8.2.jar b/lib/groovy-all-1.8.2.jar
new file mode 100755 (executable)
index 0000000..85af249
Binary files /dev/null and b/lib/groovy-all-1.8.2.jar differ
diff --git a/lib/groovy-all-2.4.6.jar b/lib/groovy-all-2.4.6.jar
deleted file mode 100644 (file)
index 4301384..0000000
Binary files a/lib/groovy-all-2.4.6.jar and /dev/null differ
index 67983a1..cae271d 100644 (file)
@@ -35,6 +35,8 @@ import java.awt.CardLayout;
 import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
 import java.awt.event.KeyAdapter;
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseAdapter;
@@ -57,6 +59,7 @@ import javax.swing.JScrollPane;
 import javax.swing.JTabbedPane;
 import javax.swing.JTable;
 import javax.swing.JTextField;
+import javax.swing.Timer;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 import javax.swing.event.DocumentEvent;
@@ -354,24 +357,29 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
       }
     });
 
-    txt_search.getDocument().addDocumentListener(new DocumentListener()
+    final DeferredTextInputListener listener = new DeferredTextInputListener(
+            500,
+            new ActionListener()
+            {
+              @Override
+              public void actionPerformed(ActionEvent e)
+              {
+                searchAction();
+              }
+            }, false);
+    txt_search.getDocument().addDocumentListener(listener);
+    txt_search.addFocusListener(new FocusListener()
     {
       @Override
-      public void insertUpdate(DocumentEvent e)
+      public void focusGained(FocusEvent e)
       {
-        searchAction();
-      }
-
-      @Override
-      public void removeUpdate(DocumentEvent e)
-      {
-        searchAction();
+        listener.start();
       }
 
       @Override
-      public void changedUpdate(DocumentEvent e)
+      public void focusLost(FocusEvent e)
       {
-        searchAction();
+        listener.stop();
       }
     });
 
@@ -444,6 +452,47 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
     Desktop.addInternalFrame(mainFrame, getFTSFrameTitle(), 800, 400);
   }
 
+  public class DeferredTextInputListener implements DocumentListener
+  {
+    private final Timer swingTimer;
+
+    public DeferredTextInputListener(int timeOut, ActionListener listener,
+            boolean repeats)
+    {
+      swingTimer = new Timer(timeOut, listener);
+      swingTimer.setRepeats(repeats);
+    }
+
+    public void start()
+    {
+      swingTimer.start();
+    }
+
+    public void stop()
+    {
+      swingTimer.stop();
+    }
+
+    @Override
+    public void insertUpdate(DocumentEvent e)
+    {
+      swingTimer.restart();
+    }
+
+    @Override
+    public void removeUpdate(DocumentEvent e)
+    {
+      swingTimer.restart();
+    }
+
+    @Override
+    public void changedUpdate(DocumentEvent e)
+    {
+      swingTimer.restart();
+    }
+
+  }
+
   public boolean wantedFieldsUpdated()
   {
     if (previousWantedFields == null)
index 428b998..83d1a98 100755 (executable)
@@ -2025,7 +2025,7 @@ and any path to a file to save to the file]]></string>
                                                                <string><![CDATA[664]]></string>
                                                        </property>
                                                        <property name="sourceName">
-                                                               <string><![CDATA[groovy-all-2.4.6-indy.jar]]></string>
+                                                               <string><![CDATA[groovy-all-1.8.2.jar]]></string>
                                                        </property>
                                                        <property name="overrideUnixPermissions">
                                                                <boolean>false</boolean>
@@ -2043,7 +2043,7 @@ and any path to a file to save to the file]]></string>
                                                                <boolean>true</boolean>
                                                        </property>
                                                        <property name="destinationName">
-                                                               <string><![CDATA[groovy-all-2.4.6-indy.jar]]></string>
+                                                               <string><![CDATA[groovy-all-1.8.2.jar]]></string>
                                                        </property>
                                                        <property name="fileSize">
                                                                <long>6149494</long>