FileDocCategorySizeDatePackage
SeedingRankColumnListener.javaAPI DocAzureus 3.0.3.44972Thu Jan 11 11:47:38 GMT 2007com.aelitis.azureus.plugins.startstoprules.defaultplugin

SeedingRankColumnListener

public class SeedingRankColumnListener extends Object implements org.gudy.azureus2.plugins.ui.tables.TableCellRefreshListener, org.gudy.azureus2.core3.config.COConfigurationListener
A "My Torrents" column for displaying Seeding Rank.

Fields Summary
private Map
downloadDataMap
private org.gudy.azureus2.plugins.PluginConfig
pluginConfig
private int
minTimeAlive
private int
iRankType
private boolean
bDebugLog
Constructors Summary
public SeedingRankColumnListener(Map _downloadDataMap, org.gudy.azureus2.plugins.PluginConfig pc)

		downloadDataMap = _downloadDataMap;
		pluginConfig = pc;
		COConfigurationManager.addListener(this);
		configurationSaved();
	
Methods Summary
public voidconfigurationSaved()

		minTimeAlive = pluginConfig
				.getIntParameter("StartStopManager_iMinSeedingTime") * 1000;
		iRankType = pluginConfig.getIntParameter("StartStopManager_iRankType");
		bDebugLog = pluginConfig.getBooleanParameter("StartStopManager_bDebugLog");
	
public voidrefresh(org.gudy.azureus2.plugins.ui.tables.TableCell cell)

		Download dl = (Download) cell.getDataSource();
		if (dl == null)
			return;

		DefaultRankCalculator dlData = null;
		Object o = cell.getSortValue();
		if (o instanceof DefaultRankCalculator)
			dlData = (DefaultRankCalculator) o;
		else {
			dlData = (DefaultRankCalculator) downloadDataMap.get(dl);
			cell.setSortValue(dlData);
		}
		if (dlData == null)
			return;
			

		long sr = dl.getSeedingRank();

		String sText = "";
		if (sr >= 0) {
			if (dlData.getCachedIsFP())
				sText += MessageText.getString("StartStopRules.firstPriority") + " ";

			if (iRankType == StartStopRulesDefaultPlugin.RANK_TIMED) {
				//sText += "" + sr + " ";
				if (sr > DefaultRankCalculator.SR_TIMED_QUEUED_ENDS_AT) {
					long timeStarted = dl.getStats().getTimeStartedSeeding();
					long timeLeft;
					if (dl.isForceStart())
						timeLeft = Constants.INFINITY_AS_INT;
					else if (timeStarted <= 0)
						timeLeft = minTimeAlive;
					else
						timeLeft = (minTimeAlive - (SystemTime.getCurrentTime() - timeStarted));
					sText += TimeFormatter.format(timeLeft / 1000);
				} else if (sr > 0) {
					sText += MessageText.getString("StartStopRules.waiting");
				}
			} else if (sr > 0) {
				sText += String.valueOf(sr);
			}
		} else if (sr == DefaultRankCalculator.SR_FP0PEERS)
			sText = MessageText.getString("StartStopRules.FP0Peers");
		else if (sr == DefaultRankCalculator.SR_FP_SPRATIOMET)
			sText = MessageText.getString("StartStopRules.SPratioMet");
		else if (sr == DefaultRankCalculator.SR_RATIOMET)
			sText = MessageText.getString("StartStopRules.ratioMet");
		else if (sr == DefaultRankCalculator.SR_NUMSEEDSMET)
			sText = MessageText.getString("StartStopRules.numSeedsMet");
		else if (sr == DefaultRankCalculator.SR_NOTQUEUED)
			sText = "";
		else if (sr == DefaultRankCalculator.SR_0PEERS)
			sText = MessageText.getString("StartStopRules.0Peers");
		else if (sr == DefaultRankCalculator.SR_SHARERATIOMET)
			sText = MessageText.getString("StartStopRules.shareRatioMet");
		else {
			sText = "ERR" + sr;
		}
		// Add a Star if it's before minTimeAlive
		if (SystemTime.getCurrentTime() - dl.getStats().getTimeStartedSeeding() < minTimeAlive)
			sText = "* " + sText;
		cell.setText(sText);
		if (bDebugLog) {
			cell.setToolTip("FP:\n" + dlData.sExplainFP + "\n" + "SR:" + dlData.sExplainSR
					+ "\n" + "TRACE:\n" + dlData.sTrace);
		} else {
			cell.setToolTip(null);
		}