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

📄 mainstatusbar.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
			{
				if (statusText != null && !statusText.isDisposed())
				{
					statusText.setText(MessageText.getStringForSentence(text));
					statusText.setImage(statusImage);
				}
			}

			
			{
				this$0 = MainStatusBar.this;
				text = s;
				super();
			}
		});
	}

	public void refreshStatusText()
	{
		if (statusText != null && !statusText.isDisposed())
			statusText.update();
	}

	public void setUpdateNeeded(UpdateWindow updateWindow)
	{
		this.updateWindow = updateWindow;
		if (updateWindow != null)
		{
			statusText.setCursor(Cursors.handCursor);
			statusText.setForeground(Colors.colorWarning);
			updateStatusText();
		} else
		{
			statusText.setCursor(null);
			statusText.setForeground(null);
			updateStatusText();
		}
	}

	public void updateUI()
	{
		if (statusBar.isDisposed())
		{
			uiFunctions.getUIUpdater().removeUpdater(this);
			return;
		}
		org.eclipse.swt.widgets.Control plugin_elements[] = plugin_label_composite.getChildren();
		for (int i = 0; i < plugin_elements.length; i++)
			if (plugin_elements[i] instanceof UpdateableCLabel)
				((UpdateableCLabel)plugin_elements[i]).checkForRefresh();

		if (ipBlocked.isVisible())
			updateIPBlocked();
		if (srStatus.isVisible())
			updateShareRatioStatus();
		if (natStatus.isVisible())
			updateNatStatus();
		if (dhtStatus.isVisible())
			updateDHTStatus();
		int dl_limit = NetworkManager.getMaxDownloadRateBPS() / 1024;
		GlobalManagerStats stats = globalManager.getStats();
		statusDown.setText((new StringBuilder()).append(dl_limit != 0 ? (new StringBuilder()).append("[").append(dl_limit).append("K] ").toString() : "").append(DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(stats.getDataReceiveRate(), stats.getProtocolReceiveRate())).toString());
		boolean auto_up = COConfigurationManager.getBooleanParameter(TransferSpeedValidator.getActiveAutoUploadParameter(globalManager)) && TransferSpeedValidator.isAutoUploadAvailable(azureusCore);
		int ul_limit_norm = NetworkManager.getMaxUploadRateBPSNormal() / 1024;
		String seeding_only;
		if (NetworkManager.isSeedingOnlyUploadRate())
		{
			int ul_limit_seed = NetworkManager.getMaxUploadRateBPSSeedingOnly() / 1024;
			if (ul_limit_seed == 0)
			{
				seeding_only = "+∞K";
			} else
			{
				int diff = ul_limit_seed - ul_limit_norm;
				seeding_only = (new StringBuilder()).append(diff < 0 ? "" : "+").append(diff).append("K").toString();
			}
		} else
		{
			seeding_only = "";
		}
		statusUp.setText((new StringBuilder()).append(ul_limit_norm != 0 ? (new StringBuilder()).append("[").append(ul_limit_norm).append("K").append(seeding_only).append("]").toString() : "").append(auto_up ? "* " : " ").append(DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(stats.getDataSendRate(), stats.getProtocolSendRate())).toString());
		statusBar.layout();
	}

	private void updateDHTStatus()
	{
		int dht_status = dhtPlugin != null ? dhtPlugin.getStatus() : 1;
		long dht_count = -1L;
		if (dht_status == 3)
		{
			DHT dhts[] = dhtPlugin.getDHTs();
			dht_count = dhts[0].getControl().getStats().getEstimatedDHTSize();
		}
		if (lastDHTstatus != dht_status || lastDHTcount != dht_count)
		{
			boolean hasImage = dhtStatus.getImage() != null;
			boolean needImage = true;
			switch (dht_status)
			{
			case 3: // '\003'
				dhtStatus.setToolTipText(MessageText.getString("MainWindow.dht.status.tooltip"));
				dhtStatus.setText(MessageText.getString("MainWindow.dht.status.users").replaceAll("%1", numberFormat.format(dht_count)));
				break;

			case 1: // '\001'
				dhtStatus.setText(MessageText.getString("MainWindow.dht.status.disabled"));
				break;

			case 2: // '\002'
				dhtStatus.setText(MessageText.getString("MainWindow.dht.status.initializing"));
				break;

			case 4: // '\004'
				dhtStatus.setText(MessageText.getString("MainWindow.dht.status.failed"));
				break;

			default:
				needImage = false;
				break;
			}
			if (hasImage != needImage)
			{
				ImageLoader imageLoader = ImageLoader.getInstance();
				if (needImage)
				{
					Image img = imageLoader.getImage("sb_count");
					dhtStatus.setImage(img);
				} else
				{
					imageLoader.releaseImage("sb_count");
					dhtStatus.setImage(null);
				}
			}
			lastDHTstatus = dht_status;
			lastDHTcount = dht_count;
		}
	}

	private void updateNatStatus()
	{
		int nat_status = connection_manager.getNATStatus();
		if (lastNATstatus != nat_status)
		{
			String imgID;
			String tooltipID;
			String statusID;
			switch (nat_status)
			{
			case 0: // '\0'
				imgID = "grayled";
				tooltipID = "MainWindow.nat.status.tooltip.unknown";
				statusID = "MainWindow.nat.status.unknown";
				break;

			case 1: // '\001'
				imgID = "greenled";
				tooltipID = "MainWindow.nat.status.tooltip.ok";
				statusID = "MainWindow.nat.status.ok";
				break;

			case 2: // '\002'
				imgID = "yellowled";
				tooltipID = "MainWindow.nat.status.tooltip.probok";
				statusID = "MainWindow.nat.status.probok";
				break;

			default:
				imgID = "redled";
				tooltipID = "MainWindow.nat.status.tooltip.bad";
				statusID = "MainWindow.nat.status.bad";
				break;
			}
			if (!imgID.equals(lastNATimageID))
			{
				ImageLoader imageLoader = ImageLoader.getInstance();
				natStatus.setImage(imageLoader.getImage(imgID));
				if (lastNATimageID != null)
					imageLoader.releaseImage(lastNATimageID);
				lastNATimageID = imgID;
			}
			natStatus.setToolTipText(MessageText.getString(tooltipID));
			natStatus.setText(MessageText.getString(statusID));
			lastNATstatus = nat_status;
		}
	}

	private void updateShareRatioStatus()
	{
		long ratio = (1000L * overall_stats.getUploadedBytes()) / (overall_stats.getDownloadedBytes() + 1L);
		int sr_status;
		if (ratio < 500L)
			sr_status = 0;
		else
		if (ratio < 900L)
			sr_status = 1;
		else
			sr_status = 2;
		if (sr_status != last_sr_status)
		{
			String imgID;
			switch (sr_status)
			{
			case 2: // '\002'
				imgID = "greenled";
				break;

			case 1: // '\001'
				imgID = "yellowled";
				break;

			default:
				imgID = "redled";
				break;
			}
			if (!imgID.equals(lastSRimageID))
			{
				ImageLoader imageLoader = ImageLoader.getInstance();
				srStatus.setImage(imageLoader.getImage(imgID));
				if (lastSRimageID != null)
					imageLoader.releaseImage(lastSRimageID);
				lastSRimageID = imgID;
			}
			last_sr_status = sr_status;
		}
		if (ratio != last_sr_ratio)
		{
			String tooltipID;
			switch (sr_status)
			{
			case 2: // '\002'
				tooltipID = "MainWindow.sr.status.tooltip.ok";
				break;

			case 1: // '\001'
				tooltipID = "MainWindow.sr.status.tooltip.poor";
				break;

			default:
				tooltipID = "MainWindow.sr.status.tooltip.bad";
				break;
			}
			String ratio_str = "";
			String partial;
			for (partial = (new StringBuilder()).append("").append(ratio % 1000L).toString(); partial.length() < 3; partial = (new StringBuilder()).append("0").append(partial).toString());
			ratio_str = (new StringBuilder()).append(ratio / 1000L).append(".").append(partial).toString();
			srStatus.setToolTipText(MessageText.getString(tooltipID, new String[] {
				ratio_str
			}));
			last_sr_ratio = ratio;
		}
	}

	private void updateIPBlocked()
	{
		IpFilter ip_filter = azureusCore.getIpFilterManager().getIPFilter();
		ipBlocked.setText((new StringBuilder()).append("IPs: ").append(numberFormat.format(ip_filter.getNbRanges())).append(" - ").append(numberFormat.format(ip_filter.getNbIpsBlockedAndLoggable())).append("/").append(numberFormat.format(ip_filter.getNbBannedIps())).append("/").append(numberFormat.format(azureusCore.getIpFilterManager().getBadIps().getNbBadIps())).toString());
		ipBlocked.setToolTipText(MessageText.getString("MainWindow.IPs.tooltip", new String[] {
			DisplayFormatters.formatDateShort(ip_filter.getLastUpdateTime())
		}));
	}

	public void setDebugInfo(String string)
	{
		if (!statusText.isDisposed())
			statusText.setToolTipText(string);
	}

	public boolean isMouseOver()
	{
		if (statusText.isDisposed())
			return false;
		else
			return statusText.getDisplay().getCursorControl() == statusText;
	}

	public CLabel createStatusEntry(final CLabelUpdater updater)
	{
		final CLabel result[] = new CLabel[1];
		Utils.execSWTThread(new AERunnable() {

			final CLabel val$result[];
			final CLabelUpdater val$updater;
			final MainStatusBar this$0;

			public void runSupport()
			{
				this_mon.enter();
				result[0] = new UpdateableCLabel(plugin_label_composite, 32, updater);
				result[0].setLayoutData(new GridData(1808));
				this_mon.exit();
				break MISSING_BLOCK_LABEL_85;
				Exception exception;
				exception;
				this_mon.exit();
				throw exception;
			}

			
			{
				this$0 = MainStatusBar.this;
				result = aclabel;
				updater = clabelupdater;
				super();
			}
		}, false);
		return result[0];
	}

	private void showProgressBar(boolean state)
	{
		if (state && !progressBar.isVisible())
		{
			progressGridData.widthHint = 100;
			progressBar.setVisible(true);
			statusBar.layout();
		} else
		if (!state && progressBar.isVisible())
		{
			progressBar.setVisible(false);
			progressGridData.widthHint = 0;
			statusBar.layout();
		}
	}

	private void updateProgressBarDisplay(IProgressReport pReport)
	{
		latestReport_mon.enter();
		latestReport = pReport;
		latestReport_mon.exit();
		break MISSING_BLOCK_LABEL_32;
		Exception exception;
		exception;
		latestReport_mon.exit();
		throw exception;
		if (null == progressBar || progressBar.isDisposed() || updateProgressBarDisplayQueued)
		{
			return;
		} else
		{
			updateProgressBarDisplayQueued = true;
			Utils.execSWTThread(new AERunnable() {

				final MainStatusBar this$0;

				public void runSupport()
				{
					latestReport_mon.enter();
					updateProgressBarDisplayQueued = false;
					if (null == progressBar || progressBar.isDisposed())
					{
						latestReport_mon.exit();
						return;
					}
					if (null != latestReport)
					{
						progressBar.setMinimum(latestReport.getMinimum());
						progressBar.setMaximum(latestReport.getMaximum());
						progressBar.setIndeterminate(latestReport.isIndeterminate());
						progressBar.setPercentage(latestReport.getPercentage());
						showProgressBar(true);
						if (isAZ3)
							statusText.setText(latestReport.getName());
						else
							setStatusText(latestReport.getName());
					} else
					{
						showProgressBar(false);
						if (isAZ3)
							statusText.setText("");
						else
							setStatusText(null);
					}
					latestReport_mon.exit();
					break MISSING_BLOCK_LABEL_288;
					Exception exception1;
					exception1;
					latestReport_mon.exit();
					throw exception1;
				}

			
			{
				this$0 = MainStatusBar.this;
				super();
			}
			}, true);
			return;
		}
	}

	private void setProgressImage()
	{
		Image newProgressImage;
		if (PRManager.getReporterCount(2) > 0)
			newProgressImage = progress_error_img;
		else
		if (PRManager.getReporterCount(0) > 0)
			newProgressImage = progress_info_img;
		else
			newProgressImage = progress_viewer_img;
		if (currentProgressImage != newProgressImage)
		{
			currentProgressImage = newProgressImage;
			Utils.execSWTThread(new AERunnable() {

				final MainStatusBar this$0;

				public void runSupport()
				{
					if (progressViewerImageLabel.isDisposed())
					{
						return;
					} else
					{
						progressViewerImageLabel.setImage(currentProgressImage);
						return;
					}
				}

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

	public Rectangle getBounds()
	{
		if (null != statusBar)
			return statusBar.getBounds();
		else
			return null;
	}

	public String getUpdateUIName()
	{
		return "MainStatusBar";
	}






















}

⌨️ 快捷键说明

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