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

📄 nameitem.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:   NameItem.java

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

import com.aelitis.azureus.core.AzureusCoreOperation;
import com.aelitis.azureus.core.AzureusCoreOperationTask;
import java.io.File;
import java.io.IOException;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.MessageBox;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.config.ParameterListener;
import org.gudy.azureus2.core3.disk.DiskManagerFileInfo;
import org.gudy.azureus2.core3.download.DownloadManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.core3.util.FileUtil;
import org.gudy.azureus2.plugins.ui.menus.MenuItem;
import org.gudy.azureus2.plugins.ui.menus.MenuItemListener;
import org.gudy.azureus2.plugins.ui.tables.*;
import org.gudy.azureus2.ui.swt.ImageRepository;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.debug.ObfusticateCellText;
import org.gudy.azureus2.ui.swt.views.table.TableCellSWT;
import org.gudy.azureus2.ui.swt.views.table.utils.CoreTableColumn;

public class NameItem extends CoreTableColumn
	implements TableCellLightRefreshListener, ObfusticateCellText, TableCellDisposeListener
{

	private static boolean bShowIcon;
	final TableContextMenuItem menuItem = addContextMenuItem("FilesView.name.fastRename");

	public NameItem()
	{
		super("name", 1, -2, 300, "Files");
		setInplaceEdit(true);
		setType(1);
		menuItem.setStyle(2);
		menuItem.setData(Boolean.valueOf(isInplaceEdit()));
		menuItem.addMultiListener(new MenuItemListener() {

			final NameItem this$0;

			public void selected(MenuItem menu, Object target)
			{
				menu.setData(Boolean.valueOf(!isInplaceEdit()));
				setInplaceEdit(!isInplaceEdit());
			}

			
			{
				this$0 = NameItem.this;
				super();
			}
		});
	}

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

	public void postConfigLoad()
	{
		setInplaceEdit(getUserData("noInplaceEdit") == null);
		menuItem.setData(Boolean.valueOf(isInplaceEdit()));
	}

	public void preConfigSave()
	{
		if (isInplaceEdit())
			removeUserData("noInplaceEdit");
		else
			setUserData("noInplaceEdit", new Integer(1));
	}

	public void refresh(TableCell cell, boolean sortOnlyRefresh)
	{
		DiskManagerFileInfo fileInfo = (DiskManagerFileInfo)cell.getDataSource();
		String name = fileInfo != null ? fileInfo.getFile(true).getName() : "";
		if (name == null)
			name = "";
		if ((cell.setText(name) || !cell.isValid()) && bShowIcon && !sortOnlyRefresh)
		{
			Image icon;
			if (fileInfo == null)
				icon = null;
			else
				icon = ImageRepository.getPathIcon(fileInfo.getFile(true).getPath(), false, false);
			((TableCellSWT)cell).setIcon(icon);
		}
	}

	public void refresh(TableCell cell)
	{
		refresh(cell, false);
	}

	public String getObfusticatedText(TableCell cell)
	{
		DiskManagerFileInfo fileInfo = (DiskManagerFileInfo)cell.getDataSource();
		String name = fileInfo != null ? Debug.secretFileName(fileInfo.getFile(true).getName()) : "";
		if (name == null)
			name = "";
		return name;
	}

	public void dispose(TableCell tablecell)
	{
	}

	private void disposeCellIcon(TableCell cell)
	{
		Image img = ((TableCellSWT)cell).getIcon();
		if (img != null)
		{
			((TableCellSWT)cell).setIcon(null);
			if (!img.isDisposed())
				img.dispose();
		}
	}

	public boolean inplaceValueSet(TableCell cell, String value, boolean finalEdit)
	{
		if (value.equalsIgnoreCase(cell.getText()) || "".equals(value) || "".equals(cell.getText()))
			return true;
		final DiskManagerFileInfo fileInfo = (DiskManagerFileInfo)cell.getDataSource();
		final File target;
		try
		{
			target = (new File(fileInfo.getFile(true).getParentFile(), value)).getCanonicalFile();
		}
		catch (IOException e)
		{
			return false;
		}
		if (!finalEdit)
			return !target.exists();
		if (target.exists())
			return false;
		final boolean result[] = {
			false
		};
		boolean paused = fileInfo.getDownloadManager().pause();
		FileUtil.runAsTask(new AzureusCoreOperationTask() {

			final boolean val$result[];
			final DiskManagerFileInfo val$fileInfo;
			final File val$target;
			final NameItem this$0;

			public void run(AzureusCoreOperation operation)
			{
				result[0] = fileInfo.setLink(target);
			}

			
			{
				this$0 = NameItem.this;
				result = aflag;
				fileInfo = diskmanagerfileinfo;
				target = file;
				super();
			}
		});
		if (paused)
			fileInfo.getDownloadManager().resume();
		if (!result[0])
		{
			MessageBox mb = new MessageBox(Utils.findAnyShell(), 33);
			mb.setText(MessageText.getString("FilesView.rename.failed.title"));
			mb.setMessage(MessageText.getString("FilesView.rename.failed.text"));
			mb.open();
		}
		return true;
	}

	static 
	{
		COConfigurationManager.addAndFireParameterListener("NameColumn.showProgramIcon", new ParameterListener() {

			public void parameterChanged(String parameterName)
			{
				NameItem.bShowIcon = COConfigurationManager.getBooleanParameter("NameColumn.showProgramIcon");
			}

		});
	}

}

⌨️ 快捷键说明

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