FileDocCategorySizeDatePackage
PiecesView.javaAPI DocAzureus 3.0.3.46134Fri Jul 27 09:56:16 BST 2007org.gudy.azureus2.ui.swt.views

PiecesView

public class PiecesView extends org.gudy.azureus2.ui.swt.views.table.impl.TableViewTab implements org.gudy.azureus2.core3.download.DownloadManagerPeerListener, com.aelitis.azureus.ui.common.table.TableDataSourceChangedListener, com.aelitis.azureus.ui.common.table.TableLifeCycleListener
author
Olivier
author
TuxPaper 2004/Apr/20: Remove need for tableItemToObject 2004/Apr/21: extends TableView instead of IAbstractView
author
MjrTom 2005/Oct/08: Add PriorityItem, SpeedItem

Fields Summary
private static final com.aelitis.azureus.ui.common.table.TableColumnCore[]
basicItems
org.gudy.azureus2.core3.download.DownloadManager
manager
private org.gudy.azureus2.ui.swt.views.table.impl.TableViewSWTImpl
tv
private org.eclipse.swt.widgets.Composite
legendComposite
private org.gudy.azureus2.ui.swt.views.piece.PieceInfoView
pieceInfoView
private org.gudy.azureus2.ui.swt.views.piece.PieceDistributionView
pieceDistView
Constructors Summary
public PiecesView()
Initialize

  
	 	 
	  
		tv = new TableViewSWTImpl(TableManager.TABLE_TORRENT_PIECES, "PiecesView",
				basicItems, basicItems[0].getName(), SWT.SINGLE | SWT.FULL_SELECTION
						| SWT.VIRTUAL);
		setTableView(tv);
		tv.setEnableTabViews(true);
		pieceInfoView = new PieceInfoView();
		pieceDistView = new PieceDistributionView();
		tv.setCoreTabViews(new IView[] {
			pieceInfoView,pieceDistView
		});
		tv.addTableDataSourceChangedListener(this, true);
		tv.addLifeCycleListener(this);
	
Methods Summary
private voidaddExistingDatasources()
Add datasources already in existance before we called addListener. Faster than allowing addListener to call us one datasource at a time.

		if (manager == null || tv.isDisposed()) {
			return;
		}

		Object[] dataSources = manager.getCurrentPieces();
		if (dataSources == null || dataSources.length == 0)
			return;

		tv.addDataSources(dataSources);
  	tv.processDataSourceQueue();
	
public org.gudy.azureus2.core3.download.DownloadManagergetManager()

return
the manager

		return manager;
	
public voidpeerAdded(org.gudy.azureus2.core3.peer.PEPeer peer)

  
public voidpeerManagerAdded(org.gudy.azureus2.core3.peer.PEPeerManager manager)

	
public voidpeerManagerRemoved(org.gudy.azureus2.core3.peer.PEPeerManager manager)

		tv.removeAllTableRows();
	
public voidpeerManagerWillBeAdded(org.gudy.azureus2.core3.peer.PEPeerManager peer_manager)

public voidpeerRemoved(org.gudy.azureus2.core3.peer.PEPeer peer)

  
public voidpieceAdded(org.gudy.azureus2.core3.peer.PEPiece created)

    tv.addDataSource(created);
	
public voidpieceRemoved(org.gudy.azureus2.core3.peer.PEPiece removed)

    
    tv.removeDataSource(removed);
	
public voidtableDataSourceChanged(java.lang.Object newDataSource)

		if (manager != null)
			manager.removePeerListener(this);

		if (newDataSource == null)
			manager = null;
		else if (newDataSource instanceof Object[])
			manager = (DownloadManager)((Object[])newDataSource)[0];
		else
			manager = (DownloadManager)newDataSource;

  	if (manager != null) {
			manager.addPeerListener(this, false);
			addExistingDatasources();
    }
  	if (pieceInfoView != null) {
  		pieceInfoView.dataSourceChanged(manager);
		}
  	if (pieceDistView != null) {
  		pieceDistView.dataSourceChanged(manager);
		}
	
public voidtableViewDestroyed()

		if (legendComposite != null && legendComposite.isDisposed()) {
			legendComposite.dispose();
		}

		if (manager != null) {
			manager.removePeerListener(this);
		}
	
public voidtableViewInitialized()

		if (legendComposite != null && (tv instanceof TableViewSWT)) {
			Composite composite = ((TableViewSWT) tv).getTableComposite();

			legendComposite = Legend.createLegendComposite(composite,
					BlocksItem.colors, new String[] {
					"PiecesView.legend.requested",
					"PiecesView.legend.written",        			
					"PiecesView.legend.downloaded",
						"PiecesView.legend.incache"
					});
	}

		if (manager != null) {
  		manager.removePeerListener(this);
			manager.addPeerListener(this, false);
			addExistingDatasources();
    }