⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 healthitem.java

📁 java 文件下载器。可自定义
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   HealthItem.java

package org.gudy.azureus2.ui.swt.views.tableitems.mytorrents;

import com.aelitis.azureus.core.AzureusCore;
import com.aelitis.azureus.core.AzureusCoreFactory;
import com.aelitis.azureus.ui.swt.imageloader.ImageLoader;
import org.eclipse.swt.graphics.*;
import org.gudy.azureus2.core3.download.DownloadManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.tracker.host.TRHost;
import org.gudy.azureus2.plugins.download.Download;
import org.gudy.azureus2.plugins.ui.tables.*;
import org.gudy.azureus2.ui.swt.views.table.TableCellSWT;
import org.gudy.azureus2.ui.swt.views.table.TableCellSWTPaintListener;
import org.gudy.azureus2.ui.swt.views.table.utils.CoreTableColumn;

public class HealthItem extends CoreTableColumn
	implements TableCellAddedListener, TableCellRefreshListener, TableCellSWTPaintListener
{

	public static final Class DATASOURCE_TYPE = org/gudy/azureus2/plugins/download/Download;
	static final int COLUMN_WIDTH = 16;
	public static final String COLUMN_ID = "health";
	static TRHost tracker_host = AzureusCoreFactory.getSingleton().getTrackerHost();

	public void fillTableColumnInfo(TableColumnInfo info)
	{
		info.addCategories(new String[] {
			"essential"
		});
	}

	public HealthItem(String sTableID)
	{
		super(DATASOURCE_TYPE, "health", 3, 16, sTableID);
		initializeAsGraphic(-2, 16);
		setMinWidth(16);
	}

	public void cellAdded(TableCell cell)
	{
		cell.setMarginWidth(0);
		cell.setMarginHeight(0);
	}

	public void refresh(TableCell cell)
	{
		DownloadManager dm = (DownloadManager)cell.getDataSource();
		int health;
		org.gudy.azureus2.core3.tracker.host.TRHostTorrent ht;
		if (dm == null)
		{
			health = 0;
			ht = null;
		} else
		{
			health = dm.getHealthStatus();
			ht = tracker_host.getHostTorrent(dm.getTorrent());
		}
		if (!cell.setSortValue(health + (ht != null ? 256 : '\0')) && cell.isValid())
			return;
		String sHelpID = null;
		if (health == 5)
			sHelpID = "health.explain.red";
		else
		if (health == 4)
			sHelpID = "health.explain.green";
		else
		if (health == 2)
			sHelpID = "health.explain.blue";
		else
		if (health == 3)
			sHelpID = "health.explain.yellow";
		else
		if (health != 6)
			sHelpID = "health.explain.grey";
		String sToolTip = health != 6 || dm == null ? MessageText.getString(sHelpID) : dm.getErrorDetails();
		if (ht != null)
			sToolTip = (new StringBuilder()).append(sToolTip).append("\n").append(MessageText.getString("health.explain.share")).toString();
		cell.setToolTip(sToolTip);
	}

	public void cellPaint(GC gc, TableCellSWT cell)
	{
		String image_name;
		ImageLoader imageLoader;
		Image img;
		Comparable sortValue = cell.getSortValue();
		if (!(sortValue instanceof Long))
			return;
		boolean isShare = false;
		long health = ((Long)sortValue).longValue();
		if (health >= 256L)
		{
			health -= 256L;
			isShare = true;
		}
		if (health == 5L)
			image_name = "st_ko";
		else
		if (health == 4L)
			image_name = "st_ok";
		else
		if (health == 2L)
			image_name = "st_no_tracker";
		else
		if (health == 3L)
			image_name = "st_no_remote";
		else
		if (health == 6L)
			image_name = "st_error";
		else
			image_name = "st_stopped";
		if (isShare)
			image_name = (new StringBuilder()).append(image_name).append("_shared").toString();
		imageLoader = ImageLoader.getInstance();
		img = imageLoader.getImage(image_name);
		Rectangle cellBounds = cell.getBounds();
		if (img != null && !img.isDisposed())
		{
			Rectangle imgBounds = img.getBounds();
			gc.drawImage(img, cellBounds.x + (cellBounds.width - imgBounds.width) / 2, cellBounds.y + (cellBounds.height - imgBounds.height) / 2);
		}
		imageLoader.releaseImage(image_name);
		break MISSING_BLOCK_LABEL_268;
		Exception exception;
		exception;
		imageLoader.releaseImage(image_name);
		throw exception;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -