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

📄 mytorrentsview.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
			}
			});
			catButton.addListener(32, new Listener() {

				final Category val$category;
				final MyTorrentsView this$0;

				public void handleEvent(Event event)
				{
					Button curButton = (Button)event.widget;
					Category curCategory = (Category)curButton.getData("Category");
					List dms = curCategory.getDownloadManagers(globalManager.getDownloadManagers());
					long ttlActive = 0L;
					long ttlSize = 0L;
					long ttlRSpeed = 0L;
					long ttlSSpeed = 0L;
					int count = 0;
					Iterator iter = dms.iterator();
					do
					{
						if (!iter.hasNext())
							break;
						DownloadManager dm = (DownloadManager)iter.next();
						if (isInCategory(dm, currentCategory))
						{
							count++;
							if (dm.getState() == 50 || dm.getState() == 60)
								ttlActive++;
							ttlSize += dm.getSize();
							ttlRSpeed += dm.getStats().getDataReceiveRate();
							ttlSSpeed += dm.getStats().getDataSendRate();
						}
					} while (true);
					String up_details = "";
					String down_details = "";
					if (category.getType() != 1)
					{
						String up_str = MessageText.getString("GeneralView.label.maxuploadspeed");
						String down_str = MessageText.getString("GeneralView.label.maxdownloadspeed");
						String unlimited_str = MessageText.getString("MyTorrentsView.menu.setSpeed.unlimited");
						int up_speed = category.getUploadSpeed();
						int down_speed = category.getDownloadSpeed();
						up_details = (new StringBuilder()).append(up_str).append(": ").append(up_speed != 0 ? DisplayFormatters.formatByteCountToKiBEtc(up_speed) : unlimited_str).toString();
						down_details = (new StringBuilder()).append(down_str).append(": ").append(down_speed != 0 ? DisplayFormatters.formatByteCountToKiBEtc(down_speed) : unlimited_str).toString();
					}
					if (count == 0)
					{
						curButton.setToolTipText((new StringBuilder()).append(down_details).append("\n").append(up_details).append("\nTotal: 0").toString());
						return;
					} else
					{
						curButton.setToolTipText((new StringBuilder()).append(up_details.length() != 0 ? (new StringBuilder()).append(down_details).append("\n").append(up_details).append("\n").toString() : "").append("Total: ").append(count).append("\n").append("Downloading/Seeding: ").append(ttlActive).append("\n").append("\n").append("Speed: ").append(DisplayFormatters.formatByteCountToKiBEtcPerSec(ttlRSpeed / (long)count)).append("/").append(DisplayFormatters.formatByteCountToKiBEtcPerSec(ttlSSpeed / (long)count)).append("\n").append("Size: ").append(DisplayFormatters.formatByteCountToKiBEtc(ttlSize)).toString());
						return;
					}
				}

			
			{
				this$0 = MyTorrentsView.this;
				category = category1;
				super();
			}
			});
			final DropTarget tabDropTarget = new DropTarget(catButton, 23);
			Transfer types[] = {
				TextTransfer.getInstance()
			};
			tabDropTarget.setTransfer(types);
			tabDropTarget.addDropListener(new DropTargetAdapter() {

				final Button val$catButton;
				final MyTorrentsView this$0;

				public void dragOver(DropTargetEvent e)
				{
					if (drag_drop_line_start >= 0)
						e.detail = 2;
					else
						e.detail = 0;
				}

				public void drop(DropTargetEvent e)
				{
					e.detail = 0;
					if (drag_drop_line_start >= 0)
					{
						drag_drop_line_start = -1;
						drag_drop_rows = null;
						TorrentUtil.assignToCategory(tv.getSelectedDataSources().toArray(), (Category)catButton.getData("Category"));
					}
				}

			
			{
				this$0 = MyTorrentsView.this;
				catButton = button;
				super();
			}
			});
			catButton.addDisposeListener(new DisposeListener() {

				final DropTarget val$tabDropTarget;
				final MyTorrentsView this$0;

				public void widgetDisposed(DisposeEvent e)
				{
					if (tabDropTarget != null && !tabDropTarget.isDisposed())
						tabDropTarget.dispose();
				}

			
			{
				this$0 = MyTorrentsView.this;
				tabDropTarget = droptarget;
				super();
			}
			});
			final Menu menu = new Menu(getComposite().getShell(), 8);
			catButton.setMenu(menu);
			menu.addMenuListener(new MenuListener() {

				boolean bShown;
				final Menu val$menu;
				final Category val$category;
				final Button val$catButton;
				final MyTorrentsView this$0;

				public void menuHidden(MenuEvent e)
				{
					bShown = false;
					if (Constants.isOSX)
					{
						return;
					} else
					{
						e.widget.getDisplay().asyncExec(new AERunnable() {

							final 11 this$1;

							public void runSupport()
							{
								if (bShown || menu.isDisposed())
									return;
								MenuItem items[] = menu.getItems();
								for (int i = 0; i < items.length; i++)
									items[i].dispose();

							}

					
					{
						this$1 = 11.this;
						super();
					}
						});
						return;
					}
				}

				public void menuShown(MenuEvent e)
				{
					MenuItem items[] = menu.getItems();
					for (int i = 0; i < items.length; i++)
						items[i].dispose();

					bShown = true;
					if (category.getType() == 0)
					{
						MenuItem itemDelete = new MenuItem(menu, 8);
						Messages.setLanguageText(itemDelete, "MyTorrentsView.menu.category.delete");
						menu.setDefaultItem(itemDelete);
						itemDelete.addListener(13, new Listener() {

							final 11 this$1;

							public void handleEvent(Event event)
							{
								Category catToDelete = (Category)catButton.getData("Category");
								if (catToDelete != null)
								{
									List managers = catToDelete.getDownloadManagers(globalManager.getDownloadManagers());
									DownloadManager dms[] = (DownloadManager[])(DownloadManager[])managers.toArray(new DownloadManager[managers.size()]);
									for (int i = 0; i < dms.length; i++)
										dms[i].getDownloadState().setCategory(null);

									if (currentCategory == catToDelete)
										activateCategory(CategoryManager.getCategory(1));
									else
										activateCategory(currentCategory);
									CategoryManager.removeCategory(catToDelete);
								}
							}

					
					{
						this$1 = 11.this;
						super();
					}
						});
					}
					if (category.getType() != 1)
					{
						long maxDownload = COConfigurationManager.getIntParameter("Max Download Speed KBs", 0) * 1024;
						long maxUpload = COConfigurationManager.getIntParameter("Max Upload Speed KBs", 0) * 1024;
						int down_speed = category.getDownloadSpeed();
						int up_speed = category.getUploadSpeed();
						ViewUtils.addSpeedMenu(menu.getShell(), menu, true, true, false, down_speed == 0, down_speed, down_speed, maxDownload, false, up_speed == 0, up_speed, up_speed, maxUpload, 1, new ViewUtils.SpeedAdapter() {

							final 11 this$1;

							public void setDownSpeed(int val)
							{
								category.setDownloadSpeed(val);
							}

							public void setUpSpeed(int val)
							{
								category.setUploadSpeed(val);
							}

					
					{
						this$1 = 11.this;
						super();
					}
						});
					}
					List managers = category.getDownloadManagers(globalManager.getDownloadManagers());
					final DownloadManager dms[] = (DownloadManager[])(DownloadManager[])managers.toArray(new DownloadManager[managers.size()]);
					boolean start = false;
					boolean stop = false;
					for (int i = 0; i < dms.length; i++)
					{
						DownloadManager dm = dms[i];
						stop = stop || ManagerUtils.isStopable(dm);
						start = start || ManagerUtils.isStartable(dm);
					}

					MenuItem itemQueue = new MenuItem(menu, 8);
					Messages.setLanguageText(itemQueue, "MyTorrentsView.menu.queue");
					Utils.setMenuItemImage(itemQueue, "start");
					itemQueue.addListener(13, new Listener() {

						final DownloadManager val$dms[];
						final 11 this$1;

						public void handleEvent(Event event)
						{
							TorrentUtil.queueTorrents(dms, menu.getShell());
						}

					
					{
						this$1 = 11.this;
						dms = adownloadmanager;
						super();
					}
					});
					itemQueue.setEnabled(start);
					MenuItem itemStop = new MenuItem(menu, 8);
					Messages.setLanguageText(itemStop, "MyTorrentsView.menu.stop");
					Utils.setMenuItemImage(itemStop, "stop");
					itemStop.addListener(13, new Listener() {

						final DownloadManager val$dms[];
						final 11 this$1;

						public void handleEvent(Event event)
						{
							TorrentUtil.stopTorrents(dms, menu.getShell());
						}

					
					{
						this$1 = 11.this;
						dms = adownloadmanager;
						super();
					}
					});
					itemStop.setEnabled(stop);
					PluginInterface bpi = StaticUtilities.getDefaultPluginInterface().getPluginManager().getPluginInterfaceByClass(com/aelitis/azureus/plugins/net/buddy/BuddyPlugin);
					int cat_type = category.getType();
					if (bpi != null && cat_type != 2)
					{
						BuddyPlugin buddy_plugin = (BuddyPlugin)bpi.getPlugin();
						if (buddy_plugin.isEnabled())
						{
							Menu share_menu = new Menu(menu.getShell(), 4);
							MenuItem share_item = new MenuItem(menu, 64);
							Messages.setLanguageText(share_item, "azbuddy.ui.menu.cat.share");
							share_item.setMenu(share_menu);
							List buddies = buddy_plugin.getBuddies();
							Iterator i$ = buddies.iterator();
							do
							{
								if (!i$.hasNext())
									break;
								final BuddyPluginBuddy buddy = (BuddyPluginBuddy)i$.next();
								if (buddy.getNickName() != null)
								{
									final String cname;
									if (cat_type == 1)
										cname = "All";
									else
										cname = category.getName();
									final boolean auth = buddy.isLocalRSSCategoryAuthorised(cname);
									MenuItem itemShare = new MenuItem(share_menu, 32);
									itemShare.setText(buddy.getName());
									itemShare.setSelection(auth);
									itemShare.addListener(13, new Listener() {

										final boolean val$auth;
										final BuddyPluginBuddy val$buddy;
										final String val$cname;
										final 11 this$1;

										public void handleEvent(Event event)
										{
											if (auth)
												buddy.removeLocalAuthorisedRSSCategory(cname);
											else
												buddy.addLocalAuthorisedRSSCategory(cname);
										}

					
					{
						this$1 = 11.this;
						auth = flag;
						buddy = buddypluginbuddy;
						cname = s;
						super();
					}
									});
								}
							} while (true);
						}
					}
					MenuItem itemOptions = new MenuItem(menu, 8);
					Messages.setLanguageText(itemOptions, "MainWindow.menu.view.configuration");
					itemOptions.addListener(13, new Listener() {

						final DownloadManager val$dms[];
						final 11 this$1;

						public void handleEvent(Event event)
						{
							UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
							uiFunctions.openView(6, dms);
						}

					
					{
						this$1 = 11.this;
						dms = adownloadmanager;
						super();
					}
					});
					if (dms.length == 0)
						itemOptions.setEnabled(false);
				}

			
			{
				this$0 = MyTorrentsView.this;
				menu = menu1;
				category = category1;
				catButton = button;
				super();
				bShown = false;
			}
			});
		}

		cCategories.layout();
		getComposite().layout();
	}

	public boolean isOurDownloadManager(DownloadManager dm)
	{
		if (!isInCategory(dm, currentCategory))
			return false;
		boolean bCompleted = dm.isDownloadComplete(bDNDalwaysIncomplete);
		boolean bOurs = bCompleted && isSeedingView || !bCompleted && !isSeedingView;
		if (bOurs)
			bOurs = filterCheck(dm);
		return bOurs;
	}

	public boolean filterCheck(DownloadManager dm)
	{
		boolean bOurs = true;
		if (sLastSearch.length() > 0)
			try
			{
				String names[][] = {
					{
						"", dm.getDisplayName()
					}, {
						"t:", dm.getTorrent().getAnnounceURL().getHost()
					}, {
						"st:", (new StringBuilder()).append("").append(dm.getState()).toString()
					}
				};
				String name = names[0][1];
				String tmpSearch = sLastSearch;
				for (int i = 0; i < names.length; i++)
					if (tmpSearch.startsWith(names[i][0]))
					{
						tmpSearch = tmpSearch.substring(names[i][0].length());
						name = names[i][1];
					}

				String s = bRegexSearch ? tmpSearch : (new StringBuilder()).append("\\Q").append(tmpSearch.replaceAll("[|;]", "\\\\E|\\\\Q")).append("\\E").toString();
				Pattern pattern = Pattern.compile(s, 2);
				if (!pattern.matcher(name).find())
					bOurs = false;
			}
			catch (Exception e) { }
		return bOurs;
	}

	public void selected(TableRowCore rows[])
	{
		updateSelectedContent();
		refreshTorrentMenu();
		refreshIconBar();
	}

	public void deselected(TableRowCore rows[])
	{
		updateSelectedContent();
		refreshTorrentMenu();
		refreshIconBar();
	}

	public void focusChanged(TableRowCore focus)
	{
		refreshIconBar();
		refreshTorrentMenu();
	}

	public void mouseEnter(TableRowCore tablerowcore)
	{
	}

	public void mouseExit(TableRowCore tablerowcore)
	{
	}

	public void updateSelectedContent()
	{
		if (cTablePanel == null || cTablePanel.isDisposed() || !cTablePanel.isVisible())
			return;
		DownloadManager dms[] = getSelectedDownloads();
		ISelectedContent sc[] = new ISelectedContent[dms.length];
		int pos = 0;
		for (int i = 0; i < dms.length; i++)
		{
			DownloadManager dm = dms[i];
			if (dm == null)
				continue;
			try
			{
				sc[pos] = new SelectedContent(dm);
				pos++;
			}
			catch (Exception e) { }
		}

		if (pos != dms.length)
		{
			ISelectedContent sc_temp[] = new ISelectedContent[pos];
			System.arraycopy(sc, 0, sc_temp, 0, pos);
			sc = sc_temp;
		}
		SelectedContentManager.changeCurrentlySelectedContent(tv.getTableID(), sc, tv);
	}

	private void refreshIconBar()
	{
		computePossibleActions();
		UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
		if (uiFunctions != null)
			uiFunctions.refreshIconBar();
	}

	private void refreshTorrentMenu()
	{
		UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
		if (uiFunctions != null && (uiFunctions instanceof UIFunctionsSWT))
			((UIFunctionsSWT)uiFunctions).refreshTorrentMenu();
	}

	public DownloadManager[] getSelectedDownloads()
	{
		Object data_sources[] = tv.getSelectedDataSources().toArray();
		DownloadManager result[] = new DownloadManager[data_sources.length];
		System.arraycopy(((Object) (data_sources)), 0, result, 0, result.length);
		return result;
	}

	public void defaultSelected(TableRowCore rows[], int keyMask)
	{
		if (defaultSelectedListener != null)
		{
			defaultSelectedListener.defaultSelected(rows, keyMask);
			return;
		} else
		{
			showSelectedDetails();
			return;
		}
	}

	private void showSelectedDetails()
	{
		Object dm_sources[] = tv.getSelectedDataSources().toArray();
		UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
		for (int i = 0; i < dm_sources.length; i++)
			if (dm_sources[i] != null && uiFunctions != null)
				uiFunctions.openView(5, (DownloadManager)dm_sources[i]);

	}

	public void overrideDefaultSelected(TableSelectionListener defaultSelectedListener)
	{
		this.defaultSelectedListener = defaultSelectedListener;
	}

	public void addThisColumnSubMenu(String sColumnName, Menu menuThisColumn)
	{
		if (sColumnName.equals("health"))
		{
			MenuItem item = new MenuItem(menuThisColumn, 8);
			Messages.setLanguageText(item, "MyTorrentsView.menu.health");
			Utils.setMenuItemImage(item, "st_explain");
			item.addListener(13, new Listener() {

				final MyTorrentsView this$0;

				public void handleEvent(Event e)

⌨️ 快捷键说明

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