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

📄 mytorrentsview.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
		tv.columnInvalidate("#");
		tv.refreshTable(bForceSort);
	}

	private void moveSelectedTorrentsUp()
	{
		Object dataSources[] = tv.getSelectedDataSources().toArray();
		Arrays.sort(dataSources, new Comparator() {

			final MyTorrentsView this$0;

			public int compare(Object a, Object b)
			{
				return ((DownloadManager)a).getPosition() - ((DownloadManager)b).getPosition();
			}

			
			{
				this$0 = MyTorrentsView.this;
				super();
			}
		});
		for (int i = 0; i < dataSources.length; i++)
		{
			DownloadManager dm = (DownloadManager)dataSources[i];
			if (dm.getGlobalManager().isMoveableUp(dm))
				dm.getGlobalManager().moveUp(dm);
		}

		boolean bForceSort = tv.getSortColumn().getName().equals("#");
		tv.columnInvalidate("#");
		tv.refreshTable(bForceSort);
	}

	private void moveSelectedTorrents(int by)
	{
		Object dataSources[] = tv.getSelectedDataSources().toArray();
		if (dataSources.length <= 0)
			return;
		int newPositions[] = new int[dataSources.length];
		if (by < 0)
			Arrays.sort(dataSources, new Comparator() {

				final MyTorrentsView this$0;

				public int compare(Object a, Object b)
				{
					return ((DownloadManager)a).getPosition() - ((DownloadManager)b).getPosition();
				}

			
			{
				this$0 = MyTorrentsView.this;
				super();
			}
			});
		else
			Arrays.sort(dataSources, new Comparator() {

				final MyTorrentsView this$0;

				public int compare(Object a, Object b)
				{
					return ((DownloadManager)b).getPosition() - ((DownloadManager)a).getPosition();
				}

			
			{
				this$0 = MyTorrentsView.this;
				super();
			}
			});
		int count = globalManager.downloadManagerCount(isSeedingView);
		for (int i = 0; i < dataSources.length; i++)
		{
			DownloadManager dm = (DownloadManager)dataSources[i];
			int pos = dm.getPosition() + by;
			if (pos < i + 1)
				pos = i + 1;
			else
			if (pos > count - i)
				pos = count - i;
			newPositions[i] = pos;
		}

		for (int i = 0; i < dataSources.length; i++)
		{
			DownloadManager dm = (DownloadManager)dataSources[i];
			globalManager.moveTo(dm, newPositions[i]);
		}

		boolean bForceSort = tv.getSortColumn().getName().equals("#");
		tv.columnInvalidate("#");
		tv.refreshTable(bForceSort);
	}

	private void moveSelectedTorrentsTop()
	{
		moveSelectedTorrentsTopOrEnd(true);
	}

	private void moveSelectedTorrentsEnd()
	{
		moveSelectedTorrentsTopOrEnd(false);
	}

	private void moveSelectedTorrentsTopOrEnd(boolean moveToTop)
	{
		Object datasources[] = tv.getSelectedDataSources().toArray();
		if (datasources.length == 0)
			return;
		DownloadManager downloadManagers[] = new DownloadManager[datasources.length];
		System.arraycopy(((Object) (datasources)), 0, downloadManagers, 0, datasources.length);
		if (moveToTop)
			globalManager.moveTop(downloadManagers);
		else
			globalManager.moveEnd(downloadManagers);
		boolean bForceSort = tv.getSortColumn().getName().equals("#");
		if (bForceSort)
		{
			tv.columnInvalidate("#");
			tv.refreshTable(bForceSort);
		}
	}

	public void parameterChanged(String parameterName)
	{
		if (parameterName == null || parameterName.equals("DND Always In Incomplete"))
			bDNDalwaysIncomplete = COConfigurationManager.getBooleanParameter("DND Always In Incomplete");
	}

	private void computePossibleActions()
	{
		Object dataSources[] = tv.getSelectedDataSources().toArray();
		up = down = run = remove = dataSources.length > 0;
		top = bottom = start = stop = false;
		for (int i = 0; i < dataSources.length; i++)
		{
			DownloadManager dm = (DownloadManager)dataSources[i];
			if (!start && ManagerUtils.isStartable(dm))
				start = true;
			if (!stop && ManagerUtils.isStopable(dm))
				stop = true;
			if (!top && dm.getGlobalManager().isMoveableUp(dm))
				top = true;
			if (!bottom && dm.getGlobalManager().isMoveableDown(dm))
				bottom = true;
		}

	}

	public boolean isEnabled(String itemKey)
	{
		if (itemKey.equals("run"))
			return run;
		if (itemKey.equals("start"))
			return start;
		if (itemKey.equals("stop"))
			return stop;
		if (itemKey.equals("remove"))
			return remove;
		if (itemKey.equals("top"))
			return top;
		if (itemKey.equals("bottom"))
			return bottom;
		if (itemKey.equals("up"))
			return up;
		if (itemKey.equals("down"))
			return down;
		if (itemKey.equals("share"))
			return remove;
		if (itemKey.equals("transcode"))
			return remove;
		else
			return super.isEnabled(itemKey);
	}

	public void itemActivated(String itemKey)
	{
		if (itemKey.equals("top"))
		{
			moveSelectedTorrentsTop();
			return;
		}
		if (itemKey.equals("bottom"))
		{
			moveSelectedTorrentsEnd();
			return;
		}
		if (itemKey.equals("up"))
		{
			moveSelectedTorrentsUp();
			return;
		}
		if (itemKey.equals("down"))
		{
			moveSelectedTorrentsDown();
			return;
		}
		if (itemKey.equals("run"))
		{
			TorrentUtil.runTorrents(tv.getSelectedDataSources().toArray());
			return;
		}
		if (itemKey.equals("start"))
		{
			TorrentUtil.queueTorrents(tv.getSelectedDataSources().toArray(), cTablePanel.getShell());
			return;
		}
		if (itemKey.equals("stop"))
		{
			TorrentUtil.stopTorrents(tv.getSelectedDataSources().toArray(), cTablePanel.getShell());
			return;
		}
		if (itemKey.equals("remove"))
		{
			TorrentUtil.removeTorrents(tv.getSelectedDataSources().toArray(), cTablePanel.getShell());
			return;
		} else
		{
			super.itemActivated(itemKey);
			return;
		}
	}

	public void downloadManagerAdded(Category category, DownloadManager manager)
	{
		if (isOurDownloadManager(manager))
			tv.addDataSource(manager);
	}

	public void downloadManagerRemoved(Category category, DownloadManager removed)
	{
		tv.removeDataSource(removed);
	}

	public void stateChanged(DownloadManager manager, int state)
	{
		final TableRowCore row = tv.getRow(manager);
		if (row != null)
			Utils.execSWTThreadLater(0, new AERunnable() {

				final TableRowCore val$row;
				final MyTorrentsView this$0;

				public void runSupport()
				{
					row.refresh(true);
					if (row.isSelected())
						refreshIconBar();
				}

			
			{
				this$0 = MyTorrentsView.this;
				row = tablerowcore;
				super();
			}
			});
	}

	public void positionChanged(DownloadManager download, int oldPosition, int newPosition)
	{
		if (isOurDownloadManager(download))
			Utils.execSWTThreadLater(0, new AERunnable() {

				final MyTorrentsView this$0;

				public void runSupport()
				{
					refreshIconBar();
				}

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

	public void filePriorityChanged(DownloadManager downloadmanager, DiskManagerFileInfo diskmanagerfileinfo)
	{
	}

	public void completionChanged(DownloadManager manager, boolean bCompleted)
	{
		if (isOurDownloadManager(manager))
		{
			if (currentCategory == null || currentCategory.getType() == 1)
			{
				tv.addDataSource(manager);
			} else
			{
				int catType = currentCategory.getType();
				Category manager_category = manager.getDownloadState().getCategory();
				if (manager_category == null)
				{
					if (catType == 2)
						tv.addDataSource(manager);
				} else
				if (currentCategory.getName().equals(manager_category.getName()))
					tv.addDataSource(manager);
			}
		} else
		if (isSeedingView && !bCompleted || !isSeedingView && bCompleted)
			tv.removeDataSource(manager);
	}

	public void downloadComplete(DownloadManager downloadmanager)
	{
	}

	private void activateCategory(Category category)
	{
		if (category != currentCategory)
		{
			if (currentCategory != null)
				currentCategory.removeCategoryListener(this);
			if (category != null)
				category.addCategoryListener(this);
			currentCategory = category;
		}
		Object managers[] = globalManager.getDownloadManagers().toArray();
		List list = tv.getDataSources();
		List listRemoves = new ArrayList();
		List listAdds = new ArrayList();
		for (int i = 0; i < managers.length; i++)
		{
			DownloadManager dm = (DownloadManager)managers[i];
			boolean bHave = list.contains(dm);
			if (!isOurDownloadManager(dm))
			{
				if (bHave)
					listRemoves.add(dm);
				continue;
			}
			if (!bHave)
				listAdds.add(dm);
		}

		tv.removeDataSources(listRemoves.toArray());
		tv.addDataSources(listAdds.toArray());
		tv.processDataSourceQueue();
	}

	public boolean isInCurrentCategory(DownloadManager manager)
	{
		return isInCategory(manager, currentCategory);
	}

	private boolean isInCategory(DownloadManager manager, Category category)
	{
		if (category == null)
			return true;
		int type = category.getType();
		if (type == 1)
			return true;
		Category dmCategory = manager.getDownloadState().getCategory();
		if (dmCategory == null)
			return type == 2;
		else
			return category.equals(dmCategory);
	}

	public void categoryAdded(Category category)
	{
		Utils.execSWTThread(new AERunnable() {

			final MyTorrentsView this$0;

			public void runSupport()
			{
				createTabs();
			}

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

	public void categoryRemoved(Category category)
	{
		Utils.execSWTThread(new AERunnable() {

			final MyTorrentsView this$0;

			public void runSupport()
			{
				createTabs();
			}

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

	public void downloadManagerAdded(DownloadManager dm)
	{
		dm.addListener(this);
		downloadManagerAdded(null, dm);
	}

	public void downloadManagerRemoved(DownloadManager dm)
	{
		dm.removeListener(this);
		DownloadBar.close(dm);
		downloadManagerRemoved(null, dm);
	}

	public void destroyInitiated()
	{
	}

	public void destroyed()
	{
	}

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

	public void rowAdded(TableRowCore row)
	{
		updateTableLabel();
	}

	public void rowRemoved(TableRowCore row)
	{
		updateTableLabel();
	}

	public void updateLanguage()
	{
		super.updateLanguage();
		updateTableLabel();
		getComposite().layout(true, true);
	}

	private void updateTableLabel()
	{
		if (refreshingTableLabel || lblHeader == null || lblHeader.isDisposed())
		{
			return;
		} else
		{
			refreshingTableLabel = true;
			lblHeader.getDisplay().asyncExec(new AERunnable() {

				final MyTorrentsView this$0;

				public void runSupport()
				{
					if (lblHeader != null && !lblHeader.isDisposed())
					{
						String sText = (new StringBuilder()).append(MessageText.getString((new StringBuilder()).append(tv.getTableID()).append("View").append(".header").toString())).append(" (").append(tv.size(true)).append(")").toString();
						lblHeader.setText(sText);
						lblHeader.getParent().layout();
					}
					refreshingTableLabel = false;
					break MISSING_BLOCK_LABEL_149;
					Exception exception;
					exception;
					refreshingTableLabel = false;
					throw exception;
				}

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

	public boolean isTableFocus()
	{
		return viewActive;
	}

	public Image obfusticatedImage(Image image, Point shellOffset)
	{
		return tv.obfusticatedImage(image, shellOffset);
	}

	protected TableViewSWT createTableView(String tableID, TableColumnCore basicItems[])
	{
		int tableExtraStyle = COConfigurationManager.getIntParameter("MyTorrentsView.table.style");
		return new TableViewSWTImpl(tableID, "MyTorrentsView", basicItems, "#", tableExtraStyle | 2 | 0x10000 | 0x10000000);
	}

	protected int getRowDefaultHeight()
	{
		return -1;
	}

	static 
	{
		LOGID = LogIDs.GUI;
	}




























}

⌨️ 快捷键说明

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