data.left = new FormAttachment(0,0);
data.top = new FormAttachment(cancel_button,0, SWT.CENTER);
label.setLayoutData( data );
final ProgressBar progress = new ProgressBar(parent, SWT.NULL );
progress.setMinimum( 0 );
progress.setMaximum( 100 );
progress.setSelection( 0 );
data = new FormData();
data.left = new FormAttachment(label,4);
data.top = new FormAttachment(cancel_button, 0, SWT.CENTER);
data.right = new FormAttachment(cancel_button,-4);
progress.setLayoutData( data );
parent.layout( true, true );
new AEThread2( "SimpleInstallerUI", true )
{
public void
run()
{
try{
Update[] updates = instance.getUpdates();
for ( Update update: updates ){
String name = update.getName();
int pos = name.indexOf('/');
if ( pos >= 0 ){
name = name.substring( pos+1 );
}
setLabel( name );
ResourceDownloader[] downloaders = update.getDownloaders();
for ( ResourceDownloader downloader: downloaders ){
synchronized( SimpleInstallUI.this ){
if ( cancelled ){
return;
}
current_downloader = downloader;
}
setProgress( 0 );
downloader.addListener(
new ResourceDownloaderAdapter()
{
public void
reportPercentComplete(
ResourceDownloader downloader,
int percentage )
{
setProgress( percentage );
}
public void
reportAmountComplete(
ResourceDownloader downloader,
long amount )
{
}
});
downloader.download();
}
}
boolean restart_required = false;
for (int i=0;i<updates.length;i++){
if ( updates[i].getRestartRequired() == Update.RESTART_REQUIRED_YES ){
restart_required = true;
}
}
if ( restart_required ){
monitor.handleRestart();
}
}catch( Throwable e ){
Debug.out( "Install failed", e );
instance.cancel();
}
}
protected void
setLabel(
final String str )
{
Utils.execSWTThread(
new Runnable()
{
public void
run()
{
if (label != null && !label.isDisposed()) {
label.setText( str );
label.getParent().layout();
}
}
});
}
protected void
setProgress(
final int percent )
{
Utils.execSWTThread(
new Runnable()
{
public void
run()
{
if (progress != null && !progress.isDisposed()) {
progress.setSelection( percent );
}
}
});
}
}.start();