Author: brett
Date: Fri Jan 20 01:10:14 2006
New Revision: 370761

URL: http://svn.apache.org/viewcvs?rev=370761&view=rev
Log:
[MRM-63] add a progress bar for the checksum

Modified:
    
maven/repository-manager/trunk/maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java
    
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf

Modified: 
maven/repository-manager/trunk/maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java
URL: 
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java?rev=370761&r1=370760&r2=370761&view=diff
==============================================================================
--- 
maven/repository-manager/trunk/maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java
 (original)
+++ 
maven/repository-manager/trunk/maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java
 Fri Jan 20 01:10:14 2006
@@ -17,7 +17,10 @@
  *
  */
 
+import javax.swing.*;
 import java.applet.Applet;
+import java.awt.*;
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -25,7 +28,6 @@
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.security.PrivilegedAction;
-import java.util.Properties;
 
 /**
  * TODO: Description.
@@ -39,14 +41,23 @@
 
     private static final int BYTE_MASK = 0xFF;
 
+    private JProgressBar progressBar;
+
     public void init()
     {
-        super.init();
+        setLayout( new BorderLayout() );
+        progressBar = new JProgressBar();
+        progressBar.setStringPainted( true );
+        add( progressBar, BorderLayout.CENTER );
+        JLabel label = new JLabel( "Checksum progress: " );
+        add( label, BorderLayout.WEST );
+        setVisible( false );
     }
 
     public String generateMd5( final String file )
         throws IOException, NoSuchAlgorithmException
     {
+        setVisible( true );
         return (String) AccessController.doPrivileged( new PrivilegedAction()
         {
             public Object run()
@@ -55,6 +66,8 @@
                 {
                     MessageDigest digest = MessageDigest.getInstance( "MD5" );
 
+                    long total = new File( file ).length();
+                    long totalRead = 0;
                     InputStream fis = new FileInputStream( file );
                     try
                     {
@@ -66,6 +79,8 @@
                             if ( numRead > 0 )
                             {
                                 digest.update( buffer, 0, numRead );
+                                totalRead += numRead;
+                                progressBar.setValue( (int) ( totalRead * 
progressBar.getMaximum() / total ) );
                             }
                         }
                         while ( numRead != -1 );

Modified: 
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf
URL: 
http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf?rev=370761&r1=370760&r2=370761&view=diff
==============================================================================
--- 
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf
 (original)
+++ 
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/form.jspf
 Fri Jan 20 01:10:14 2006
@@ -23,14 +23,15 @@
 </script>
 
 <p>Search by MD5 (select an artifact):
-  <form action="search.action"
-        onsubmit="this.md5.value = doSomething(this.file.value); 
this.file.disabled = true;">
-    <input name="md5" type="hidden"/>
-    <input type="file" name="file"/>
-    <input type="submit" value="Search"/>
-  </form>
 
-  <!--"CONVERTED_APPLET"-->
+<form action="search.action"
+      onsubmit="this.md5.value = doSomething(this.file.value); 
this.file.disabled = true;">
+  <input name="md5" type="hidden"/>
+  <input type="file" name="file"/>
+  <input type="submit" value="Search"/>
+</form>
+
+<!--"CONVERTED_APPLET"-->
 <!-- HTML CONVERTER -->
 <script language="JavaScript" type="text/javascript"><!--
     var _info = navigator.userAgent;
@@ -39,32 +40,33 @@
     var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && 
_info.indexOf("Windows 3.1") < 0);
 //--></script>
 
-    <comment>
-        <script language="JavaScript" type="text/javascript"><!--
+<comment>
+  <script language="JavaScript" type="text/javascript"><!--
         var _ns = (navigator.appName.indexOf("Netscape") >= 0 && 
((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && 
java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || 
(_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0) || 
(_info.indexOf("AIX") > 0) || (_info.indexOf("OS/2") > 0) || 
(_info.indexOf("IRIX") > 0)));
         var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5") >= 0));
 //--></script>
-    </comment>
+</comment>
 
 <script language="JavaScript" type="text/javascript"><!--
-    if (_ie == true) document.writeln('<object 
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "1" HEIGHT = "1" 
NAME = "ChecksumApplet"  
codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=5,0,0,5";><noembed><xmp>');
+    if (_ie == true) document.writeln('<object 
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "400" HEIGHT = 
"20" NAME = "ChecksumApplet"  
codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=5,0,0,5";><noembed><xmp>');
     else if (_ns == true && _ns6 == false) document.writeln('<embed ' +
            'type="application/x-java-applet;version=1.5" \
             CODE = "org/apache/maven/repository/applet/ChecksumApplet.class" \
             ARCHIVE = "maven-repository-artifact-applet.jar" \
             NAME = "ChecksumApplet" \
-            WIDTH = "1" \
-            HEIGHT = "1" ' +
+            WIDTH = "400" \
+            HEIGHT = "20" ' +
            'scriptable=false ' +
            
'pluginspage="http://java.sun.com/products/plugin/index.html#download";><noembed><xmp>');
 //--></script>
-<applet  CODE = "org/apache/maven/repository/applet/ChecksumApplet.class" 
ARCHIVE = "maven-repository-artifact-applet.jar" WIDTH = "1" HEIGHT = "1" NAME 
= "ChecksumApplet"></xmp>
-    <PARAM NAME = CODE VALUE = 
"org/apache/maven/repository/applet/ChecksumApplet.class" >
-    <PARAM NAME = ARCHIVE VALUE = "maven-repository-artifact-applet.jar" >
-    <PARAM NAME = NAME VALUE = "ChecksumApplet" >
+<applet CODE="org/apache/maven/repository/applet/ChecksumApplet.class" 
ARCHIVE="maven-repository-artifact-applet.jar"
+        WIDTH="400" HEIGHT="20" NAME="ChecksumApplet"></xmp>
+<PARAM NAME=CODE 
VALUE="org/apache/maven/repository/applet/ChecksumApplet.class">
+  <PARAM NAME=ARCHIVE VALUE="maven-repository-artifact-applet.jar">
+  <PARAM NAME=NAME VALUE="ChecksumApplet">
 
-    <param name="type" value="application/x-java-applet;version=1.5">
-    <param name="scriptable" value="false">
+  <param name="type" value="application/x-java-applet;version=1.5">
+  <param name="scriptable" value="false">
 
 
 </applet>
@@ -73,7 +75,8 @@
 </object>
 
 <!--
-<APPLET CODE = "org/apache/maven/repository/applet/ChecksumApplet.class" 
ARCHIVE = "maven-repository-artifact-applet.jar" WIDTH = "1" HEIGHT = "1" NAME 
= "ChecksumApplet">
+<APPLET CODE = "org/apache/maven/repository/applet/ChecksumApplet.class" 
ARCHIVE =
+"maven-repository-artifact-applet.jar" WIDTH = "400" HEIGHT = "20" NAME = 
"ChecksumApplet">
 
 
 </APPLET>


Reply via email to