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

📄 traywindow.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:   TrayWindow.java

package org.gudy.azureus2.ui.swt;

import com.aelitis.azureus.core.AzureusCore;
import com.aelitis.azureus.core.AzureusCoreFactory;
import com.aelitis.azureus.ui.UIFunctions;
import com.aelitis.azureus.ui.UIFunctionsManager;
import com.aelitis.azureus.ui.common.updater.UIUpdatable;
import com.aelitis.azureus.ui.common.updater.UIUpdater;
import com.aelitis.azureus.ui.swt.UIFunctionsManagerSWT;
import com.aelitis.azureus.ui.swt.UIFunctionsSWT;
import com.aelitis.azureus.ui.swt.imageloader.ImageLoader;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.download.DownloadManager;
import org.gudy.azureus2.core3.download.DownloadManagerStats;
import org.gudy.azureus2.core3.global.GlobalManager;
import org.gudy.azureus2.core3.global.GlobalManagerListener;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.ui.swt.components.shell.ShellFactory;
import org.gudy.azureus2.ui.swt.mainwindow.MainWindow;
import org.gudy.azureus2.ui.swt.mainwindow.MenuFactory;
import org.gudy.azureus2.ui.swt.views.utils.ManagerUtils;

// Referenced classes of package org.gudy.azureus2.ui.swt:
//			Messages, Utils

public class TrayWindow
	implements GlobalManagerListener, UIUpdatable
{

	private static final String ID = "DownloadBasket/TrayWindow";
	GlobalManager globalManager;
	List managers;
	protected AEMonitor managers_mon;
	MainWindow main;
	Display display;
	Shell minimized;
	Label label;
	private Menu menu;
	private Rectangle screen;
	private int xPressed;
	private int yPressed;
	private boolean moving;

	public TrayWindow(MainWindow _main)
	{
		managers_mon = new AEMonitor("DownloadBasket/TrayWindow");
		managers = new ArrayList();
		main = _main;
		UIFunctionsSWT uif = UIFunctionsManagerSWT.getUIFunctionsSWT();
		Shell mainShell = uif != null ? uif.getMainShell() : Utils.findAnyShell();
		display = mainShell.getDisplay();
		minimized = ShellFactory.createShell(mainShell, 16384);
		minimized.setText("Vuze");
		label = new Label(minimized, 0);
		ImageLoader.getInstance().setLabelImage(label, "tray");
		final Rectangle bounds = label.getImage().getBounds();
		label.setSize(bounds.width, bounds.height);
		minimized.setSize(bounds.width + 2, bounds.height + 2);
		screen = display.getClientArea();
		if (!Constants.isOSX)
			minimized.setLocation((screen.x + screen.width) - bounds.width - 2, (screen.y + screen.height) - bounds.height - 2);
		else
			minimized.setLocation(20, 20);
		minimized.layout();
		minimized.setVisible(false);
		org.eclipse.swt.events.MouseListener mListener = new MouseAdapter() {

			final TrayWindow this$0;

			public void mouseDown(MouseEvent e)
			{
				xPressed = e.x;
				yPressed = e.y;
				moving = true;
			}

			public void mouseUp(MouseEvent e)
			{
				moving = false;
			}

			public void mouseDoubleClick(MouseEvent e)
			{
				restore();
			}

			
			{
				this$0 = TrayWindow.this;
				super();
			}
		};
		MouseMoveListener mMoveListener = new MouseMoveListener() {

			final Rectangle val$bounds;
			final TrayWindow this$0;

			public void mouseMove(MouseEvent e)
			{
				if (moving)
				{
					int dX = xPressed - e.x;
					int dY = yPressed - e.y;
					Point currentLoc = minimized.getLocation();
					int x = currentLoc.x - dX;
					int y = currentLoc.y - dY;
					if (x < 10)
						x = 0;
					if (x > screen.width - (bounds.width + 12))
						x = screen.width - (bounds.width + 2);
					if (y < 10)
						y = 0;
					if (y > screen.height - (bounds.height + 12))
						y = screen.height - (bounds.height + 2);
					minimized.setLocation(x, y);
				}
			}

			
			{
				this$0 = TrayWindow.this;
				bounds = rectangle;
				super();
			}
		};
		label.addMouseListener(mListener);
		label.addMouseMoveListener(mMoveListener);
		menu = new Menu(minimized, 64);
		label.setMenu(menu);
		MenuItem file_show = new MenuItem(menu, 0);
		Messages.setLanguageText(file_show, "TrayWindow.menu.show");
		menu.setDefaultItem(file_show);
		file_show.addListener(13, new Listener() {

			final TrayWindow this$0;

			public void handleEvent(Event e)
			{
				restore();
			}

			
			{
				this$0 = TrayWindow.this;
				super();
			}
		});
		new MenuItem(menu, 2);
		MenuFactory.addCloseDownloadBarsToMenu(menu);
		new MenuItem(menu, 2);
		MenuItem file_startalldownloads = new MenuItem(menu, 0);
		Messages.setLanguageText(file_startalldownloads, "TrayWindow.menu.startalldownloads");
		file_startalldownloads.addListener(13, new Listener() {

			final TrayWindow this$0;

			public void handleEvent(Event e)
			{
				globalManager.startAllDownloads();
			}

			
			{
				this$0 = TrayWindow.this;
				super();
			}
		});
		MenuItem file_stopalldownloads = new MenuItem(menu, 0);
		Messages.setLanguageText(file_stopalldownloads, "TrayWindow.menu.stopalldownloads");
		file_stopalldownloads.addListener(13, new Listener() {

			final TrayWindow this$0;

			public void handleEvent(Event e)
			{
				ManagerUtils.asyncStopAll();
			}

			
			{
				this$0 = TrayWindow.this;
				super();
			}
		});
		new MenuItem(menu, 2);
		MenuItem file_close = new MenuItem(menu, 0);
		Messages.setLanguageText(file_close, "TrayWindow.menu.close");
		file_close.addListener(13, new Listener() {

			final TrayWindow this$0;

			public void handleEvent(Event e)
			{
				COConfigurationManager.setParameter("Show Download Basket", false);
			}

			
			{
				this$0 = TrayWindow.this;
				super();
			}
		});
		MenuItem file_exit = new MenuItem(menu, 0);
		Messages.setLanguageText(file_exit, "TrayWindow.menu.exit");
		file_exit.addListener(13, new Listener() {

			final TrayWindow this$0;

			public void handleEvent(Event e)
			{
				main.dispose(false, false);
			}

			
			{
				this$0 = TrayWindow.this;
				super();
			}
		});
		Utils.createTorrentDropTarget(minimized, false);
		try
		{
			globalManager = AzureusCoreFactory.getSingleton().getGlobalManager();
			globalManager.addListener(this);
		}
		catch (Exception e)
		{
			Debug.out(e);
		}
	}

	public void setVisible(boolean visible)
	{
		if (visible || !COConfigurationManager.getBooleanParameter("Show Download Basket"))
		{
			minimized.setVisible(visible);
			if (!visible)
				moving = false;
		}
		try
		{
			if (visible)
				UIFunctionsManager.getUIFunctions().getUIUpdater().addUpdater(this);
			else
				UIFunctionsManager.getUIFunctions().getUIUpdater().removeUpdater(this);
		}
		catch (Exception e)
		{
			Debug.out(e);
		}
	}

	public void dispose()
	{
		minimized.dispose();
	}

	public void restore()
	{
		if (!COConfigurationManager.getBooleanParameter("Show Download Basket"))
			minimized.setVisible(false);
		UIFunctionsSWT functionsSWT = UIFunctionsManagerSWT.getUIFunctionsSWT();
		if (functionsSWT != null)
			functionsSWT.bringToFront();
		moving = false;
	}

	public void updateUI()
	{
		StringBuffer toolTip;
		String separator;
		if (minimized.isDisposed() || !minimized.isVisible())
			return;
		toolTip = new StringBuffer();
		separator = "";
		managers_mon.enter();
		for (int i = 0; i < managers.size(); i++)
		{
			DownloadManager manager = (DownloadManager)managers.get(i);
			DownloadManagerStats stats = manager.getStats();
			String name = manager.getDisplayName();
			String completed = DisplayFormatters.formatPercentFromThousands(stats.getCompleted());
			toolTip.append(separator);
			toolTip.append(name);
			toolTip.append(" -- C: ");
			toolTip.append(completed);
			toolTip.append(", D : ");
			toolTip.append(DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(stats.getDataReceiveRate(), stats.getProtocolReceiveRate()));
			toolTip.append(", U : ");
			toolTip.append(DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(stats.getDataSendRate(), stats.getProtocolSendRate()));
			separator = "\n";
		}

		managers_mon.exit();
		break MISSING_BLOCK_LABEL_215;
		Exception exception;
		exception;
		managers_mon.exit();
		throw exception;
	}

	public void downloadManagerAdded(DownloadManager created)
	{
		managers_mon.enter();
		managers.add(created);
		managers_mon.exit();
		break MISSING_BLOCK_LABEL_38;
		Exception exception;
		exception;
		managers_mon.exit();
		throw exception;
	}

	public void downloadManagerRemoved(DownloadManager removed)
	{
		managers_mon.enter();
		managers.remove(removed);
		managers_mon.exit();
		break MISSING_BLOCK_LABEL_38;
		Exception exception;
		exception;
		managers_mon.exit();
		throw exception;
	}

	public void destroyed()
	{
	}

	public void destroyInitiated()
	{
	}

	public void seedingStatusChanged(boolean flag, boolean flag1)
	{
	}

	public void updateLanguage()
	{
		MenuFactory.updateMenuText(menu);
	}

	public void setMoving(boolean moving)
	{
		this.moving = moving;
	}

	public String getUpdateUIName()
	{
		return "DownloadBasket/TrayWindow";
	}







}

⌨️ 快捷键说明

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