[hg] main-silver: #206298 - AddModulePanel insertUpdate handler ...

  • From: Ondrej Vrabec < >
  • To:
  • Subject: [hg] main-silver: #206298 - AddModulePanel insertUpdate handler ...
  • Date: Tue, 20 Nov 2012 20:38:11 -0800

changeset 4b883b81933e in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/4b883b81933e
description:
        #206298 - AddModulePanel insertUpdate handler calls slow 
AddModuleFilter.getMatches synch
        searching in background and displaying "Please wait..." after 1 second

diffstat:

 
apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModulePanel.java
 |  22 +++++++--
 1 files changed, 16 insertions(+), 6 deletions(-)

diffs (62 lines):

diff --git 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModulePanel.java
 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModulePanel.java
--- 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModulePanel.java
+++ 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModulePanel.java
@@ -61,6 +61,7 @@
 import javax.swing.JComponent;
 import javax.swing.JPanel;
 import javax.swing.KeyStroke;
+import javax.swing.Timer;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
@@ -99,6 +100,7 @@
     private URL currectJavadoc;
     
     private final SingleModuleProperties props;
+    private Timer timer;
     
     public static ModuleDependency[] selectDependencies(final 
SingleModuleProperties props) {
         final AddModulePanel addPanel = new AddModulePanel(props);
@@ -331,6 +333,7 @@
                     }
                     Mutex.EVENT.readAccess(new Runnable() {
                         public @Override void run() {
+                            timer.stop();
                             // XXX would be better to have more fine-grained 
control over the thread
                             if (!text.equals(filterValue.getText())) {
                                 return; // no longer valid, don't apply
@@ -343,9 +346,7 @@
                     });
                 }
             };
-            if (filterer == null) {
-                // Slow to create it, so show Please wait...
-                moduleList.setModel(UIUtil.createListWaitModel());
+            restartTimer();
                 synchronized (this) {
                     filterTask = RP.post(new Runnable() {
                         public @Override void run() {
@@ -356,11 +357,20 @@
                         }
                     });
                 }
-            } else {
-                // Pretty fast once we have it, so do right now and avoid 
flickering.
-                compute.run();
             }
         }
+    
+    private void restartTimer () {
+        if (timer == null) {
+            timer = new Timer(1000, new ActionListener() {
+                @Override
+                public void actionPerformed (ActionEvent e) {
+                    moduleList.setModel(UIUtil.createListWaitModel());
+                }
+            });
+            timer.setRepeats(false);
+        }
+        timer.restart();
     }
     
     private void initAccessibility() {

[hg] main-silver: #206298 - AddModulePanel insertUpdate handler ...

Ondrej Vrabec 11/21/2012

Project Features

About this Project

APIsupport was started in November 2009, is owned by Antonin Nebuzelsky, and has 43 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close