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

PercentItem

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

Fields Summary
Constructors Summary
public PercentItem()
Default Constructor

    super("%", 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();
	
    long percent = 0;
	
    if (fileInfo != null ){
		
		if ( fileInfo.getDownloaded() < 0 ){
			
			percent = -1; // unknown skeleton value
			
		}else if ( fileInfo.getLength() != 0 ){

			percent = (1000 * fileInfo.getDownloaded()) / fileInfo.getLength();
		}
	  
    }else{
		
		percent = -1;	// unknown skeleton value
    }
	
    if( !cell.setSortValue( percent ) && cell.isValid() ) {
		
      return;
    }
    
    cell.setText( percent < 0?"":DisplayFormatters.formatPercentFromThousands((int)percent));