FileDocCategorySizeDatePackage
BadAvailTimeItem.javaAPI DocAzureus 3.0.3.42892Wed Aug 15 09:00:02 BST 2007org.gudy.azureus2.ui.swt.views.tableitems.mytorrents

BadAvailTimeItem

public class BadAvailTimeItem extends org.gudy.azureus2.ui.swt.views.table.utils.CoreTableColumn implements TableCellRefreshListener

Fields Summary
private static String
now_string
Constructors Summary
public BadAvailTimeItem(String sTableID)

		
		MessageText.addAndFireListener(
			new MessageText.MessageTextListener()
			{
				public void 
				localeChanged(
					Locale old_locale, 
					Locale new_locale ) 
				{
					now_string = MessageText.getString( "SpeedView.stats.now" );
				}
			});
	
		super("bad_avail_time", ALIGN_CENTER, POSITION_INVISIBLE, 120, sTableID);
		setRefreshInterval(INTERVAL_LIVE);
	
Methods Summary
public voidrefresh(TableCell cell)

		DownloadManager dm = (DownloadManager) cell.getDataSource();
		long value = dm==null?-1:dm.getStats().getAvailWentBadTime();

		if ( value == 0 ){
			
				// zero means no recorded last bad availability time (bad=transition from >=1 -> < 1)
			
			PEPeerManager pm = dm.getPeerManager();
			
			if ( pm  == null || pm.getMinAvailability() < 1.0 ){
				
				long stopped = dm.getDownloadState().getLongAttribute( DownloadManagerState.AT_TIME_STOPPED );
				
				if ( stopped > 0 ){
					
					value = stopped;
					
				}else{
					
					value = -1;
				}
				
			}else{
				
				value = -2;
			}
		}
		
		String text;
		
		if ( value == -1 ){
			text = "";
		}else if ( value == -2 ){
			text = now_string;
		}else{
			text = DisplayFormatters.formatDate(value);
		}
		
		if (!cell.setSortValue(value) && cell.isValid())
			return;

		cell.setText(text);