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

📄 mytorrentsview.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
// 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:   MyTorrentsView.java

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

import com.aelitis.azureus.core.AzureusCore;
import com.aelitis.azureus.plugins.net.buddy.BuddyPlugin;
import com.aelitis.azureus.plugins.net.buddy.BuddyPluginBuddy;
import com.aelitis.azureus.ui.UIFunctions;
import com.aelitis.azureus.ui.UIFunctionsManager;
import com.aelitis.azureus.ui.common.table.*;
import com.aelitis.azureus.ui.selectedcontent.*;
import com.aelitis.azureus.ui.swt.UIFunctionsSWT;
import com.aelitis.azureus.ui.swt.imageloader.ImageLoader;
import java.net.URL;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.category.*;
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.*;
import org.gudy.azureus2.core3.global.GlobalManager;
import org.gudy.azureus2.core3.global.GlobalManagerListener;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.logging.*;
import org.gudy.azureus2.core3.torrent.TOTorrent;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.plugins.PluginInterface;
import org.gudy.azureus2.plugins.PluginManager;
import org.gudy.azureus2.plugins.download.DownloadTypeComplete;
import org.gudy.azureus2.plugins.download.DownloadTypeIncomplete;
import org.gudy.azureus2.plugins.utils.StaticUtilities;
import org.gudy.azureus2.ui.swt.*;
import org.gudy.azureus2.ui.swt.help.HealthHelpWindow;
import org.gudy.azureus2.ui.swt.mainwindow.Colors;
import org.gudy.azureus2.ui.swt.mainwindow.TorrentOpener;
import org.gudy.azureus2.ui.swt.minibar.DownloadBar;
import org.gudy.azureus2.ui.swt.shells.InputShell;
import org.gudy.azureus2.ui.swt.views.table.TableViewSWT;
import org.gudy.azureus2.ui.swt.views.table.TableViewSWTMenuFillListener;
import org.gudy.azureus2.ui.swt.views.table.TableViewSWTPanelCreator;
import org.gudy.azureus2.ui.swt.views.table.impl.TableViewSWTImpl;
import org.gudy.azureus2.ui.swt.views.table.impl.TableViewTab;
import org.gudy.azureus2.ui.swt.views.utils.ManagerUtils;

// Referenced classes of package org.gudy.azureus2.ui.swt.views:
//			ViewUtils

public class MyTorrentsView extends TableViewTab
	implements GlobalManagerListener, ParameterListener, DownloadManagerListener, CategoryManagerListener, CategoryListener, KeyListener, TableLifeCycleListener, TableViewSWTPanelCreator, TableSelectionListener, TableViewSWTMenuFillListener, TableRefreshListener, TableCountChangeListener
{

	private static final LogIDs LOGID;
	private static final int ASYOUTYPE_MODE_FIND = 0;
	private static final int ASYOUTYPE_MODE_FILTER = 1;
	private static final int ASYOUTYPE_MODE = 1;
	private static final int ASYOUTYPE_UPDATEDELAY = 300;
	private static final boolean EXPERIMENT = false;
	private AzureusCore azureus_core;
	private GlobalManager globalManager;
	protected boolean isSeedingView;
	private Composite cTablePanel;
	private Font fontButton;
	private Composite cCategories;
	private ControlAdapter catResizeAdapter;
	private DragSource dragSource;
	private DropTarget dropTarget;
	private Composite cHeader;
	private Label lblHeader;
	private Text txtFilter;
	private Label lblX;
	private Category currentCategory;
	private int drag_drop_line_start;
	private TableRowCore drag_drop_rows[];
	private TimerEvent searchUpdateEvent;
	private String sLastSearch;
	private long lLastSearchTime;
	private boolean bRegexSearch;
	private boolean bDNDalwaysIncomplete;
	private TableViewSWT tv;
	private Composite cTableParentPanel;
	protected boolean viewActive;
	private boolean forceHeaderVisible;
	private TableSelectionListener defaultSelectedListener;
	private Composite cFilterArea;
	private boolean top;
	private boolean bottom;
	private boolean up;
	private boolean down;
	private boolean run;
	private boolean start;
	private boolean stop;
	private boolean remove;
	private boolean refreshingTableLabel;

	public MyTorrentsView()
	{
		fontButton = null;
		dragSource = null;
		dropTarget = null;
		cHeader = null;
		lblHeader = null;
		txtFilter = null;
		lblX = null;
		drag_drop_line_start = -1;
		drag_drop_rows = null;
		sLastSearch = "";
		bRegexSearch = false;
		forceHeaderVisible = false;
		refreshingTableLabel = false;
	}

	public MyTorrentsView(AzureusCore _azureus_core, String tableID, boolean isSeedingView, TableColumnCore basicItems[])
	{
		fontButton = null;
		dragSource = null;
		dropTarget = null;
		cHeader = null;
		lblHeader = null;
		txtFilter = null;
		lblX = null;
		drag_drop_line_start = -1;
		drag_drop_rows = null;
		sLastSearch = "";
		bRegexSearch = false;
		forceHeaderVisible = false;
		refreshingTableLabel = false;
		init(_azureus_core, tableID, isSeedingView, basicItems);
	}

	public void init(AzureusCore _azureus_core, String tableID, boolean isSeedingView, TableColumnCore basicItems[])
	{
		this.isSeedingView = isSeedingView;
		tv = createTableView(tableID, basicItems);
		setTableView(tv);
		tv.setRowDefaultIconSize(new Point(16, 16));
		if (getRowDefaultHeight() > 0)
			tv.setRowDefaultHeight(getRowDefaultHeight());
		azureus_core = _azureus_core;
		globalManager = azureus_core.getGlobalManager();
		currentCategory = CategoryManager.getCategory(1);
		tv.addLifeCycleListener(this);
		tv.setMainPanelCreator(this);
		tv.addSelectionListener(this, false);
		tv.addMenuFillListener(this);
		tv.addRefreshListener(this, false);
		tv.addCountChangeListener(this);
		tv.setDataSourceType(((Class) (isSeedingView ? org/gudy/azureus2/plugins/download/DownloadTypeComplete : org/gudy/azureus2/plugins/download/DownloadTypeIncomplete)));
	}

	public void tableViewInitialized()
	{
		tv.addKeyListener(this);
		createTabs();
		createDragDrop();
		COConfigurationManager.addAndFireParameterListeners(new String[] {
			"DND Always In Incomplete", "Confirm Data Delete"
		}, this);
		if (currentCategory != null)
			currentCategory.addCategoryListener(this);
		CategoryManager.addCategoryManagerListener(this);
		globalManager.addListener(this, false);
		Object dms[] = globalManager.getDownloadManagers().toArray();
		for (int i = 0; i < dms.length; i++)
		{
			DownloadManager dm = (DownloadManager)dms[i];
			dm.addListener(this);
			if (!isOurDownloadManager(dm))
				dms[i] = null;
		}

		tv.addDataSources(dms);
		tv.processDataSourceQueue();
		cTablePanel.layout();
	}

	public void tableViewDestroyed()
	{
		tv.removeKeyListener(this);
		Utils.execSWTThread(new AERunnable() {

			final MyTorrentsView this$0;

			public void runSupport()
			{
				try
				{
					Utils.disposeSWTObjects(new Object[] {
						dragSource, dropTarget, fontButton
					});
					dragSource = null;
					dropTarget = null;
					fontButton = null;
				}
				catch (Exception e)
				{
					Debug.out(e);
				}
			}

			
			{
				this$0 = MyTorrentsView.this;
				super();
			}
		});
		Object dms[] = globalManager.getDownloadManagers().toArray();
		for (int i = 0; i < dms.length; i++)
		{
			DownloadManager dm = (DownloadManager)dms[i];
			dm.removeListener(this);
		}

		if (currentCategory != null)
			currentCategory.removeCategoryListener(this);
		CategoryManager.removeCategoryManagerListener(this);
		globalManager.removeListener(this);
		COConfigurationManager.removeParameterListener("DND Always In Incomplete", this);
		COConfigurationManager.removeParameterListener("Confirm Data Delete", this);
		COConfigurationManager.removeParameterListener("User Mode", this);
	}

	public Composite createTableViewPanel(Composite composite)
	{
		composite.addListener(26, new Listener() {

			final MyTorrentsView this$0;

			public void handleEvent(Event event)
			{
				viewActive = true;
				updateSelectedContent();
				refreshIconBar();
			}

			
			{
				this$0 = MyTorrentsView.this;
				super();
			}
		});
		composite.addListener(27, new Listener() {

			final MyTorrentsView this$0;

			public void handleEvent(Event event)
			{
				viewActive = false;
			}

			
			{
				this$0 = MyTorrentsView.this;
				super();
			}
		});
		cTableParentPanel = new Composite(composite, 0);
		GridLayout layout = new GridLayout();
		layout.horizontalSpacing = 0;
		layout.verticalSpacing = 0;
		layout.marginHeight = 0;
		layout.marginWidth = 0;
		cTableParentPanel.setLayout(layout);
		if (composite.getLayout() instanceof GridLayout)
			cTableParentPanel.setLayoutData(new GridData(1808));
		cTablePanel = new Composite(cTableParentPanel, 0);
		cTablePanel.setBackground(composite.getDisplay().getSystemColor(25));
		cTablePanel.setForeground(composite.getDisplay().getSystemColor(24));
		GridData gridData = new GridData(1808);
		cTablePanel.setLayoutData(gridData);
		layout = new GridLayout(1, false);
		layout.marginHeight = 0;
		layout.marginWidth = 0;
		layout.verticalSpacing = 0;
		layout.horizontalSpacing = 0;
		cTablePanel.setLayout(layout);
		cTablePanel.layout();
		return cTablePanel;
	}

	public void setForceHeaderVisible(boolean forceHeaderVisible)
	{
		this.forceHeaderVisible = forceHeaderVisible;
		if (cTablePanel != null && !cTablePanel.isDisposed())
			createTabs();
	}

	private void createTabs()
	{
		Category categories[] = CategoryManager.getCategories();
		Arrays.sort(categories);
		boolean showCat = sLastSearch.length() > 0;
		if (!showCat)
		{
			int i = 0;
			do
			{
				if (i >= categories.length)
					break;
				if (categories[i].getType() == 0)
				{
					showCat = true;
					break;
				}
				i++;
			} while (true);
		}
		boolean show = showCat || forceHeaderVisible;
		if (!showCat && cCategories != null && !cCategories.isDisposed())
		{
			Control controls[] = cCategories.getChildren();
			for (int i = 0; i < controls.length; i++)
				controls[i].dispose();

		}
		if (show)
		{
			if (cCategories == null)
			{
				Composite parent = cTableParentPanel;
				cHeader = new Composite(parent, 0);
				GridData gridData = new GridData(768);
				gridData.horizontalIndent = 5;
				cHeader.setLayoutData(gridData);
				GridLayout layout = new GridLayout();
				layout.numColumns = 3;
				layout.marginHeight = 0;
				layout.marginWidth = 0;
				layout.horizontalSpacing = 2;
				layout.verticalSpacing = 0;
				cHeader.setLayout(layout);
				lblHeader = new Label(cHeader, 64);
				gridData = new GridData();
				lblHeader.setLayoutData(gridData);
				updateTableLabel();
				cFilterArea = new Composite(cHeader, 0);
				gridData = new GridData(768);
				cFilterArea.setLayoutData(gridData);
				layout = new GridLayout();
				layout.numColumns = 5;
				cFilterArea.setLayout(layout);
				cCategories = new Composite(cHeader, 0);
				gridData = new GridData(128);
				cCategories.setLayoutData(gridData);
				RowLayout rowLayout = new RowLayout();
				rowLayout.marginTop = 0;
				rowLayout.marginBottom = 0;
				rowLayout.marginLeft = 3;
				rowLayout.marginRight = 0;
				rowLayout.spacing = 0;
				rowLayout.wrap = true;
				new Label(cCategories, 0);
				cCategories.setLayout(rowLayout);
				Label lblSep = new Label(cFilterArea, 514);
				gridData = new GridData(1040);
				gridData.heightHint = 5;
				lblSep.setLayoutData(gridData);
				Label lblFilter = new Label(cFilterArea, 64);
				gridData = new GridData(1);
				lblFilter.setLayoutData(gridData);
				Messages.setLanguageText(lblFilter, "MyTorrentsView.filter");
				lblX = new Label(cFilterArea, 64);
				Messages.setLanguageTooltip(lblX, "MyTorrentsView.clearFilter.tooltip");
				gridData = new GridData(128);
				lblX.setLayoutData(gridData);
				ImageLoader.getInstance().setLabelImage(lblX, "smallx-gray");
				lblX.setData("ImageID", "smallx-gray");
				lblX.addMouseListener(new MouseAdapter() {

					final MyTorrentsView this$0;

					public void mouseUp(MouseEvent e)
					{
						if (e.y <= 10)
						{
							sLastSearch = "";
							updateLastSearch();
							cFilterArea.setVisible(false);
						}
					}

			
			{
				this$0 = MyTorrentsView.this;
				super();
			}
				});
				txtFilter = new Text(cFilterArea, 2048);
				Messages.setLanguageTooltip(txtFilter, "MyTorrentsView.filter.tooltip");
				txtFilter.addKeyListener(this);
				gridData = new GridData(768);
				txtFilter.setLayoutData(gridData);
				txtFilter.addModifyListener(new ModifyListener() {

					final MyTorrentsView this$0;

					public void modifyText(ModifyEvent e)
					{
						sLastSearch = ((Text)e.widget).getText();
						updateLastSearch();
					}

			
			{
				this$0 = MyTorrentsView.this;
				super();
			}
				});
				txtFilter.addKeyListener(new KeyAdapter() {

					final MyTorrentsView this$0;

					public void keyPressed(KeyEvent e)
					{
						if (e.keyCode == 0x1000002)
						{
							tv.setFocus();
							e.doit = false;
						} else
						if (e.character == '\r')
						{
							if (searchUpdateEvent != null)
								searchUpdateEvent.cancel();
							searchUpdateEvent = null;
							activateCategory(currentCategory);
						}
					}

			
			{
				this$0 = MyTorrentsView.this;
				super();
			}
				});
				lblSep = new Label(cFilterArea, 514);
				gridData = new GridData(1040);
				gridData.heightHint = 5;
				lblSep.setLayoutData(gridData);
				cHeader.moveAbove(null);
				parent.layout(true);
			} else
			{
				Control controls[] = cCategories.getChildren();
				for (int i = 0; i < controls.length; i++)
					controls[i].dispose();

			}
			cFilterArea.setVisible(showCat);
			if (showCat)
				buildCat(categories);
		}
	}

	private void buildCat(Category categories[])
	{
		int iFontPixelsHeight = 11;
		int iFontPointHeight = (iFontPixelsHeight * 72) / cCategories.getDisplay().getDPI().y;
		for (int i = 0; i < categories.length; i++)
		{
			final Category category = categories[i];
			final Button catButton = new Button(cCategories, 2);
			catButton.addKeyListener(this);
			if (i == 0 && fontButton == null)
			{
				Font f = catButton.getFont();
				FontData fd = f.getFontData()[0];
				fd.setHeight(iFontPointHeight);
				fontButton = new Font(cCategories.getDisplay(), fd);
			}
			catButton.setText("|");
			catButton.setFont(fontButton);
			catButton.pack(true);
			if (catButton.computeSize(100, -1).y > 0)
			{
				RowData rd = new RowData();
				rd.height = (catButton.computeSize(100, -1).y - 2) + catButton.getBorderWidth() * 2;
				catButton.setLayoutData(rd);
			}
			String name = category.getName();
			if (category.getType() == 0)
				catButton.setText(name);
			else
				Messages.setLanguageText(catButton, name);
			catButton.setData("Category", category);
			if (category == currentCategory)
				catButton.setSelection(true);
			catButton.addSelectionListener(new SelectionAdapter() {

				final MyTorrentsView this$0;

				public void widgetSelected(SelectionEvent e)
				{
					Button curButton = (Button)e.widget;
					boolean isEnabled = curButton.getSelection();
					Control controls[] = cCategories.getChildren();
					if (!isEnabled)
					{
						int i = 0;
						do
						{
							if (i >= controls.length)
								break;
							if (controls[i] instanceof Button)
							{
								curButton = (Button)controls[i];
								break;
							}
							i++;
						} while (true);
					}
					for (int i = 0; i < controls.length; i++)
					{
						if (!(controls[i] instanceof Button))
							continue;
						Button b = (Button)controls[i];
						if (b != curButton && b.getSelection())
						{
							b.setSelection(false);
							continue;
						}
						if (b == curButton && !b.getSelection())
							b.setSelection(true);
					}

					activateCategory((Category)curButton.getData("Category"));
				}

			
			{
				this$0 = MyTorrentsView.this;
				super();

⌨️ 快捷键说明

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