Removed 'Cancel' from ProgressApplet, allow CPGeneratorProgress to restart

This commit is contained in:
timm 1998-05-01 10:31:14 +00:00
parent ede12d798a
commit b168f2585b
2 changed files with 132 additions and 122 deletions

View File

@ -20,6 +20,7 @@ package netscape.asw;
import netscape.npasw.CPGenerator;
import netscape.npasw.ServerDownload;
import netscape.npasw.Trace;
import java.lang.*;
//import AMDProgressBar;
@ -54,84 +55,91 @@ public class CPGeneratorProgress extends ProgressApplet
{
try
{
int lastState = CPGenerator.DONE;
int thisState = CPGenerator.DONE;
String lastString = "";
String thisString = "";
while ( !CPGenerator.done )
{
thisState = getState();
thisString = new String( CPGenerator.currentFile );
if ( thisState != lastState )
{
String buffer = null;
switch ( thisState )
{
case ServerDownload.DOWNLOADING:
buffer = DOWNLOAD_STRING;
break;
case ServerDownload.UNJARRING:
buffer = UNJAR_STRING;
break;
case CPGenerator.CONTACTING_SERVER:
buffer = CONTACTING_SERVER;
break;
case CPGenerator.SENDING:
buffer = SENDING;
break;
case CPGenerator.WAITING:
buffer = WAITING;
break;
case CPGenerator.RECEIVING_RESPONSE:
buffer = RECEIVING_RESPONSE;
break;
case CPGenerator.DONE:
buffer = DONE_STRING;
break;
case CPGenerator.ABORT:
buffer = ABORT;
break;
}
status.setText( buffer );
lastState = thisState;
}
if ( thisString.compareTo( lastString ) != 0 )
{
progress.setText( thisString );
lastString = thisString;
}
if ( ServerDownload.getBytesDownloaded() == 0 || CPGenerator.totalBytes == 0 )
progressBar.setPercent( 0.0 );
else
progressBar.setPercent( (double)ServerDownload.getBytesDownloaded() / (double)CPGenerator.totalBytes );
repaint();
Thread.sleep( 100 );
}
progressBar.setPercent( 1.0 );
progress.setText( "" );
status.setText( DONE_STRING );
repaint();
Thread.sleep( 2000 );
}
catch (Exception e)
{
;
}
while ( true )
{
Trace.TRACE( "running applet" );
int lastState = CPGenerator.DONE;
int thisState = CPGenerator.DONE;
String lastString = "";
String thisString = "";
while ( CPGenerator.done == false )
{
//Trace.TRACE( "CPGenerator not done" );
thisState = getState();
thisString = new String( CPGenerator.currentFile );
if ( thisState != lastState )
{
String buffer = null;
switch ( thisState )
{
case ServerDownload.DOWNLOADING:
buffer = DOWNLOAD_STRING;
break;
case ServerDownload.UNJARRING:
buffer = UNJAR_STRING;
break;
case CPGenerator.CONTACTING_SERVER:
buffer = CONTACTING_SERVER;
break;
case CPGenerator.SENDING:
buffer = SENDING;
break;
case CPGenerator.WAITING:
buffer = WAITING;
break;
case CPGenerator.RECEIVING_RESPONSE:
buffer = RECEIVING_RESPONSE;
break;
case CPGenerator.DONE:
buffer = DONE_STRING;
break;
case CPGenerator.ABORT:
buffer = ABORT;
break;
}
status.setText( buffer );
lastState = thisState;
}
if ( thisString.compareTo( lastString ) != 0 )
{
progress.setText( thisString );
lastString = thisString;
}
if ( ServerDownload.getBytesDownloaded() == 0 || CPGenerator.totalBytes == 0 )
progressBar.setPercent( 0.0 );
else
progressBar.setPercent( (double)ServerDownload.getBytesDownloaded() / (double)CPGenerator.totalBytes );
repaint();
Thread.sleep( 50 );
}
Trace.TRACE( "CPGenerator done" );
progressBar.setPercent( 1.0 );
progress.setText( "" );
status.setText( DONE_STRING );
repaint();
Thread.sleep( 1000 );
}
}
catch (Exception e)
{
;
}
}
}

View File

@ -39,50 +39,50 @@ public class ProgressApplet extends Applet implements Runnable
int loop1 = 1;
Thread thread = null;
public void init()
{
super.init();
Trace.TRACE( "applet got loaded" );
//setBackground( Color.white );
setLayout( null );
//setResizable( false );
//setModal( true );
public void init()
{
super.init();
Trace.TRACE( "applet got loaded" );
//setBackground( Color.white );
setLayout( null );
//setResizable( false );
//setModal( true );
addNotify();
resize( insets().left + insets().right + 360, insets().top + insets().bottom + 120 );
setFont( TEXTFONT );
status = new java.awt.Label( "" );
status.reshape( insets().left + 12, insets().top + 8, 340, 24 );
status.setFont( TEXTFONT );
add( status );
progress = new java.awt.Label( "" );
progress.reshape( insets().left + 12, insets().top + 32, 340, 20 );
progress.setFont( BARFONT );
add( progress );
//cancel = new java.awt.Button( "Cancel" );
//cancel.reshape( insets().left + 240, insets().top + 80, 80, 20 );
//add( cancel );
// [canvas]
progressBar = new AMDProgressBar();
progressBar.setFont( TEXTFONT );
progressBar.reshape( 12, 80, 300, 21 );
progressBar.setBoxColors( BOXCOLOR, BOXCOLOR );
progressBar.setBarColor( BARCOLOR );
progressBar.setBackgroundColors( BACKCOLOR, BACKCOLOR );
add( progressBar );
show();
enable();
repaint();
Trace.TRACE( "done initing applet" );
}
addNotify();
resize( insets().left + insets().right + 360, insets().top + insets().bottom + 120 );
setFont( TEXTFONT );
status = new java.awt.Label( "" );
status.reshape( insets().left + 12, insets().top + 8, 340, 24 );
status.setFont( TEXTFONT );
add( status );
progress = new java.awt.Label( "" );
progress.reshape( insets().left + 12, insets().top + 32, 340, 20 );
progress.setFont( BARFONT );
add( progress );
cancel = new java.awt.Button( "Cancel" );
cancel.reshape( insets().left + 240, insets().top + 80, 80, 20 );
add( cancel );
// [canvas]
progressBar = new AMDProgressBar();
progressBar.setFont( TEXTFONT );
progressBar.reshape( 12, 80, 200, 21 );
progressBar.setBoxColors( BOXCOLOR, BOXCOLOR );
progressBar.setBarColor( BARCOLOR );
progressBar.setBackgroundColors( BACKCOLOR, BACKCOLOR );
add( progressBar );
show();
enable();
repaint();
Trace.TRACE( "done initing applet" );
}
public boolean handleEvent( Event event )
{
public boolean handleEvent( Event event )
{
if ( event.target == cancel && event.id == Event.ACTION_EVENT )
{
cancel_Clicked( event );
@ -113,12 +113,14 @@ public class ProgressApplet extends Applet implements Runnable
public void start()
{
Trace.TRACE( "starting applet" );
thread = new Thread( this );
thread.start();
}
public void stop()
{
Trace.TRACE( "stopping applet" );
thread.stop();
thread = null;
}