geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r721779 - in /geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor: ProgressSpinnerMonitor.java SimpleMonitor.java
Date Sun, 30 Nov 2008 07:46:21 GMT
Author: jdillon
Date: Sat Nov 29 23:46:21 2008
New Revision: 721779

URL: http://svn.apache.org/viewvc?rev=721779&view=rev
Log:
Add a simple download monitor

Added:
    geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java
  (contents, props changed)
      - copied, changed from r721778, geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java
Modified:
    geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java

Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java?rev=721779&r1=721778&r2=721779&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java
Sat Nov 29 23:46:21 2008
@@ -65,6 +65,8 @@
     public void transferStarted(final TransferEvent event) {
         assert event != null;
 
+        super.transferStarted(event);
+
         complete = 0;
 
         spinner.reset();
@@ -74,14 +76,14 @@
 
         String message = type + ": " + location;
 
-        log.debug(message);
-
         println(message);
     }
 
     public void transferProgress(final TransferEvent event) {
         assert event != null;
 
+        super.transferProgress(event);
+
         long total = event.getContentLength();
         complete += event.getLength();
 
@@ -94,7 +96,6 @@
             message = complete + "/" + (total == TransferEvent.UNKNOWN_LENGTH ? "?" : total
+ "b");
         }
 
-        log.trace(message);
         
         print(spinner.spin(message));
     }

Copied: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java
(from r721778, geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java?p2=geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java&p1=geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java&r1=721778&r2=721779&rev=721779&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/ProgressSpinnerMonitor.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java
Sat Nov 29 23:46:21 2008
@@ -26,34 +26,20 @@
 import java.io.IOException;
 
 /**
- * A download monitor providing a simple spinning progress interface.
+ * A simple download monitor.
  *
  * @version $Rev$ $Date$
  */
-public class ProgressSpinnerMonitor
+public class SimpleMonitor
     extends TransferListenerSupport
 {
-    private static final String CARRIAGE_RETURN = "\r";
-
     private final IO io;
 
-    private final ProgressSpinner spinner = new ProgressSpinner();
-
-    private long complete;
-
-    public ProgressSpinnerMonitor(final IO io) throws IOException {
+    public SimpleMonitor(final IO io) throws IOException {
         assert io != null;
 
         this.io = io;
     }
-    
-    private void print(final String message) {
-        if (!io.isQuiet()) {
-            io.out.print(message);
-            io.out.print(CARRIAGE_RETURN);
-            io.out.flush();
-        }
-    }
 
     private void println(final String message) {
         if (!io.isQuiet()) {
@@ -65,9 +51,7 @@
     public void transferStarted(final TransferEvent event) {
         assert event != null;
 
-        complete = 0;
-
-        spinner.reset();
+        super.transferStarted(event);
 
         String type = event.getRequestType() == TransferEvent.RequestType.UPLOAD ? "Uploading"
: "Downloading";
         String location = event.getLocation();
@@ -79,26 +63,6 @@
         println(message);
     }
 
-    public void transferProgress(final TransferEvent event) {
-        assert event != null;
-
-        long total = event.getContentLength();
-        complete += event.getLength();
-
-        String message;
-
-        if (total >= 1024) {
-            message = complete / 1024 + "/" + (total == TransferEvent.UNKNOWN_LENGTH ? "?"
: total / 1024 + "K");
-        }
-        else {
-            message = complete + "/" + (total == TransferEvent.UNKNOWN_LENGTH ? "?" : total
+ "b");
-        }
-
-        log.trace(message);
-        
-        print(spinner.spin(message));
-    }
-
     public void transferCompleted(final TransferEvent event) {
         assert event != null;
 
@@ -108,7 +72,6 @@
         String type = event.getRequestType() == TransferEvent.RequestType.UPLOAD ? "Uploaded"
: "Downloaded";
         String bytes = total >= 1024 ? ( total / 1024 ) + "K" : total + "b";
 
-        // HACK: pad at end just incase, should really blank the reset of the line
-        print(type + " " + bytes + "          ");
+        println(type + " " + bytes);
     }
 }
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/transfer/monitor/SimpleMonitor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message