FileDocCategorySizeDatePackage
RemainingPiecesItem.javaAPI DocAzureus 3.0.3.42380Mon Feb 19 14:24:06 GMT 2007org.gudy.azureus2.ui.swt.views.tableitems.files

RemainingPiecesItem

public class RemainingPiecesItem extends org.gudy.azureus2.ui.swt.views.table.utils.CoreTableColumn implements TableCellRefreshListener
author
TuxPaper
since
2.0.8.5

Fields Summary
Constructors Summary
public RemainingPiecesItem()
Default Constructor

    super("remaining", ALIGN_TRAIL, POSITION_LAST, 60, TableManager.TABLE_TORRENT_FILES);
    setRefreshInterval(INTERVAL_LIVE);
    setMinWidthAuto(true);
  
Methods Summary
public voidrefresh(TableCell cell)

    DiskManagerFileInfo fileInfo 	= (DiskManagerFileInfo)cell.getDataSource();
	
		//	 dm may be null if this is a skeleton file view
	
    DiskManager			dm			= fileInfo==null?null:fileInfo.getDiskManager();
	
    int remaining = 0;
    
    if( fileInfo != null && dm != null ) {
      int start = fileInfo.getFirstPieceNumber();
      int end = start + fileInfo.getNbPieces();
      DiskManagerPiece[] pieces = dm.getPieces();
      for( int i = start; i < end; i++ ) {
        if( !pieces[ i ].isDone() )  remaining++;
      }
    }else{
		
		remaining	= -1;	// unknown
    }

    if( !cell.setSortValue( remaining ) && cell.isValid() ) {
      return;
    }
    
    cell.setText( "" + ( remaining<0?"":(""+remaining)));