FileDocCategorySizeDatePackage
SplashWindow.javaAPI DocAzureus 3.0.3.45492Thu May 31 16:34:10 BST 2007org.gudy.azureus2.ui.swt.mainwindow

SplashWindow

public class SplashWindow extends Object implements com.aelitis.azureus.ui.InitializerListener
The initial Splash Screen shown while azureus loads

Fields Summary
org.eclipse.swt.widgets.Display
display
com.aelitis.azureus.ui.IUIIntializer
initializer
org.eclipse.swt.widgets.Shell
splash
org.eclipse.swt.widgets.Label
currentTask
org.eclipse.swt.widgets.ProgressBar
percentDone
private String
task
private int
percent
private boolean
updating
Constructors Summary
public SplashWindow(org.eclipse.swt.widgets.Display display)

  	this(display, null);
  
public SplashWindow(org.eclipse.swt.widgets.Display display, com.aelitis.azureus.ui.IUIIntializer initializer)

    this.display = display;
    this.initializer = initializer;
    
    splash = new Shell(display, SWT.NULL);
    splash.setText("Azureus");
    Utils.setShellIcon(splash);

    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    splash.setLayout(layout);
    Label label = new Label(splash, SWT.NONE);
    label.setImage(ImageRepository.getImage("azureus_splash"));

    currentTask = new Label(splash,SWT.BORDER);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    currentTask.setLayoutData(gridData);
    currentTask.setBackground(ColorCache.getColor(display, 255, 255, 255));
    currentTask.setText("(: Azureus :)");
    
    this.percentDone = new ProgressBar(splash,SWT.HORIZONTAL);
    this.percentDone.setMinimum(0);
    this.percentDone.setMaximum(100);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    this.percentDone.setLayoutData(gridData);

    splash.pack();
    splash.layout();
    Utils.centreWindow(splash);
    splash.open();
    
    if (initializer != null) {
    	initializer.addListener(this);
    }
  
Methods Summary
public voidcloseSplash()

    Utils.execSWTThread(new AERunnable(){
      public void runSupport() {
				try {
					if (initializer != null)
						initializer.removeListener(SplashWindow.this);
					if (splash != null && !splash.isDisposed())
						splash.dispose();
					ImageRepository.unloadImage("azureus_splash");
				} catch (Exception e) {
					//ignore
				}
			}
    });
  
public static voidcreate(org.eclipse.swt.widgets.Display display, Initializer initializer)

  	Utils.execSWTThread(new AERunnable() {
			public void runSupport() {
				if (display == null || display.isDisposed())
					return;

				new SplashWindow(display, initializer);
			}
		});
  
public intgetPercent()

		return percent;
	
public voidreportCurrentTask(java.lang.String task)

    //Ensure that display is set and not disposed
    if(display == null || display.isDisposed())
      return;

    if (this.task == null || this.task.compareTo(task) != 0) {
    	this.task = task;
    	update();
    }
  
public voidreportPercent(int percent)

    //Ensure that display is set and not disposed
    if(display == null || display.isDisposed())
      return;
    
    //OK Tricky way to close the splash window BUT ... sending a percent > 100 means closing
    if (percent > 100) {
      closeSplash();
      return;
    }
    
    if (this.percent != percent) {
    	this.percent = percent;
    	update();
    }
  
private voidupdate()

since
3.0.0.7

		if (updating) {
			return;
		}
		
		updating = true;
    //Post runnable to SWTThread
    Utils.execSWTThread(new AERunnable(){
      public void runSupport() {
      	updating = false;
        //Ensure than the task Label is created and not disposed
        if(currentTask != null && !currentTask.isDisposed() && task != null) {
        	currentTask.setText(task);
        }
        //Ensure than the percentDone ProgressBar is created and not disposed
        if(percentDone != null && !percentDone.isDisposed()) {
        	percentDone.setSelection(percent);
        }
      }
    });