Author: ceki
Date: Tue Feb 26 17:56:58 2008
New Revision: 988

Modified:
   
slf4j/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/ProgressListenerImpl.java

Log:
- limit the number of screen updates to eliminate screen flicker

Modified: 
slf4j/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/ProgressListenerImpl.java
==============================================================================
--- 
slf4j/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/ProgressListenerImpl.java
      (original)
+++ 
slf4j/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/internal/ProgressListenerImpl.java
      Tue Feb 26 17:56:58 2008
@@ -32,12 +32,18 @@
 public class ProgressListenerImpl implements ProgressListener {
 
   static final int TARGET_FILE_LENGTH = 85;
+  static final int UPDATE_THRESHOLD = 100;
+  
   int addFileCount = 0;
   int scanFileCount = 0;
   int inplaceConversionCount = 0;
   final MigratorFrame frame;
 
   Abbreviator abbr;
+  
+  long lastUpdate = 0;
+  
+  
 
   public ProgressListenerImpl(File projectFolder, MigratorFrame frame) {
     this.frame = frame;
@@ -49,7 +55,19 @@
     frame.disableInput();
   }
 
+  boolean isTooSoon() {
+    long now = System.currentTimeMillis();
+    if(now-lastUpdate < UPDATE_THRESHOLD) {
+      return true;
+    } else {
+      lastUpdate = now;
+      return false;
+    }
+  }
+ 
   public void onDirectory(File file) {
+    if(isTooSoon()) return;
+      
     String abbreviatedName = getShortName(file);
     frame.otherLabel.setText("<html><p>Searching folder [" + abbreviatedName
         + "]<p>Found " + addFileCount + " java files to scan.</html>");
@@ -74,9 +92,11 @@
   }
 
   public void onFileScan(File file) {
-    String abbreviatedName = getShortName(file);
+  
     scanFileCount++;
-
+    if(isTooSoon()) return;
+    String abbreviatedName = getShortName(file);
+    
     frame.otherLabel.setText("<html><p>Scanning file [" + abbreviatedName
         + "]<p></html>");
     // File + scanFileCount + " out of "+ addFileCount+" files to scan."+
_______________________________________________
dev mailing list
dev@slf4j.org
http://www.slf4j.org/mailman/listinfo/dev

Reply via email to