FileDocCategorySizeDatePackage
DownloadBar.javaAPI DocAzureus 3.0.3.45272Fri Aug 03 15:59:08 BST 2007org.gudy.azureus2.ui.swt.minibar

DownloadBar

public class DownloadBar extends MiniBar
author
Allan Crooks

Fields Summary
private static MiniBarManager
manager
private org.gudy.azureus2.core3.download.DownloadManager
download
private org.eclipse.swt.widgets.Label
download_name
private org.eclipse.swt.widgets.ProgressBar
progress_bar
private org.eclipse.swt.widgets.Label
down_speed
private org.eclipse.swt.widgets.Label
up_speed
private org.eclipse.swt.widgets.Label
eta
Constructors Summary
private DownloadBar(org.gudy.azureus2.core3.download.DownloadManager download, org.eclipse.swt.widgets.Shell main)

		super(manager);
		this.download = download;
		this.construct(main);
	
Methods Summary
public voidbeginConstruction()

		
		// Download name.
		this.createFixedTextLabel("MinimizedWindow.name", false, false);
		this.download_name = this.createDataLabel(200);
		
		// Download progress.
		this.progress_bar = this.createPercentProgressBar(100);
		
		// Download speed.
		this.createFixedTextLabel("ConfigView.download.abbreviated", false, false);
		this.down_speed = this.createSpeedLabel();
		
		// Upload speed.
		this.createFixedTextLabel("ConfigView.upload.abbreviated", false, false);
		this.up_speed = this.createSpeedLabel();
		
		// ETA.
		this.createFixedTextLabel("MyTorrentsView.eta", true, false);
		this.eta = this.createDataLabel(65);
	
public voidbuildMenu(org.eclipse.swt.widgets.Menu menu)

		
		// Queue
		final MenuItem itemQueue = new MenuItem(menu, SWT.PUSH);
		Messages.setLanguageText(itemQueue, "MyTorrentsView.menu.queue");
		Utils.setMenuItemImage(itemQueue, "start");
		itemQueue.addListener(SWT.Selection, new Listener() {
			public void handleEvent(Event e) {
				ManagerUtils.queue(download, splash);
			}
		});
		itemQueue.setEnabled(ManagerUtils.isStartable(download));


		// Stop
		final MenuItem itemStop = new MenuItem(menu, SWT.PUSH);
		Messages.setLanguageText(itemStop, "MyTorrentsView.menu.stop");
		Utils.setMenuItemImage(itemStop, "stop");
		itemStop.addListener(SWT.Selection, new Listener() {
			public void handleEvent(Event e) {
				ManagerUtils.stop(download, splash);
			}
		});
		itemStop.setEnabled(ManagerUtils.isStopable(download));
		
		new MenuItem(menu, SWT.SEPARATOR);
		super.buildMenu(menu);
	
public static voidclose(org.gudy.azureus2.core3.download.DownloadManager download)

		DownloadBar result = (DownloadBar)manager.getMiniBarForObject(download);
		if (result != null) {result.close();}
	
public java.lang.ObjectgetContextObject()

return this.download;
public static MiniBarManagergetManager()

		manager = new MiniBarManager("AllTransfersBar");
	
		return manager;
	
public java.lang.ObjectgetPluginMenuContextObject()

		try {return DownloadManagerImpl.getDownloadStatic(this.download);}
		catch (DownloadException de) {return null;}
	
public java.lang.String[]getPluginMenuIdentifiers(java.lang.Object context)

		if (context == null) {return null;}
		return new String[] {"downloadbar", "download_context"};
	
public static org.gudy.azureus2.ui.swt.minibar.DownloadBaropen(org.gudy.azureus2.core3.download.DownloadManager download, org.eclipse.swt.widgets.Shell main)

		DownloadBar result = (DownloadBar)manager.getMiniBarForObject(download);
		if (result == null) {
			result = new DownloadBar(download, main);
		}
		return result;
	
protected voidrefresh0()

		DownloadManagerStats stats = download.getStats();

        download_name.setText(download.getDisplayName());
        int percent = stats.getCompleted();
        
        this.updateSpeedLabel(down_speed, stats.getDataReceiveRate(), stats.getProtocolReceiveRate());
        this.updateSpeedLabel(up_speed, stats.getDataSendRate(), stats.getProtocolSendRate());
        
        eta.setText(DisplayFormatters.formatETA(stats.getETA()));
        if (progress_bar.getSelection() != percent) {
        	progress_bar.setSelection(percent);
        	progress_bar.redraw();
        }